Click HERE to get FREE USD10

NetData is COOL

Recently, my friend send me this Netdata and is pretty cool!!
Just git clone and install.

# download it - the directory 'netdata.git' will be created
git clone https://github.com/firehol/netdata.git --depth=1
cd netdata

# build it
./netdata-installer.sh

In order to view it, either using ssh tunneling to the server and use the web browser point to the port 19999. e.g.: http://localhost:19999

#netdata

Standard Debian LXC Containers TODO

Usually, the default containers do not have the configuration we need. The below steps are quite crucial:

# echo "nameserver 8.8.8.8" > /etc/resolv.conf
# /bin/mkdir -p /etc/systemd/system/networking.service.d/         # This is to make sure the folder is being created.
# echo -e "[Service]\nTimeoutStartSec=5" > /etc/systemd/system/networking.service.d/reduce-timeout.conf          # This is to make sure the network starting time will not hang the whole container.
# passwd        # Changing the password of the root user

Next is to lxc-console to the container and setup the pre-requisite packages.

FromHost# lxc-console -n thenewcontainername
Connected to tty 1
Type  to exit the console,  to enter Ctrl+a itself

Debian GNU/Linux 8 thenewcontainername tty1

thenewcontainername login: root
Password:
...
...
root@thenewcontainername:~# 

lxc_cgfsng – cgfsng.c:cgfsng_setup_limits:1707 – No such file or directory – Error setting memory.limit_in_bytes to 128M for XXX Container

Well, this happened on debian jessie. In order to fix this, just need to add the below to the grub boot up line.

cgroup_enable=memory

This will solved the memory limit for the LXC containers. 😉

Added Notes:
Also I had noticed, without this, there won’t be showing the memory used by the containers. You will find the below if the cgroup_enable=memory is enabled. If the container’s memory info are missing, that is the root cause.

# cat /sys/fs/cgroup/memory

Installing LXC to DigitalOcean

For installing LXC to DigitalOcean, I use the below methods:

Pre-requisite:

# apt-get install htop vim build-essential bridge-utils git automake pkg-config build-essential python3 python3-dev liblua5.1-0-dev libcgmanager-dev cgmanager chrpath libcap-dev

Next, checking out from github:

# git clone https://github.com/lxc/lxc.git
# cd lxc
# ./autogen.sh
# ./configure
# make && make install
# ldconfig -v

Configuring the LXC Host by editing /usr/local/etc/lxc/default.conf:

lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx

OpenVZ on DigitalOcean (CentOS)

Well, this is just some experimental project that I had tested on DigitalOcean where I am using OpenVZ kernel on DigitalOcean servers.

Here is how I do:
1. Remove away unwanted packages on host

# yum -y remove mysql* postfix
# yum update -y
# yum install -y wget

2. Adding swap:

# dd if=/dev/zero of=/swapfile bs=1k count=1M
# mkswap /swapfile
# swapon swapfile

3. Setting the permanent change:

# echo  '/swapfile          swap            swap    defaults        0 0' >> /etc/fstab
# chown root:root /swapfile
# chmod 0600 /swapfile
# swapon -s

4. Install OpenVZ kernel:

# cd /etc/yum.repos.d
# wget http://download.openvz.org/openvz.repo
# rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
# yum install -y vzkernel.x86_64 vzctl vzquota ploop

5. Getting the default OpenVZ settings:

# sed -i 's/kernel.sysrq = 0/kernel.sysrq = 1/g' /etc/sysctl.conf
# sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
# echo 'net.ipv4.conf.default.proxy_arp = 0' >> /etc/sysctl.conf
# echo 'net.ipv4.conf.all.rp_filter = 1' >> /etc/sysctl.conf
# echo 'net.ipv4.conf.default.send_redirects = 1' >> /etc/sysctl.conf
# echo 'net.ipv4.conf.all.send_redirects = 0' >> /etc/sysctl.conf
# echo 'net.ipv4.icmp_echo_ignore_broadcasts=1' >> /etc/sysctl.conf
# echo 'net.ipv4.conf.default.forwarding=1' >> /etc/sysctl.conf
# sysctl -p
# sed -i 's/NEIGHBOUR_DEVS=detect/NEIGHBOUR_DEVS=all/g' /etc/vz/vz.conf
# sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/sysconfig/selinux
# yum install -y ntp
# ntpdate -u us.pool.ntp.org
# chkconfig ntpd on

6. Changing some configurations which is allowing iptables to be loaded. Change to below value at /etc/modprobe.d/openvz.conf:

options nf_conntrack ip_conntrack_disable_ve0=0

7. Get the latest kernel and replace the version number to below script:

# ls -t /boot/vmlinuz-*
/boot/vmlinuz-2.6.32-573.12.1.el6.x86_64  /boot/vmlinuz-2.6.32-573.1.1.el6.x86_64
/boot/vmlinuz-2.6.32-573.8.1.el6.x86_64   /boot/vmlinuz-2.6.32-504.12.2.el6.x86_64
/boot/vmlinuz-2.6.32-042stab112.15        /boot/vmlinuz-2.6.32-504.3.3.el6.x86_64

8. Use the right version number and replace to below script at /usr/local/bin/startOpenVZ.sh:

# vim /usr/local/bin/startOpenVZ.sh
#!/bin/bash

# Changing the kernel to OpenVZ Kernel
latestkernel="2.6.32-042stab112.15"

# Detect kernel version. If is not the same then execute the below commands
CURRENT_VERSION="$(/bin/uname -r)"
if [ "${CURRENT_VERSION}" == "${latestkernel}" ];
then
        echo "Kernel -> OpenVZ [OK]"
        exit
fi
echo "Kernel -> OpenVZ [Not loaded]"
echo "Loading OpenVZ kernel"

/sbin/kexec -l /boot/vmlinuz-${latestkernel} --initrd=/boot/initramfs-${latestkernel}.img --append="`cat /proc/cmdline`"
/sbin/kexec -e

9. Change the file to be executable and put to the cronjob:

# chmod 755 /usr/local/bin/startOpenVZ.sh
# chown root.root /usr/local/bin/startOpenVZ.sh
# crontab -e
@reboot /usr/local/bin/startOpenVZ.sh

10. Reboot the droplet:

# reboot

#openvz #droplet #digitalocean