标题: How-to install LXC and OpenQuake LXC on RHEL/CentOS 6 [打印本页] 作者: 翔子 时间: 2014-10-1 10:49 标题: How-to install LXC and OpenQuake LXC on RHEL/CentOS 6 How-to install LXC and OpenQuake LXC on RHEL/CentOS 6
As root user:
1. Add the EPEL repo to your RHEL/CentOS 6 server:
rpm -ivh [url=http://mirror.1000mbps.com/fedora-epel/6/i386/epelrelease-6-8.noarch.rpm]http://mirror.1000mbps.com/fedora-epel/6/i386/epelrelease-6-8.noarch.rpm
2. Install LXC 0.9.0 from epel-testing and some other stuff needed:
yum install --enablerepo=epel-testing lxc lxc-libs lxc-templates
bridge-utils libcgroup
3. Enable cgroups:
service cgconfig start
service cgred start
chkconfig --level 345 cgconfig on
chkconfig --level 345 cgred on
4. Setup the network: the easiest way is to create an internal network, so you do not need to
expose the LXC to the bare-metal server network.
a. Create the bridge:
brctl addbr lxcbr0
b. Make the bridge persistent on reboot: create /etc/sysconfig/network-scripts/ifcfglxcbr0 and add
DEVICE="lxcbr0"
TYPE="Bridge"
BOOTPROTO="static"
IPADDR="10.0.3.1"
NETMASK="255.255.255.0"
c. Start the bridge interface
ifup lxcbr0
5. Configure the firewall to allow outgoing traffic from the container: edit
/etc/sysconfig/iptables and
a. Comment or remove
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
b. Add at the end of file:
*nat REROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0] OSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
c. Restart the firewall:
service iptables restart
6. Enable IPv4 forwarding editing /etc/sysctl.conf:a. Change net.ipv4.ip_forward = 0 to net.ipv4.ip_forward = 1
b. Then apply the new parameters
sysctl –p
7. Download OpenQuake LXC:
cd /tmp && wget [url=ftp://ftp.openquake.org/oq]ftp://ftp.openquake.org/oq-
1.0/lxc/Ubuntu_lxc_12.04.2_64_oq_1-0.tar.bz2
8. Extract the OpenQuake LXC:
tar --numeric-owner -C /var/lib/lxc \
-xpsjf /tmp/Ubuntu_lxc_12.04.2_64_oq_1-0.tar.bz2
9. Check if the LXC is installed and ready: with the command lxc-ls you should see
“openquake”
10.Setup the OpenQuake LXC ip address: open
/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
11.Start the OpenQuake LXC:
lxc-start –d –n openquake
12.Login into the running OpenQuake LXC:
lxc-console –n openquake
(to detach press ctrl-a + q)
You can also login using SSH from the host server:
ssh [url=mailtopenquake@10.0.3.2]openquake@10.0.3.2
User: openquake
Password: openquake
Please note:
• 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-owner is mandatory.
• On 10. the 8.8.8.8 DNS 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.作者: 翔子 时间: 2014-10-1 10:55 标题: CentOS 6 使用 LXC 原文: [url=http://purplegrape.blog.51cto.com/1330104/1343766]http://purplegrape.blog.51cto.com/1330104/1343766