Keepalived安装和配置

安装依赖:

yum -y install popt-devel

yum -y install openssl openssl-devel

下载:

wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz

解压:

tar zxvf keepalived-1.2.7.tar.gz

cd keepalived-1.2.7

./configure

make

make install

拷贝文件:

cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/

cp /usr/local/etc/sysconfig/keepalived /etc/sysconfig/

mkdir /etc/keepalived

cp /usr/local/etc/keepalived/keepalived.conf /etc/keepalived/

cp /usr/local/sbin/keepalived /usr/sbin/

加入启动服务:

echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local

echo "/etc/init.d/keepalived start" >> /etc/rc.local

查看rc.local文件:

有,则启动nginx:

/usr/local/nginx/sbin/nginx 

启动keepalived:

/etc/init.d/keepalived start

修改配置文件:

vi /etc/keepalived/keepalived.conf

找到:rooter_id **** 修改为:

rooter_id NGINX_UPSTREAM

修改网卡:

interface etho(CentOS6)--》interface ens33

修改虚拟ip:

virtual_ipaddress{
    192.168.140.100
}

删除从服务器

退出后在主从服务器上启动keepalived:

/etc/init.d/keepalived start  or(service keepalived start)

在主服务器上查看是否已经绑定了虚拟ip:

ip addr

*****补充内容*******

vim中删除多行:

删除光标之前:dgg

删除光标之后:dG

删除行第一个:dg0


你可能感兴趣的:(Keepalived安装和配置)