Nginx之Keepalived高可用东西

1、建设两台虚拟机,别离为主机和从机,区别两台虚拟机的IP地点 2、 将keepalived上传到linux系统傍边   

Nginx之Keepalived高可用对象

3、 cd /usr/local目次 

  

Nginx之Keepalived高可用对象

4、 tar -zxvf keepalived-1.2.18.tar.gz

  

5、 cd keepalived-1.2.18目次

  

6、 yum install -y openssl openssl-devel (需要安装一个软件包)

  

7、 ./configure --prefix=/usr/local/keepalived 编译,将编译文件放到/usr/local/keepalived

  

8、 make

  

9、 make install

  

10、 在/etc/keepalived 建设目次: mkdir /etc/keepalived    11、 cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/

  

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

  

13、 cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/

  

14、 ln -s /usr/local/sbin/keepalived /usr/sbin/

  

  (ln -s /usr/local/keepalived/sbin/keepalived /sbin/) 15、 将nginx启动剧本和keepalived.conf设置上传到/etc/keepalived

  

Nginx之Keepalived高可用对象

  

Nginx之Keepalived高可用对象

16、 主机:修改keepalived.conf设置文件  vim /etc/keepalived/keepalived.conf

  interface 设置成与主机沟通的网络 ip a
  mcast_src_ip 设置本钱身呆板的IP
  virtual_ipaddress {
    192.168.33.135 # 虚拟ip,也就是办理写死措施的ip怎么能切换的ip,也可扩展,用途遍及。可设置多个。
  }

  

Nginx之Keepalived高可用对象

 

17、 启动keepalived   启动呼吁service keepalived start

  假如报错:Job for keepalived.service failed because the control process exited with error code. See "systemctl status keepalived.service" and "journalctl -xe" for details.

  

18、办理步伐:rm /usr/sbin/keepalived

  

19、ln -s /usr/local/keepalived/sbin/keepalived /usr/sbin/

  

 20、再次启动

  

  

Nginx之Keepalived高可用对象

21、可以配置开机启动:chkconfig keepalived on   22、自动重启不了,办理步伐

  查察剧本是否有运行的权限,假如你是 root 登岸的话(不是的话,切换到 root 用户,对*.sh 赋可执行的权限)

  赋予权限呼吁:chmod 777 *.sh

  赋予所有权限:chmod +x *.sh

  然后运行就 OK 了,即有权限对文件举办删除等操纵。

23、备机安装步调同上,备机修改设置文件步调如下 24、备机:修改keepalived.conf设置文件  vim /etc/keepalived/keepalived.conf

   state BACKUP 备机名称
  interface 设置成与主机沟通的网络 ip a
  mcast_src_ip 设置本钱身呆板的IP
  priority 90  权重设置 
  virtual_ipaddress {
    192.168.33.135  # 虚拟ip,也就是办理写死措施的ip怎么能切换的ip,也可扩展,用途遍及。可设置多个。
  }

  

Nginx之Keepalived高可用对象

25、从机启动步调同上

  

Nginx之Keepalived高可用对象

26、结果展示  会见虚拟IP地点192.168.33.135

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsdjwg.html