mr923 发表于 2018-11-16 06:41:57

Keepaliev+Nginx+http-tianrandai

配置Sorry-Server  
    # mkdir -p /app/apache/html/
  
    # chown -R apache.apache /app/apache/html/
  
    # echo "Sorry Server 1" > /app/apache/html/index.html
  
    # vim /etc/httpd/conf/httpd.conf
  
       #此处是更改httpd.conf中的内容,并非添加内容
  
       Listen 8080
  
       DocumentRoot "/app/apache/html"
  
       #更改为自定义的路径
  

  
       #
  
       # Relax access to content within /var/www.
  
       #
  
         #更改为自定义的路径
  
       AllowOverride None
  
       # Allow open access:
  
       Require all granted
  
      
  

  
       # Further relax access to the default document root:
  
            #更改为自定义的路径.
  
    # systemctl restart http
  
               #测试网站是否正常运行
  
      # curl http://172.18.17.31:8080
  
            Sorry Server 1#测试成功
  
      配置Keepalived
  
         # cp /etc/keepalived/keepalived.conf{,.bak}    #备份文件
  
         # vim /etc/keepalived/keepalived.conf
  
            global_defs {
  
               notification_email {
  
                  root   #定义收邮件的用户
  
               }
  
               notification_email_from Alexandre.Cassen@firewall.loc
  
               smtp_server 172.18.17.31   #定义邮件地址
  
               smtp_connect_timeout 30
  
               router_id node1            #定义节点名称
  
            }
  

  
            vrrp_instance VI_1 {
  
                state MASTER            #定义节点为主节点模式
  
                interface ens33         #定义使用ens33为VIP网卡
  
                virtual_router_id 51      #定义节点编号
  
                priority 150            #定义优先级
  
                advert_int 1
  
                authentication {
  
                  auth_type PASS
  
                  auth_pass 1111
  
                }
  
                virtual_ipaddress {
  
                  172.18.17.30          #定义VIP
  
                }
  
            }
  
~      配置Nginx服务
  
            # vim /etc/nginx/nginx.conf
  
                #添加nginx集群
  
                upstream websrvs {
  
                  server 172.18.17.33:80;
  
                  server 172.18.17.34:80;
  
                  server 127.0.0.1:8080 backup;
  
                }
  
                #server 部分的内容需要全部注释掉
  

  
            # vim /etc/nginx/conf.d/default.conf
  
                  server {
  
                  listen       80;
  
                  location / {
  
                        roothtml;
  
                        proxy_pass http://websrvs;
  
                        indexindex.html index.htm;
  
                  }
  
                }
  
            # systemctl restart nginx
  
            # systemctl restart keepalived
  
            # systemctl restart httpd


页: [1]
查看完整版本: Keepaliev+Nginx+http-tianrandai