关闭vm1,vm4两边的keepalived服务,把vm1的运行内存调为2048,关闭其他三台虚拟机
下载kernel-2.6.32-220.23.1.el6.src.rpm Lvs-fullnat-synproxy.tar.gz
[root@server1 ~]# rpm -ivh kernel-2.6.32-220.23.1.el6.src.rpm
[root@server1 ~]# cd rpmbuild/SPECS/
[root@server1 SPECS]# yum install rpm-build -y
[root@server1 SPECS]# rpmbuild -bp kernel.spec
error: Failed build dependencies:
redhat-rpm-config is needed by kernel-2.6.32-220.23.1.el6.x86_64
patchutils is needed by kernel-2.6.32-220.23.1.el6.x86_64
xmlto is needed by kernel-2.6.32-220.23.1.el6.x86_64
asciidoc is needed by kernel-2.6.32-220.23.1.el6.x86_64
elfutils-libelf-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64
binutils-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64
newt-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64
python-devel is needed by kernel-2.6.32-220.23.1.el6.x86_64
perl(ExtUtils::Embed) is needed by kernel-2.6.32-220.23.1.el6.x86_64
hmaccalc is needed by kernel-2.6.32-220.23.1.el6.x86_64
[root@server1 SPECS]# yum install redhat-rpm-config patchutils xmlto asciidoc elfutils-libelf-devel binutils-devel newt-devel python-devel perl-ExtUtils-Embed hmaccalc -y
会出现
No package asciidoc available.
No package newt-devel available.
下载这两个包,这两个包的安装还需要另一个依赖性包,在进行下载
[root@server1 ~]# yum install newt-devel-0.52.11-3.el6.x86_64.rpm asciidoc-8.4.5-4.1.el6.noarch.rpm slang-devel-2.2.1-1.el6.x86_64.rpm -y
[root@server1 SPECS]# rpmbuild -bp kernel.spec这条命令需要在执行
rngd -r /dev/urandom,不然会卡到那块
在远程连接server1
yum provides */rngd
yum install rng-tools-2-13.e16_2.x86_64 -y
rngd -r /dev/urandom
tar zxf Lvs-fullnat-synproxy.tar.gz
cd lvs-fullnat-synproxy/
cp lvs-2.6.32-220.23.1.el6.patch ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/
patch -p1< lvs-2.6.32-220.23.1.el6.patch
cd ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/
vim Makefile
EXTRAVERSION = -220.23.1.e16
make
make modules_install
make install
官方网站http://kb.linuxvirtualserver.org/wiki/IPVS_FULLNAT_and_SYNPROXY
cd /boot/grub
vim grub.conf
default=0
执行reboot
cd lvs-fullnat-synproxy/
tar zxf lvs-tools.tar.gz
cd tools
cd keepalived/
yum install -y popt-devel没有这个服务,./configure会报错
./configure –with-kernel-dir=”/lib/modules/uname -r
/build”
make && make install
[root@server1 tools]# cd ipvsadm/
[root@server1 ipvsadm]# yum remove ipvsadm -y
[root@server1 ipvsadm]# make && make install
成功后,ipvsadm –help会有十种算法出现
[root@server1 ipvsadm]# ipvsadm -l
IP Virtual Server version 1.2.1 (size=4194304)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.25.22.100:http rr
-> localhost:http Local 1 0 0
更改内核
vim /boot/grub/grub.conf
default = 1
reboot重启
下载tar zxf nginx-1.22.0.tar.gz
tar zxf nginx-1.12.0.tar.gz
vim /nginx-1.12.0/auto/cc/gcc 注释掉debug下面那行
cd nginx-1.12.0
yum install pcre-devel -y
./configure –prefix=/usr/local/nginx
make && make install
vim /usr/local/nginx/conf/nginx.conf
http {
upstream westos {
server 172.25.22.2:80;
server 172.25.22.3:80;
}
server {
listen 80;
server_name www.westos.org;
location / {
proxy_pass http://westos;
}
}
}
vm1和vm4
vim /etc/keepalived/keepalived.conf
vrrp_script nginx_check {
scripts /opt/nginx_check.sh
interval 2
}
virtual_ipaddress {
172.25.22.100/24
}
track_script{
nginx_check
}
}
/etc/init.d/keepalived start
scp -r /usr/local/nginx server4:/usr/local
vim /opt/nginx_check.sh
#!/bin/bash
curl http://127.0.0.1/index.html -o /dev/null -s || /usr/local/nginx/sbin/nginx
if [ $? -ne 0 ];then
/etc/init.d/keepalived stop &> /dev/null
fi
执行killall -9 nginx,通过ps ax 进行查看