您好,登錄后才能下訂單哦!
系統(tǒng)版本 | nginx版本 | keepalived版本 | ip | 作用 |
---|---|---|---|---|
CentOS Linux release 7.5.1804 (Core) | nginx/1.16.1 | keepalived-2.0.18 | 10.1.1.31 | master |
CentOS Linux release 7.5.1804 (Core) | nginx/1.16.1 | keepalived-2.0.18 | 10.1.1.32 | slave |
VIP 10.1.1.111
安裝nignx
yum install nginx -y
修改nginx配置文件
master
echo 'this is master 31' > /usr/share/nginx/html/index.html
slave
echo 'this is slave 32' > /usr/share/nginx/html/index.html
啟動nginx
systemctl start nginx
測試nginx啟動
curl localhost
this is master
yum -y install openssl-devel gcc gcc-c++
mkdir /etc/keepalived
wget https://www.keepalived.org/software/keepalived-2.0.18.tar.gz
tar -zxvf keepalived-2.0.18.tar.gz
mv keepalived-2.0.18 /usr/local/keepalived
cd /usr/local/keepalived
./configure && make && make install
cp? -a /usr/local/etc/keepalived ? /etc/init.d/
cp? -a /usr/local/etc/sysconfig/keepalived? ? /etc/sysconfig/
cp? -a /usr/local/sbin/keepalived? ? /usr/sbin/
master
cat > /etc/keepalived/keepalived.conf << EOF
! Configuration File for keepalived
global_defs {
router_id 31
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 3
mcast_src_ip 10.1.1.132
priority 200
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
10.1.1.111/24
}
}
EOF
slave
cat > /etc/keepalived/keepalived.conf << EOF
! Configuration File for keepalived
global_defs {
router_id 32
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 3
mcast_src_ip 10.1.1.132
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
10.1.1.111/24
}
}
EOF
systemctl start keepalived
systemctl enable keepalived
master
$ curl localhost
this is master
root@centos7[14:46:07]:~
$ curl 10.1.1.111
this is master
root@centos7[15:03:29]:~
slave
$ curl localhost
this is slave
root@centos7[15:03:59]:/etc/keepalived
$ curl 10.1.1.111
this is master
master關(guān)閉keepalived
$ systemctl stop keepalived
$ curl localhost
this is slave
root@centos7[15:10:29]:/etc/keepalived
$ curl 10.1.1.111
this is slave
到此keepalived完成
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。