nginx load + keepalived alta disponibilidad
- 1. Prepare el medio ambiente
- 2. Instale y configure dos páginas de prueba web
- 3. Instalación y configuración nginx + keepalived
-
-
- 1. Instale nginx desde el código fuente (dos 136 137)
- 2. Configurar el equilibrio de carga de nginx
- 3. Inicie nginx y pruebe el equilibrio de carga
- 4. Instale y configure el maestro keepalived (136)
- 5. Inicie keepalived y compruebe si se genera el VIP
- 6. Instale y configure keepalived desde (137)
- 7. Pruebe para ver si el VIP se desvía de
-
- 4. Prueba VIP en la Web
1. Prepare el medio ambiente
1. Prepare 4 máquinas virtuales (la mía es la versión centos7.5)
Dos como páginas de prueba web, dos como carga + alta disponibilidad
2. Apague el firewall setenforce
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
2. Instale y configure dos páginas de prueba web
1. Instale apache primero
[root@localhost ~]# yum -y install httpd
2. Edite la página de prueba html para distinguir fácilmente
[root@localhost ~]# vim /var/www/html/index.html
web1
[root@localhost ~]# vim /var/www/html/index.html
web2
3. Inicie y vea la página de prueba
[root@localhost ~]# systemctl start httpd
3. Instalación y configuración nginx + keepalived
1. Instale nginx desde el código fuente (dos 136 137)
先安装依赖
[root@localhost ~]# yum -y install gcc gcc-c++ pcre-devel zlib-devel
下载nginx源码包 http://nginx.org/ nginx官方网址
[root@localhost ~]# tar xzf nginx-1.12.2.tar.gz
[root@localhost ~]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# ./configure && make && make install
2. Configurar el equilibrio de carga de nginx
[root@localhost nginx-1.12.2]# vim /usr/local/nginx/conf/nginx.conf
3. Inicie nginx y pruebe el equilibrio de carga
[root@localhost nginx-1.12.2]# /usr/local/nginx/sbin/nginx
4. Instale y configure el maestro keepalived (136)
[root@localhost ~]# yum -y install keepalived
[root@localhost ~]# vim /etc/keepalived/keepalived.conf
5. Inicie keepalived y compruebe si se genera el VIP
[root@localhost ~]# systemctl start keepalived
6. Instale y configure keepalived desde (137)
[root@localhost ~]# yum -y install keepalived
[root@localhost ~]# vim /etc/keepalived/keepalived.conf
7. Pruebe para ver si el VIP se desvía de
先把从上的keepalived 启动
[root@localhost nginx-1.12.2]# systemctl start keepalived
在主上把keepalived 关掉
[root@localhost ~]# systemctl stop keepalived