Master: 10.17.17.78 slave: 10.17.17.79 VIP: 10.17.17.80

Install nginx1.19.7

  • 10.17.17.78/79 Do the same
/ root @ baojian - 79 ~ # wget HTTP: / / http://nginx.org/download/nginx-1.19.7.tar.gz/root @ baojian - 79 ~ # yum - y install GCC Pcr-devel zlib-devel openssl openssl-devel lua-devel python-devel -y [root@baojian-79 ~]# tar-xf nginx-1.19.7.tar.gz [root@baojian-79 ~]# CD nginx-1.19.7 ### #./configure --prefix=/data/nginx --with-pcre --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-ipv6 --with-http_realip_module --with-http_gzip_static_module --with-pcre-jit --with-ld-opt=-ljemalloc --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib - add - the module = / usr/local/SRC/nginx1.19.7 - - nginx - module - module/lua 0.10.13 - add - the module = / usr/local/SRC/nginx1.19.7 - the module/ngx_devel_kit - 0.3.0 - add - the module = / usr/local/SRC/nginx1.19.7 - the module/nginx - module - VTS - add - the module = / usr/local/SRC/nginx1.19.7 - the module/nginx_upstream_check_module # # # / root @ baojian - 79 ~ #. / configure --prefix=/data/nginx --with-pcre --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-ipv6 --with-http_realip_module --with-http_gzip_static_module --with-pcre-jit --with-ld-opt=-ljemalloc --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib [root@baojian-79 ~]# make -j 4 && make install

install keepalived

  • 10.17.17.78/79 Do the same
[root@baojian-78 ~]# yum install -y ipvsadm keepalived [root@baojian-78 ~]# cat /etc/keepalived/keepalived.conf ! Configuration File for keepalived global_defs { notification_email { } router_id LVS_DEVEL } vrrp_script chk_http_port {  script "/data/nginx/sbin/nginx_pid.sh" interval 1 weight 2 } vrrp_instance VI_1 { state MASTER interface ens192 #ip Virtual_router_id 28 priority 100 #slave node is smaller than master node. For example, 80 advert_int 1 authentication {auth_type PASS Auth_pass 1111} virtual_ipaddress {10.17.17.80} track_script {chk_http_port}}

[root@baojian-79 ~]# cat /data/nginx/sbin/nginx_pid.sh #! /bin/bash if [ `ps -C nginx --no-header |wc -l` -eq 0 ]; then killall keepalived fi

config nginx


[root@insurace-24 conf]# cat nginx.conf
user  root;
worker_processes     8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
worker_rlimit_nofile 65535;

error_log /data/nginx/logs/error.log error;
#pid        logs/nginx.pid;


events {
    use epoll;
    worker_connections  65535;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format main   '{"@timestamp":"$time_iso8601",'
                        '"@source":"$server_addr",'
                        '"hostname":"$hostname",'
                        '"ip":"$http_x_forwarded_for",'
                        '"client":"$remote_addr",'
                        '"request_method":"$request_method",'
                        '"scheme":"$scheme",'
                        '"domain":"$server_name",'
                        '"referer":"$http_referer",'
                        '"request":"$request_uri",'
                        '"args":"$args",'
                        '"size":$body_bytes_sent,'
                        '"status": $status,'
                        '"responsetime":$request_time,'
                        '"upstreamtime":"$upstream_response_time",'
                        '"upstreamaddr":"$upstream_addr",'
                        '"http_user_agent":"$http_user_agent",'
                        '"https":"$https"'
                        '}';

    access_log  logs/access.log  main;

    sendfile        on;
    client_max_body_size 256m;
    server_tokens off ;
    proxy_intercept_errors on;


    #keepalive_timeout  0;
    keepalive_timeout  30;
    
    gzip on;
    gzip_min_length  5k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 4;
    gzip_types  text/plain application/x-javascript application/javascript  text/css  application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";

    vhost_traffic_status_zone;
    vhost_traffic_status_filter_by_host on;
    include     conf.d/*.conf;


    fastcgi_intercept_errors on;
 
   server {
        listen       80;
        server_name 10.17.17.79;
        charset UTF-8;

   }
    server {
        listen       80;
        server_name   10.17.17.80;
        charset UTF-8;

    }
}