工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.wdlinux.cn 注册 | 登陆

OpenVZ安装

OpenVZ 是唯一可用于unibilling生产用的服务器虚拟技术。目前全球有多套unibilling运行于OpenVZ container。经过3年多的VOIP连续运营生产,证实绝对可靠稳定。

在新的服务器上用如下步骤安装openVZ:

导入 OpenVZ yum源

cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm –import  http://download.openvz.org/RPM-GPG-Key-OpenVZ

下载openVZ内核及头文件安装包

mkdir -p /usr/src/files

cd /usr/src/files

wget http://download.openvz.org/kernel/branches/rhel5-2.6.18/028stab068.3/ovzkernel-2.6.18-164.11.1.el5.028stab068.3.i686.rpm

wget http://download.openvz.org/kernel/branches/rhel5-2.6.18/028stab068.3/ovzkernel-devel-2.6.18-164.11.1.el5.028stab068.3.i686.rpm

安装openVZ内核及头文件

rpm -ihv ovzkernel*.rpm

配置boot loader确保使用openVZ的内核启动

vi /etc/grub.conf

配置 sysctl

确保 /etc/sysctl.conf 文件中包含如下信息:

# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0

# Enables source route verification
net.ipv4.conf.all.rp_filter = 1

# Enables the magic-sysrq key
kernel.sysrq = 1

# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

编辑完毕保存,运行如下命令使之生效:

sysctl -p

禁用 SELinux

修改 /etc/sysconfig/selinux 文件,使其包含信息:
SELINUX=disabled

重新启动linux

shutdown -r now

机器重新启动后,运行 uname -r检查是否已经是openVZ的内核

安装openvz工具集

yum install vzquota
yum install vzctl-lib
yum install vzctl
yum install vzyum
yum install vzpkg
yum install vzrpm43-python
yum install vzrpm44-python

启动OpenVZ服务

/sbin/service vz start

安装操作系统模板文件

查找系统中可用的操作系统模板
yum search vztmpl
[root@tpd620 /]# yum search vztmpl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirror.ii.uib.no
* base: mirror.ii.uib.no
* extras: mirror.ii.uib.no
* openvz-kernel-rhel5: openvz.proserve.nl
* openvz-utils: openvz.proserve.nl
* updates: mirror.ii.uib.no
====================== Matched: vztmpl =======================
vztmpl-centos-4.i386 : OpenVZ template metadata for centos-4 i386.
vztmpl-fedora-7.i386 : OpenVZ template metadata for fedora-7 i386.
vztmpl-fedora-core-3.i386 : OpenVZ template metadata for fedora-core-3 i386.
vztmpl-fedora-core-4.i386 : OpenVZ template metadata for fedora-core-4 i386.
vztmpl-fedora-core-5.i386 : OpenVZ template metadata for fedora-core-5 i386.
vztmpl-fedora-core-6.i386 : OpenVZ template metadata for fedora-core-6 i386.
[root@tpd620 /]#

安装centos linux操作系统模板
yum install vztmpl-centos-4
为操作系统模板建立缓存
vzpkgcache

该命令将建立 centos-4-i386-minimal.tar.gz 和 centos-4-i386-default.tar.gz
vzpkgcache centos-4-i386-minimal 将只建立 centos-4-i386-minimal.tar.gz
vzpkgcache centos-4-i386-default 将只建立 centos-4-i386-default.tar.gz

查看系统中存在的操作系统缓存:
[root@c8 ~]# vzpkgls
centos-4-i386-default
centos-4-i386-minimal
建立OpenVZ节点container

准备配置文件
为方便起见,平分Host机器的内存和CPU
cd /etc/sysconfig/vz-scripts/
vzsplit -n 3 -f vps.mytest

上述命令将均分系统资源为3等份,产生一个例子配置文件
验证该文件的有效性:vzcfgvalidate ve-vps.mytest.conf-sample
创建节点VPS
vzctl create 112 --ostemplate centos-4-i386-minimal --config vps.mytest
配置该VPS
vzctl set 112 --hostname unibillingsrv1 --save
vzctl set 112 --ipadd 207.182.xxx.xxx --save
vzctl set 112 --userpasswd root:xxxxxxxxx
vzctl set 112 --nameserver 209.190.xxx.xxx --save
vzctl set 112 --onboot yes --save
vzctl start 112
vzctl exec 112 service sshd start
vzctl enter 112
vzctl stop 112
配置VPS硬盘容量等参数
grep DISK_QUOTA /etc/sysconfig/vz
df /vz
vi /etc/sysconfig/vz-scripts/112.conf

在该文件中添加 DISK_QUOTA=no
grep DISK_QUOTA /etc/sysconfig/vz-scripts/112.conf
vzctl stop 112

vzctl start 112
vzctl exec 112 df

vzctl set 112 --diskinodes 75000000:79000000 --save

vzctl set 112 --quotatime 600 --save

vzctl exec 112 df

vzctl exec 112 stat -f /

vzctl set 112 --quotaugidlimit 100 --save
vzctl stop 112
vzctl start 112

vzctl exec 112 rpm -q quota

vzyum 112 install quota

vzquota stat 112 -t
向新建的vps中安装yum等工具
vzyum 112 install yum

vzyum 112 install diffutils
错误处理
若vzctl enter进入节点时出现错误,或ssh无法进入节点,需要运行如下命令:
vzctl exec 112 "cd /dev; /sbin/MAKEDEV pty; /sbin/MAKEDEV tty; /sbin/MAKEDEV generic"

« 上一篇 | 下一篇 »

Trackbacks

点击获得Trackback地址,Encode: UTF-8

发表评论

评论内容 (必填):