1.1.预装wordpress
注:后端存储需要数据库的支持,所以先安装MySql
# tar –zxvf mysql-5.5.15-linux2.6-i686.tar.gz –C /usr/local/
方便打开mysql目录,给解压目录建立软连接
# cd /usr/local
# ln -s mysql-5.5.15-linux2.6-i686 mysql
安装可以参考/usr/local/INSTALL-BINARY文件
78 shell> groupadd mysql
79 shell> useradd -r -g mysql mysql
80 shell> cd /usr/local
81 shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
82 shell> ln -s full-path-to-mysql-VERSION-OS mysql
83 shell> cd mysql
84 shell> chown -R mysql .
85 shell> chgrp -R mysql .
86 shell> scripts/mysql_install_db --user=mysql
87 shell> chown -R root .
88 shell> chown -R mysql data
89 # Next command is optional
90 shell> cp support-files/my-medium.cnf /etc/my.cnf
91 shell> bin/mysqld_safe --user=mysql &
92 # Next command is optional
93 shell> cp support-files/mysql.server /etc/init.d/mysql.server
# groupadd -r mysql
# useradd -r -g mysql mysql –M
# chown -R mysql .
# chogrp -R mysql .
# scripts/mysql_install_db --user=mysql
# chown -R root .
# chgrp -R mysql data
# cp support-files/my-medium.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/init.d/mysqld
更改mysqld的权限
# chmod a+x /etc/init.d/mysqld
# chkconfig –add mysqld
配置mysql的环境变量
# vim /etc/profile
44 PATH=$PATH:/usr/local/mysql/bin
# . /etc/profile(.后面加空格)
创建mysql.conf文件并添加库文件路径
# vim /etc/ld.so.conf.d/mysql.conf
(添加下面内容)
/usr/local/mysql/lib
# ldconfig
为头文件建立连接
# cd /usr/local/mysql
# ln -s include /usr/include/mysql
给root用户密码
# mysqladmin -u root -p password '123456'
# service mysqld restart
注:其实就是将wordpress的站点文件展开就是了,真正的配置可以在前端的web服务器上完成
# unzip wordpress-3.0.5-zh_CN.zip
# cdwordpress-3.0.5-zh_CN
# mv wordpress /usr/local/nginx/html/website
创建mybbs数据库
# mysql–u root –p
Enter password:
mysql>create database mybbs;
mysql>grant all on mybbs to ‘root’@’192.168.110.10’identified by ‘123456’;
mysql>grant all on mybbs to ‘root’@’192.168.110.12’identified by ‘123456’;
mysql>grant all on mybbs to ‘root’@’192.168.110.13’identified by ‘123456’;
mysql>flush privileges;
在/usr/local/nginx/html/website下创建一个隐藏的.test.html用于director对服务器的监控时反馈信息
# cd/usr/local/nginx/html/website
# echo ‘ok’ .test.html
动态网站搭建完成
1.2.服务器端配置
确保服务器端已经安装以下有关nfs的软件包
# rpm -qa grep nfs
nfs-utils-lib-1.0.8-7.6.el5
nfs-utils-1.0.9-42.el5
查看rpc工作状态
# rpcinfo -p
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 653 status
100024 1 tcp 656 status
100011 1 udp 663 rquotad
100011 2 udp 663 rquotad
100011 1 tcp 666 rquotad
100011 2 tcp 666 rquotad
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
100021 1 udp 38515 nlockmgr
100021 3 udp 38515 nlockmgr
100021 4 udp 38515 nlockmgr
100003 2 tcp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 tcp 2049 nfs
100021 1 tcp 34341 nlockmgr
100021 3 tcp 34341 nlockmgr
100021 4 tcp 34341 nlockmgr
100005 1 udp 677 mountd
100005 1 tcp 680 mountd
100005 2 udp 677 mountd
100005 2 tcp 680 mountd
100005 3 udp 677 mountd
100005 3 tcp 680 mountd
把/usr/local/nginx/html/website并修改权限
# chmod o+wt /usr/local/nginx/html/website
编辑共享清单信息
# vim /etc/exports
/usr/local/nginx/html/website 192.168.110.0/28(rw,sync)(给192.168.110.0/28网段的用户对/usr/local/nginx/html/website有读写权限)
# exportfs –r (刷新共享清单)
2.1.web服务器1配置
2.1.1.LAMP环境的搭建
搭建前准备工作
下载一下安装包:
httpd-2.4.4
apr-1.4.6
apr-util-1.5.1
pcre采用光盘镜像的rpm安装包
mysql-5.6.10
php-5.4.13
phpMyAdmin-3.5.8-all-languages
ZendOptimizer-3.3.0a-linux-glibc21-i386
确保搭建的平台有以下开发组件
Development Libraries
Development Tools
Legacy Software Development
X Software Development
安装apache
源码安装httpd:
安装使用httpd我们必须先安装apr和它的工具apr-util
解压apr和apr-util并进入解压后的目录进行编译安装
#tar –zxvf apr-1.4.6.tar.gz –C /usr/local/src/
#tar –zxvf apr-util-1.5.1.tar.gz –C /usr/local/src/
# cd/usr/local/src/ apr-1.4.6
# ./configure –prefix=/usr/local/apr
# make&& make install
# cd /usr/local/src/ apr-util-1.5.1
# ./configure --with-apr=/usr/local/apr/bin/apr-1-config
# make&& make install
yum安装pcre和pcre-devel
# yum install pcre
# yum install pcre-devel
解压httpd并编译安装
# tar –jxvf httpd.2.4.4.tar.bz2 –C /usr/local/src/
# cd/usr/local/src/ httpd.2.4.4
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre --with-z --enable-mpms-shared=all
# make&& make install
为头文件目录建一个链接,方便用户能够访问到include文件
# ln -s /usr/local/apache/include /usr/include/apache
方便启动关闭重启apache服务建立httpd控制脚本
# vim /etc/init.d/httpd
#!/bin/sh
#set -x
#description:http server
#chkconfig:2345 88 60
HTTPD='/usr/local/apache/bin/httpd'
CONFFILE='/etc/httpd/httpd.conf'
start(){
[ -f /var/lock/subsys/httpd ] && echo "apache is started" && exit
echo -n "starting apache......."
sleep 1
$HTTPD -f $CONFFILE && RETVAL=0 RETVAL=1
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd && echo "ok" echo "fail"
}
stop(){
[ ! -f /var/lock/subsys/httpd ]&& echo "httpd is stoped......" && exit
echo -n "stoping httpd......"
sleep 1
/bin/rm -rf /var/lock/subsys/httpd
$HTTPD -k stop && RETVAL=0 RETVAL=1
[ $RETVAL -eq 0 ] && rm -rf /var/lock/subsys/httpd && echo "ok" echo "fail"
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "start stop restart"
;;
Esac
# service httpd start
starting apache.......ok
安装mysql
# tar -zxvf mysql-5.6.10.tar.gz -C /usr/local/src/
安装mysql需要cmake,Cmake它相当于./configure
安装cmake
# tar -zxvf cmake-2.8.10.2.tar.gz -C /usr/local/src/
# cd/usr/local/src/ cmake-2.8.10.2
# ./configure --prefix=/usr/local/cmake
执行make && make install
Cmake的可执行文件在/usr/local/cmake/bin目录下为了方便使用cmake,更改/etc/profile文件内容,添加一条PATH值,能直接使用cmke
# vim /etc/profile
45 PATH=$PATH:/usr/local/cmake/bin
安装mysql
# cd/usr/local/src/ mysql-5.6.10
# cmake .
# make&& make install
Mysql默认安装到/usr/local/下,增加mysql组创建用户并更改mysql目录下的所属者和所属组
# cd /usr/local/mysql
# groupadd mysql
# useradd -r -g mysql mysql
# chown -R mysql .
# chgrp -R mysql .
初始化mysql
# cd /usr/local/mysql
# scripts/mysql_install_db --user=mysql
进行权限更改
# chown -R root .
# chown -R mysql data
拷贝/mysql/ support-files目录下配置文件到/etc/my.cnf作为新的配置文件
# cd /usr/local/mysql/ support-files
# cp my-default.cnf /etc/my.cnf
拷贝mysql.server文件到/etc/init.d/mysqld作为新的控制文件,并给它执行权
# cp mysql.server /etc/init.d/mysqld
# chmod a+x /etc/init.d/mysqld
为直接使用mysql命令添加mysql环境变量
# vim /etc/profile
45 PATH=$PATH:/usr/local/cmake/bin:/usr/local/mysql/bin
给数据库创建用户和密码
# mysqladmin -u root -p password 123456
登录
# mysql -u root –p
Enter password:
使系统能够正确找到lib文件,我们需要给它指定正确的lib路径,创建一个mysql.conf在里面写入lib的路径/usr/local/mysql/bin,并对ld.so.cache文件刷新
# vim /etc/ld.so.conf.d/mysql.conf
加入下面内容
/usr/local/mysql/bin
# ldconfig(刷新)
再给头文件做一个链接
# ln -s /usr/local/mysql/include /usr/include/mysql
安装php
# tar -jxvf php-5.4.13.tar.bz2 -C /usr/local/src/
# cd /usr/local/src/ php-5.4.13
# ./configure --prefix=/usr/local/php --sysconfdir=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-zlib --with-gd --with-jpeg-dir --with-png-dir --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --disable-xml --with-freetype-dir --enable-xml
# Make && make install
添加php的环境路径:
# vim /etc/profile
指定php的lib文件路径
# vim /etc/ld.so.conf.d/php.conf
加入以下内容
/usr/local/php/lib
# ldconfig(更新)
为头文件建立链接
# cd /usr/local/php
# ln -s include /usr/include/php
为了让apache能够处理一些php网页,我们要加入一些模块,向httpd.conf文件内加入语句
# vim /etc/httpd/httpd.conf
147 LoadModule php5_module modules/libphp5.so
148 AddType application/x-httpd-php .php .phtml
246 <IfModule dir_module>
247 DirectoryIndex index.html index.php
248 </IfModule>
更改web主站点路径到挂载目录,并创建虚拟主机头
213 DocumentRoot "/var/www/website"
514 <Virtualhost 192.168.110.12:80>
515 DocumentRoot /var/www/website
516 ServerName www.zzdx.com
517 ErrorLog logs/tec_error_log
518 CustomLog logs/tec_access_log combined
519 </VirtualHost>
# service httpd restart
stoping httpd......ok
starting apache.......ok
2.1.2.Zend加速php
# tar -zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
# cd ZendOptimizer-3.3.0a-linux-glibc21-i386
# ./install
安装过程(如图2-1-2-1至图2-1-2-7)
图2-1-2-1
图2-1-2-2
图2-1-2-3
指定zend的安装路径
图2-1-2-4
指定zend配置文件安装路径
图2-1-2-5
图2-1-2-6
指定apachectl的路径
图2-1-2-7
2.1.3.安装snmp软件包及相关组件
使监测服务器能够正常监控web服务器
# cd /mnt/cdrom/Server/
# rpm -ivh net-snmp-5.3.2.2-7.el5.i386.rpm
# yum install net-snmp-utils-5.3.2.2-7.el5.i386.rpm
2.1.4添加虚拟端口并更改系统控制文件
添加虚拟端口并配置路由,web服务器回应客户端时使用虚拟端口
# ifconfig lo:0 192.168.110.1 broadcast 192.168.110.1 netmask 255.255.255.255
# route add -host 192.168.110.1 dev lo:0
更改系统控制文件,在接收arp请求时不给予回应以防冲突
# vim /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
2.1.5.挂载NFS资源到本地
# vim /etc/fstab
加入下面代码
192.168.110.10:/usr/local/nginx/html/website /var/www/website nfs rw,soft,intr 0 0
2.1.6.安装wordpress
在NFS服务器上只是将wordpress的站点文件展开了,真正的配置在web站点上,配置过程如图2-1-6-1至图2-1-6-6所示:
图2-1-6-1
图2-1-6-2
图2-1-6-3
图2-1-6-4
图2-1-6-5
图2-1-6-6
2.2web服务器2配置
2.2.1.LAMP环境的搭建
搭建前准备工作
下载一下安装包:
httpd-2.4.4
apr-1.4.6
apr-util-1.5.1
pcre采用光盘镜像的rpm安装包
mysql-5.6.10
php-5.4.13
phpMyAdmin-3.5.8-all-languages
ZendOptimizer-3.3.0a-linux-glibc21-i386
确保搭建的平台有以下开发组件
Development Libraries
Development Tools
Legacy Software Development
X Software Development
安装apache
源码安装httpd:
安装使用httpd我们必须先安装apr和它的工具apr-util
解压apr和apr-util并进入解压后的目录进行编译安装
#tar –zxvf apr-1.4.6.tar.gz –C /usr/local/src/
#tar –zxvf apr-util-1.5.1.tar.gz –C /usr/local/src/
# cd/usr/local/src/ apr-1.4.6
# ./configure –prefix=/usr/local/apr
# make&& make install
# cd /usr/local/src/ apr-util-1.5.1
# ./configure --with-apr=/usr/local/apr/bin/apr-1-config
# make&& make install
yum安装pcre和pcre-devel
# yum install pcre
# yum install pcre-devel
解压httpd并编译安装
# tar –jxvf httpd.2.4.4.tar.bz2 –C /usr/local/src/
# cd/usr/local/src/ httpd.2.4.4
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre --with-z --enable-mpms-shared=all
# make&& make install
为头文件目录建一个链接,方便用户能够访问到include文件
# ln -s /usr/local/apache/include /usr/include/apache
方便启动关闭重启apache服务建立httpd控制脚本
# vim /etc/init.d/httpd
#!/bin/sh
#set -x
#description:http server
#chkconfig:2345 88 60
HTTPD='/usr/local/apache/bin/httpd'
CONFFILE='/etc/httpd/httpd.conf'
start(){
[ -f /var/lock/subsys/httpd ] && echo "apache is started" && exit
echo -n "starting apache......."
sleep 1
$HTTPD -f $CONFFILE && RETVAL=0 RETVAL=1
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd && echo "ok" echo "fail"
}
stop(){
[ ! -f /var/lock/subsys/httpd ]&& echo "httpd is stoped......" && exit
echo -n "stoping httpd......"
sleep 1
/bin/rm -rf /var/lock/subsys/httpd
$HTTPD -k stop && RETVAL=0 RETVAL=1
[ $RETVAL -eq 0 ] && rm -rf /var/lock/subsys/httpd && echo "ok" echo "fail"
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "start stop restart"
;;
Esac
# service httpd start
starting apache.......ok
安装mysql
# tar -zxvf mysql-5.6.10.tar.gz -C /usr/local/src/
安装mysql需要cmake,Cmake它相当于./configure
安装cmake
# tar -zxvf cmake-2.8.10.2.tar.gz -C /usr/local/src/
# cd/usr/local/src/ cmake-2.8.10.2
# ./configure --prefix=/usr/local/cmake
执行make && make install
Cmake的可执行文件在/usr/local/cmake/bin目录下为了方便使用cmake,更改/etc/profile文件内容,添加一条PATH值,能直接使用cmke
# vim /etc/profile
45 PATH=$PATH:/usr/local/cmake/bin
安装mysql
# cd/usr/local/src/ mysql-5.6.10
# cmake .
# make&& make install
Mysql默认安装到/usr/local/下,增加mysql组创建用户并更改mysql目录下的所属者和所属组
# cd /usr/local/mysql
# groupadd mysql
# useradd -r -g mysql mysql
# chown -R mysql .
# chgrp -R mysql .
初始化mysql
# cd /usr/local/mysql
# scripts/mysql_install_db --user=mysql
进行权限更改
# chown -R root .
# chown -R mysql data
拷贝/mysql/ support-files目录下配置文件到/etc/my.cnf作为新的配置文件
# cd /usr/local/mysql/ support-files
# cp my-default.cnf /etc/my.cnf
拷贝mysql.server文件到/etc/init.d/mysqld作为新的控制文件,并给它执行权
# cp mysql.server /etc/init.d/mysqld
# chmod a+x /etc/init.d/mysqld
为直接使用mysql命令添加mysql环境变量
# vim /etc/profile
45 PATH=$PATH:/usr/local/cmake/bin:/usr/local/mysql/bin
给数据库创建用户和密码
# mysqladmin -u root -p password 123456
登录
# mysql -u root –p
Enter password:
使系统能够正确找到lib文件,我们需要给它指定正确的lib路径,创建一个mysql.conf在里面写入lib的路径/usr/local/mysql/bin,并对ld.so.cache文件刷新
# vim /etc/ld.so.conf.d/mysql.conf
加入下面内容
/usr/local/mysql/bin
# ldconfig(刷新)
再给头文件做一个链接
# ln -s /usr/local/mysql/include /usr/include/mysql
安装php
# tar -jxvf php-5.4.13.tar.bz2 -C /usr/local/src/
# cd /usr/local/src/ php-5.4.13
# ./configure --prefix=/usr/local/php --sysconfdir=/etc --with-apxs2=/usr/local/apache/bin/apxs --with-zlib --with-gd --with-jpeg-dir --with-png-dir --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --disable-xml --with-freetype-dir --enable-xml
# Make && make install
添加php的环境路径:
# vim /etc/profile
指定php的lib文件路径
# vim /etc/ld.so.conf.d/php.conf
加入以下内容
/usr/local/php/lib
# ldconfig(更新)
为头文件建立链接
# cd /usr/local/php
# ln -s include /usr/include/php
为了让apache能够处理一些php网页,我们要加入一些模块,向httpd.conf文件内加入语句
# vim /etc/httpd/httpd.conf
147 LoadModule php5_module modules/libphp5.so
148 AddType application/x-httpd-php .php .phtml
246 <IfModule dir_module>
247 DirectoryIndex index.html index.php
248 </IfModule>
更改web主站点路径到挂载目录,并创建虚拟主机头
213 DocumentRoot "/var/www/website"
514 <Virtualhost 192.168.110.13:80>
515 DocumentRoot /var/www/website
516 ServerName www.zzdx.com
517 ErrorLog logs/tec_error_log
518 CustomLog logs/tec_access_log combined
519 </VirtualHost>
# service httpd restart
stoping httpd......ok
starting apache.......ok
2.2.2.Zend加速php
# tar -zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
# cd ZendOptimizer-3.3.0a-linux-glibc21-i386
# ./install
安装过程如图2-2-2-1至图2-2-2-7
图2-2-2-1
图2-2-2-2
图2-2-2-3
指定zend的安装路径
图2-2-2-4
指定zend配置文件安装路径
图2-2-2-5
图2-2-2-6
指定apachectl的路径
图2-2-2-7
2.2.3.安装snmp软件包及相关组件
使监测服务器能够正常监控web服务器
# cd /mnt/cdrom/Server/
# rpm -ivh net-snmp-5.3.2.2-7.el5.i386.rpm
# yum install net-snmp-utils-5.3.2.2-7.el5.i386.rpm
2.2.4.添加虚拟端口并更改系统控制文件
添加虚拟端口并配置路由,web服务器回应客户端时使用虚拟端口
# ifconfig lo:0 192.168.110.1 broadcast 192.168.110.1 netmask 255.255.255.255
# route add -host 192.168.110.1 dev lo:0
更改系统控制文件,在接收arp请求时不给予回应以防冲突
# vim /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
2.2.5.挂载NFS资源到本地
# vim /etc/fstab
加入下面代码
192.168.110.10:/usr/local/nginx/html/website /var/www/website nfs rw,soft,intr 0 0
3.1.准备工作
heartbeat-2.1.4-11.el5.i386.rpm
openhpi-libs-2.14.0-5.el5.i386.rpm
heartbeat-pils-2.1.4-11.el5.i386.rpm
perl-MailTools-2.04-1.el5.rf.noarch.rpm
heartbeat-stonith-2.1.4-11.el5.i386.rpm
perl-TimeDate-1.16-5.el5.noarch.rpm
libnet-1.1.5-1.el5.i386.rpm
heartbeat-ldirectord-2.1.4-11.el5.i386.rpm
3.2.软件安装
所有上述软件都放在/heartbeat目录下
# cd heart/
# yum localinstall ./* --nogpgcheck
这样安装省了很多事,系统会自动解决依赖关系,但是读者还要记着安装完成之后查询一下heartbeat到底产生了哪些文件
其中/usr/share/doc/heartbeat-2.1.4/目录下就存放了heartbeat的样例配置文件
3.3.修改相关配置文件
3.3.1.主服务器配置
接下来的工作是修改主机名,Heartbeat依靠服务器的主机名来识别服务器,因此使用hostname命令得到的结果必须与uname -n 结果保持一致。
# vim /etc/sysconfig/network //修改主机名称;
HOSTNAME=primary.zzdx.com
# hostname primary.zzdx.com
# vim /etc/hosts //修改主机地址映射;
192.168.110.6 primary.zzdx.com primary
192.168.110.7 standby.zzdx.com standby
# cd /etc/ha.d/
# cp /usr/share/doc/heartbeat-2.1.4/ha.cf ./
# cp /usr/share/doc/heartbeat-2.1.4/authkeys ./
# cp /usr/share/doc/heartbeat-2.1.4/haresources ./
# cp /usr/share/doc/heartbeat-2.1.4/heartbeat-ldirectord-2.1.4/ldirectord.cf ./ldirectord-192.168.110.1.cf //ldirectord的配置文件
# vim ha.cf //定义各节点之间Heartbeat进程如何通信;
debugfile /var/log/ha-debug //设置调试日志文件名
logfile /var/log/ha-log //设置其他日志文件名
keepalive 2 //设定heartbeat之间的时间间隔为2秒;
deadtime 30 //在30秒后宣布节点死亡;
warntime 10 //在日志中发出late heartbeat警告之前等待的时间,单位为秒;
udpport 694 // 使用端口694进行bcast和ucast通信,默认参数;
bcast eth1 //在eth1接口上使用广播heartbeat-”心跳”;
node primary.zzdx.com //定义节点;
node standby.zzdx.com //定义节点;
# dd if=/dev/urandom bs=512 count=1 openssl md5 //生成节点间域共享密钥;
14df2a6b5b26b510e7d5d5b16b7cc10b
# vim authkeys //定义心跳探测包使用哪种加密方式;
auth 1
1 sha1 14df2a6b5b26b510e7d5d5b16b7cc10b
# chmod 600 authkeys //仅允许管理员修改文件;
# vim haresources //定义资源;文件给出了相应的格式
primary.zzdx.com IPaddr::192.168.110.1/28/eth0/192.168.110.15 ldirectord::ldirectord-192.168.110.1.cf
# vim ldirectord-192.168.110.1.cf //定义director规则
# Global Directives
checktimeout=10 // ldirectord 等待Realserver 健康检查完成的时间,单位为秒;任何原因的检查错误或超过此时间限制,ldirector 将会将此Realserver 从IPVS 表中移除;
checkinterval=2 // 每次检查的时间间隔,即检查的频率;
autoreload=no //定义ldirectord 是否定期每隔一段时间检查此配置文件是否发生改变并自动重新加载此文件;
logfile="/var/log/ldirectord-192.168.110.1.log" //日志文件存放位置;
quiescent=yes //当某台Real Server 出现异常,此项可将其设置为静默状态(即其权重为0)从而不再响应客户端的访问请求;
virtual=192.168.110.1:80 // 定义LVS 服务及其使用的VIP 和PORT;
real=192.168.110.12:80 gate 1 // 定义Real Server;
real=192.168.110.13:80 gate 3 //定义Real Server;
fallback=127.0.0.1:80 gate // 当IPVS 表没有任何可用的Realserver 时,
此“地址:端口”作为最后响应的服务。一般指向127.0.0.1,并可以通过一个包含错误信息的页面通知用户服务发生了异常;
service=http // 基于http 服务来测试Real Server;
request=".test.html" //测试请求页面;
receive="OK" //测试接收字符;
scheduler=wlc //定义调度算法;
3.3.2.standby 服务器的配置
从服务器的主机名称为standby.zzdx.com,安装heartbeat的方法同主服务器一致。/etc/hosts文件、Heartbeat、ldirectord的配置文件也必须与主机保持一致。因此这里采用将primary上的配置文件直接远程复制过来的方法:
# cd /etc/ha.d/
# scp 192.168.110.6:/etc/ha.d/ha.cf ./
# scp 192.168.110.6:/etc/ha.d/authkeys ./
# scp 192.168.110.6:/etc/ha.d/haresources ./
# scp 192.168.110.6:/etc/ha.d/ldirectord-192.168.110.1.cf ./
# chmod 600 authkeys
3.3.3.在primary和standby服务器上分别启动heartbeat服务
# service heartbeat start
测试部分小编就不做啦,发现自己最近一阶段非常的懒啊,呵呵,整个一个架构下来相信读者对于群集技术已经有所了解啦,如果还想知道更多,那就需要自己动手好好去摸索一下啦….