As root user:
$ rpm -ivh http://mirror.nl.leaseweb.net/epel/6/i386/epel-release-6-8.noarch.rpm$ yum install lxc lxc-libs lxc-templates bridge-utils libcgroup$ service cgconfig start
$ service cgred start
$ chkconfig --level 345 cgconfig on
$ chkconfig --level 345 cgred onthe easiest way is to create an internal network, so you do not need to expose the LXC to the bare-metal server network.
$ brctl addbr lxcbr0create /etc/sysconfig/network-scripts/ifcfg-lxcbr0 and add
DEVICE="lxcbr0"
TYPE="Bridge"
BOOTPROTO="static"
IPADDR="10.0.3.1"
NETMASK="255.255.255.0"
$ ifup lxcbr0to allow outgoing traffic from the container: edit /etc/sysconfig/iptables and
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
*nat
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
$ service iptables restartedit /etc/sysctl.conf and change net.ipv4.ip_forward = 0 to net.ipv4.ip_forward = 1, then apply the new parameters with
$ sysctl –p$ cd /tmp && wget http://www.globalquakemodel.org/lxc/Ubuntu_lxc_14.04_64_oq_1.5-0.tar.bz2$ tar --numeric-owner -C /var/lib/lxc -xpsjf /tmp/Ubuntu_lxc_14.04_64_oq_1.5-0.tar.bz2with the command lxc-ls you should see
$ lxc-ls
openquake-nightly-141020open /var/lib/lxc/openquake/rootfs/etc/network/interfaces and change iface eth0 inet dhcp to
iface eth0 inet static
address 10.0.3.2
netmask 255.255.255.0
gateway 10.0.3.1
dns-nameservers 8.8.8.8
$ lxc-start –d –n openquake$ lxc-console –n openquake
(to detach press ctrl-a + q)You can also login using SSH from the host server:
$ ssh openquake@10.0.3.2
User: openquake
Password: openquake- This how-to is intended for a fresh, standard installation of RHEL/CentOS 6 (and is tested on 6.4). It may need some adjustments for customized installations.
- On 5. the firewall could be already customized by the sysadmin, please be careful when edit it. For more details please ask to your network and/or system administrator.
- On 5. section b.
-A POSTROUTING -o eth0 -j MASQUERADE"eth0" is the name of the host server main interface. It can differ in your configuration (see the used interface with ifconfig). - On 8. the
--numeric-owneris mandatory. - On 10. the
8.8.8.8DNS is the one provided by Google. It’s better to use your internal DNS, so change that IP address with the one associated to your DNS server. For more details please ask to your network and/or system administrator. - On certain installations the
rsyslogdprocess inside the container can eat lots of CPU cycles. To fix it run, within the container, these commands (not required on containers prepared by us):
service rsyslog stop
sed -i -e 's/^\$ModLoad imklog/#\$ModLoad imklog/g' /etc/rsyslog.conf
service rsyslog start