XEN下虚拟机安装openvz
[
2009/11/04 23:46 | by suibing ]
2009/11/04 23:46 | by suibing ]
1. Install OpenVZ Repo
cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
2.
yum install ovzkernel-xen -y
3.
yum install vzctl vzquota xen -y
4.
$ setenforce 0
$ wget http://download.lxlabs.com/download/hypervm/production/hypervm-install-master.sh
$ sh ./hypervm-install-master.sh --virtualization-type=xen/openvz/NONE
5.
cd /usr/local/lxlabs/hypervm/httpdocs/
lphp.exe ../bin/common/setdriver.php --server=localhost --class=vps --driver=openvz
母机也需要这样安装带有xen和openvz内核,然后才能虚拟出支持openvz的XEN虚拟机
cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ
2.
yum install ovzkernel-xen -y
3.
yum install vzctl vzquota xen -y
4.
$ setenforce 0
$ wget http://download.lxlabs.com/download/hypervm/production/hypervm-install-master.sh
$ sh ./hypervm-install-master.sh --virtualization-type=xen/openvz/NONE
5.
cd /usr/local/lxlabs/hypervm/httpdocs/
lphp.exe ../bin/common/setdriver.php --server=localhost --class=vps --driver=openvz
母机也需要这样安装带有xen和openvz内核,然后才能虚拟出支持openvz的XEN虚拟机
制作及下载XEN模板
[
2009/11/04 08:39 | by suibing ]
2009/11/04 08:39 | by suibing ]
下载地址:
http://stacklet.com/
http://modernadmin.com/downloads/?d=ostemplates/xen
其中http://stacklet.com/的模板是img的,需要需该才能用于hypervm
修改步骤如下:
Note: Root access is required. This MUST be done on a server or VPS that allows mounting using the loop device, as this is needed for some of the steps.
For our example, we are going to demonstrate how to convert the debian image into a HyperVM-ready image. This can also be done on any other template provided by JailTime.org.
Firstly, we must download the image onto the machine we’re going to be doing the conversion on.
Code:
cd ~
wget "http://www.jailtime.org/lib/exe/fetch.php?cache=cache&media=download%3Adebian64%3Adebian.4-0.64.20080709.img.tar.bz2"
After downloading the file, we are going to extract out the image. There will be a xen configuration file in the archive as well, but this can be ignored as HyperVM generates its own xen configuration file.
Code:
tar jxf debian.4-0.64.20080709.img.tar.bz2
Next, we will prepare a directory to mount the image file to, and mount it using the loop device.
Code:
mkdir /mnt/tmp
mount -o loop ~/debian.4-0.64.img /mnt/tmp
For the Xen console to work correctly add the following line to /etc/inittab
Code:
nano /mnt/tmp/etc/inittab
1:2345:respawn:/sbin/getty -L xvc0 9600 vt100
Also ensure that the line containing tty1 is commented out, as this may cause conflicts.
SSH Root logins must be permitted. Edit /etc/ssh/sshd_config
Code:
nano /mnt/tmp/etc/ssh/sshd_config
PermitRootLogin yes
Now, to get to the very simple part. All we need to do now is tarball the image so that HyperVM can read it appropriately.
Code:
[/code]
cd /mnt/tmp
tar czf /home/hypervm/xen/template/debian-4.0-x86_64-jailtime.tar.gz .
Please note, when naming the templates, you MUST name the template in the following schema:
Code:
[code]
distro-version-arch-custom.tar.gz
This instructs HyperVM which configuration variables it must pass to xen, and which configuration HyperVM must choose to ensure that the VPS will boot successfully.
For slackware users, the following should go in /etc/inittab
Code:
c1:2345:respawn:/bin/sh
#c1:1235:respawn:/sbin/agetty 38400 tty1 linux
#c2:1235:respawn:/sbin/agetty 38400 tty2 linux
#c3:1235:respawn:/sbin/agetty 38400 tty3 linux
#c4:1235:respawn:/sbin/agetty 38400 tty4 linux
#c5:1235:respawn:/sbin/agetty 38400 tty5 linux
#c6:12345:respawn:/sbin/agetty 38400 tty6 linux
http://stacklet.com/
http://modernadmin.com/downloads/?d=ostemplates/xen
其中http://stacklet.com/的模板是img的,需要需该才能用于hypervm
修改步骤如下:
Note: Root access is required. This MUST be done on a server or VPS that allows mounting using the loop device, as this is needed for some of the steps.
For our example, we are going to demonstrate how to convert the debian image into a HyperVM-ready image. This can also be done on any other template provided by JailTime.org.
Firstly, we must download the image onto the machine we’re going to be doing the conversion on.
Code:
cd ~
wget "http://www.jailtime.org/lib/exe/fetch.php?cache=cache&media=download%3Adebian64%3Adebian.4-0.64.20080709.img.tar.bz2"
After downloading the file, we are going to extract out the image. There will be a xen configuration file in the archive as well, but this can be ignored as HyperVM generates its own xen configuration file.
Code:
tar jxf debian.4-0.64.20080709.img.tar.bz2
Next, we will prepare a directory to mount the image file to, and mount it using the loop device.
Code:
mkdir /mnt/tmp
mount -o loop ~/debian.4-0.64.img /mnt/tmp
For the Xen console to work correctly add the following line to /etc/inittab
Code:
nano /mnt/tmp/etc/inittab
1:2345:respawn:/sbin/getty -L xvc0 9600 vt100
Also ensure that the line containing tty1 is commented out, as this may cause conflicts.
SSH Root logins must be permitted. Edit /etc/ssh/sshd_config
Code:
nano /mnt/tmp/etc/ssh/sshd_config
PermitRootLogin yes
Now, to get to the very simple part. All we need to do now is tarball the image so that HyperVM can read it appropriately.
Code:
[/code]
cd /mnt/tmp
tar czf /home/hypervm/xen/template/debian-4.0-x86_64-jailtime.tar.gz .
Please note, when naming the templates, you MUST name the template in the following schema:
Code:
[code]
distro-version-arch-custom.tar.gz
This instructs HyperVM which configuration variables it must pass to xen, and which configuration HyperVM must choose to ensure that the VPS will boot successfully.
For slackware users, the following should go in /etc/inittab
Code:
c1:2345:respawn:/bin/sh
#c1:1235:respawn:/sbin/agetty 38400 tty1 linux
#c2:1235:respawn:/sbin/agetty 38400 tty2 linux
#c3:1235:respawn:/sbin/agetty 38400 tty3 linux
#c4:1235:respawn:/sbin/agetty 38400 tty4 linux
#c5:1235:respawn:/sbin/agetty 38400 tty5 linux
#c6:12345:respawn:/sbin/agetty 38400 tty6 linux
CentOS 安裝 Lighttpd + PHP5 + FastCgi + eaccelerator
[
2009/10/30 11:10 | by suibing ]
2009/10/30 11:10 | by suibing ]
最近发现论坛经常性会挂掉,后来发现是lighttpd和fastcgi的问题,面板自带的一直没法升级,本地测试了一下,就升级到lighttpd1.4.22了
下面讲一下安装步骤,可以直接yum的,真方便
RHEL5 / CentOS-5
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
RHEL4 / CentOS-4
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.x86_64.rpm
RHEL3 / CentOS-3
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el3.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el3.rf.x86_64.rpm
RHEL2.1 / CentOS-2
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el2.rf.i386.rpm
就是找你的版本,然後下載安裝:
#
# 安裝
#
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
安裝 lighttpd
#
# yum 安裝
#
yum install lighttpd
yum install lighttpd-fastcgi php-cli
然後編輯:/etc/php.ini 加上
cgi.fix_pathinfo = 1
; cgi.fix_pathinfo 为CGI提供 *真实* PATH_INFO/PATH_TRANSLATED 支持.
; PHP的预处理行为是设置 PATH_TRANSLATED 到 SCRIPT_FILENAME, 并且不去猜测 PATH_INFO 是什么.
; 想获取关于 PATH_INFO 更多的信息, 查看 cgi 规范.
; 将此值设置为1会引起PHP CGI修正它的路径来符合规范.
; 设置为0会引起PHP类似前面的行为. 默认是1. 你应该修正你的脚本来使用 SCRIPT_FILENAME 而不是 PATH_TRANSLATED.
; cgi.fix_pathinfo=0
这个我没改,用了面板默认的
然後修改 lighttpd.conf
#
# 修改
#
vi /etc/lighttpd/lighttpd.confserver.modules = (
"mod_rewrite",
"mod_redirect",
"mod_alias",
"mod_access",
"mod_fastcgi",
"mod_proxy",
"mod_evhost",
"mod_userdir",
"mod_accesslog" )
server.document-root = "/var/www/html/"
server.errorlog = "/var/log/lighttpd/error.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
)
)
$HTTP["host"] == "mini101.twgg.org" {
server.document-root = "/var/www/html/Mini/"
#url.rewrite = ( "^/(archives|categories|comments|feed)/" => "/index.php" )
url.rewrite = (
"^/?$" => "/index.php",
"^/(\?.*)$" => "/index.php$1",
"^/(wp-.+)$" => "$0",
"^/([^.]+)/?$" => "/index.php?$1",
)
accesslog.filename = "/var/log/lighttpd/mini101.twgg.org-access_log"
}
安裝:eaccelerator
#
# yum 安裝
#
yum install eaccelerator
設定 eaccelerator.ini
#
# 編輯
#
vi /etc/php.d/eaccelerator.ini
#
; Enable eAccelerator extension module
zend_extension = /usr/lib/php/modules/eaccelerator.so
; Options for the eAccelerator module
eaccelerator.cache_dir = /var/cache/php-eaccelerator
eaccelerator.shm_size = 128
eaccelerator.enable = 1
eaccelerator.optimizer = 1
eaccelerator.check_mtime = 1
eaccelerator.filter = ""
eaccelerator.shm_max = 0
eaccelerator.shm_ttl = 3600
eaccelerator.shm_prune_period = 0
eaccelerator.shm_only = 0
eaccelerator.compress = 1
eaccelerator.compress_level = 9
eaccelerator.keys = "shm_and_disk"
eaccelerator.sessions = "shm_and_disk"
eaccelerator.content = "shm_and_disk"
eaccelerator.debug = 0
這樣大概ok了,然後測試看看:
# php -v
PHP 5.1.6 (cli) (built: Sep 20 2007 10:16:10)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
下面讲一下安装步骤,可以直接yum的,真方便
RHEL5 / CentOS-5
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
RHEL4 / CentOS-4
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.x86_64.rpm
RHEL3 / CentOS-3
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el3.rf.i386.rpm
x86_64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el3.rf.x86_64.rpm
RHEL2.1 / CentOS-2
i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el2.rf.i386.rpm
就是找你的版本,然後下載安裝:
#
# 安裝
#
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
安裝 lighttpd
#
# yum 安裝
#
yum install lighttpd
yum install lighttpd-fastcgi php-cli
然後編輯:/etc/php.ini 加上
cgi.fix_pathinfo = 1
; cgi.fix_pathinfo 为CGI提供 *真实* PATH_INFO/PATH_TRANSLATED 支持.
; PHP的预处理行为是设置 PATH_TRANSLATED 到 SCRIPT_FILENAME, 并且不去猜测 PATH_INFO 是什么.
; 想获取关于 PATH_INFO 更多的信息, 查看 cgi 规范.
; 将此值设置为1会引起PHP CGI修正它的路径来符合规范.
; 设置为0会引起PHP类似前面的行为. 默认是1. 你应该修正你的脚本来使用 SCRIPT_FILENAME 而不是 PATH_TRANSLATED.
; cgi.fix_pathinfo=0
这个我没改,用了面板默认的
然後修改 lighttpd.conf
#
# 修改
#
vi /etc/lighttpd/lighttpd.confserver.modules = (
"mod_rewrite",
"mod_redirect",
"mod_alias",
"mod_access",
"mod_fastcgi",
"mod_proxy",
"mod_evhost",
"mod_userdir",
"mod_accesslog" )
server.document-root = "/var/www/html/"
server.errorlog = "/var/log/lighttpd/error.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
)
)
$HTTP["host"] == "mini101.twgg.org" {
server.document-root = "/var/www/html/Mini/"
#url.rewrite = ( "^/(archives|categories|comments|feed)/" => "/index.php" )
url.rewrite = (
"^/?$" => "/index.php",
"^/(\?.*)$" => "/index.php$1",
"^/(wp-.+)$" => "$0",
"^/([^.]+)/?$" => "/index.php?$1",
)
accesslog.filename = "/var/log/lighttpd/mini101.twgg.org-access_log"
}
安裝:eaccelerator
#
# yum 安裝
#
yum install eaccelerator
設定 eaccelerator.ini
#
# 編輯
#
vi /etc/php.d/eaccelerator.ini
#
; Enable eAccelerator extension module
zend_extension = /usr/lib/php/modules/eaccelerator.so
; Options for the eAccelerator module
eaccelerator.cache_dir = /var/cache/php-eaccelerator
eaccelerator.shm_size = 128
eaccelerator.enable = 1
eaccelerator.optimizer = 1
eaccelerator.check_mtime = 1
eaccelerator.filter = ""
eaccelerator.shm_max = 0
eaccelerator.shm_ttl = 3600
eaccelerator.shm_prune_period = 0
eaccelerator.shm_only = 0
eaccelerator.compress = 1
eaccelerator.compress_level = 9
eaccelerator.keys = "shm_and_disk"
eaccelerator.sessions = "shm_and_disk"
eaccelerator.content = "shm_and_disk"
eaccelerator.debug = 0
這樣大概ok了,然後測試看看:
# php -v
PHP 5.1.6 (cli) (built: Sep 20 2007 10:16:10)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
mysql双机热备份遇到的问题
[
2009/10/15 15:58 | by suibing ]
2009/10/15 15:58 | by suibing ]
昨晚完成了论坛的数据库热备份,今天想再增加一台备份服务器,按照正常流程添加以后,不能正常备份,后来发现主要三台机器同步数据库后,需要删除所有的master和slave的日志然后启动服务就可以正常同步了
SSH登录缓慢解决方法
[
2009/09/24 09:51 | by suibing ]
2009/09/24 09:51 | by suibing ]
最近几天通过SSH登录局域网内的一台机器时,在输入用户名后,得等10多秒后才会有响应回来,很慢,
但PING的时候TTL时间很快,那机器负载也蛮小的。这个小问题存在了几天,一直没顾上解决,今天在网上查了些资料,终于知道的这个问题产生的原因。
原因之一是因为LINUX系统的一个文件/etc/nsswitch.conf ,在这里面有如下一行
hosts: files
dns
这行的含义是对于访问的主机进行域名解析的顺序,是先访问file,也就是/etc/hosts文件,如果hosts中没有记录域名,则访问dns,进行域名解析,如果dns也无法访问,就会等待访问超时后返回,因此等待时间比较长。
解决这个问题有以下几个方法:
1、在server上/etc/hosts文件中把你本机的ip和hostname加入,改后便可生效;
2、在server上/etc/ssh/sshd_config文件中修改或加入UseDNS=no
然后/etc/init.d/ssh restart使配置生效;
3、注释掉server上/etc/resolv.conf中所有行,改后便可生效;
4、修改server上/etc/nsswitch.conf中hosts为hosts: files
,改后便可生效;
#我访问慢的原因就是因为上边这个原因,通过上边几个方法都能解决掉。
另外一个原因可能是
authentication
gssapi-with-mic出现问题,在server上/etc/ssh/sshd_config文件中修改GSSAPIAuthentication
no.
/etc/init.d/sshd restart重启sshd进程使配置生效。
如果以上两招还不能解决问题,善于使用DEBUG MODE ssh
-v来查看log,找到停滞时间最长的步骤,然后针对性的修改配置解决。
但PING的时候TTL时间很快,那机器负载也蛮小的。这个小问题存在了几天,一直没顾上解决,今天在网上查了些资料,终于知道的这个问题产生的原因。
原因之一是因为LINUX系统的一个文件/etc/nsswitch.conf ,在这里面有如下一行
hosts: files
dns
这行的含义是对于访问的主机进行域名解析的顺序,是先访问file,也就是/etc/hosts文件,如果hosts中没有记录域名,则访问dns,进行域名解析,如果dns也无法访问,就会等待访问超时后返回,因此等待时间比较长。
解决这个问题有以下几个方法:
1、在server上/etc/hosts文件中把你本机的ip和hostname加入,改后便可生效;
2、在server上/etc/ssh/sshd_config文件中修改或加入UseDNS=no
然后/etc/init.d/ssh restart使配置生效;
3、注释掉server上/etc/resolv.conf中所有行,改后便可生效;
4、修改server上/etc/nsswitch.conf中hosts为hosts: files
,改后便可生效;
#我访问慢的原因就是因为上边这个原因,通过上边几个方法都能解决掉。
另外一个原因可能是
authentication
gssapi-with-mic出现问题,在server上/etc/ssh/sshd_config文件中修改GSSAPIAuthentication
no.
/etc/init.d/sshd restart重启sshd进程使配置生效。
如果以上两招还不能解决问题,善于使用DEBUG MODE ssh
-v来查看log,找到停滞时间最长的步骤,然后针对性的修改配置解决。





