{"id":329,"date":"2021-07-28T14:47:54","date_gmt":"2021-07-28T06:47:54","guid":{"rendered":"http:\/\/egonlin.com\/?p=329"},"modified":"2024-04-01T22:18:52","modified_gmt":"2024-04-01T14:18:52","slug":"%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%92%8c%e4%bc%9a%e8%af%9d%e4%bf%9d%e6%8c%81","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=329","title":{"rendered":"\u8d1f\u8f7d\u5747\u8861\u548c\u4f1a\u8bdd\u4fdd\u6301"},"content":{"rendered":"<h2>\u4e00\u3001\u8d1f\u8f7d\u5747\u8861<\/h2>\n<h2><\/h2>\n<pre><code class=\"language-bash\">Nginx\u8981\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u9700\u8981\u7528\u5230proxy_pass\u4ee3\u7406\u6a21\u5757\u914d\u7f6e\n\nNginx\u8d1f\u8f7d\u5747\u8861\u4e0eNginx\u4ee3\u7406\u4e0d\u540c\u5730\u65b9\u5728\u4e8e\uff0cNginx\u7684\u4e00\u4e2alocation\u4ec5\u80fd\u4ee3\u7406\u4e00\u53f0\u670d\u52a1\u5668\uff0c\u800cNginx\u8d1f\u8f7d\u5747\u8861\u5219\u662f\u5c06\u5ba2\u6237\u7aef\u8bf7\u6c42\u4ee3\u7406\u8f6c\u53d1\u81f3\u4e00\u7ec4upstream\u865a\u62df\u670d\u52a1\u6c60.<\/code><\/pre>\n<h3>1.\u8d1f\u8f7d\u5747\u8861\u6a21\u5757<\/h3>\n<pre><code class=\"language-bash\"># ngx_http_upstream_module\n\n#\u8bed\u6cd5\nSyntax: upstream name { ... }\nDefault:    \u2014\nContext:    http\n\n#\u4f8b\u5b50\nupstream backend {\n    server backend1.example.com       weight=5;\n    server backend2.example.com:8080;\n    server backup1.example.com:8080   backup;\n    server backup2.example.com:8080   backup;\n}\n\nserver {\n    ... ...\n    location \/ {\n        proxy_pass http:\/\/backend;\n    }\n}<\/code><\/pre>\n<h3>2.\u73af\u5883\u51c6\u5907<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u4e3b\u673a<\/th>\n<th>IP<\/th>\n<th>\u8eab\u4efd<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>lb01<\/td>\n<td>10.0.0.4,172.16.1.4<\/td>\n<td>\u8d1f\u8f7d\u5747\u8861<\/td>\n<\/tr>\n<tr>\n<td>web01<\/td>\n<td>172.16.1.7<\/td>\n<td>web\u670d\u52a1\u7aef<\/td>\n<\/tr>\n<tr>\n<td>web02<\/td>\n<td>172.16.1.8<\/td>\n<td>web\u670d\u52a1\u7aef<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3.web01\u51c6\u5907\u7ad9\u70b9<\/h3>\n<h4>1\uff09\u914d\u7f6enginx<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# vim \/etc\/nginx\/conf.d\/linux.lb.com.conf\nserver {\n    listen 80;\n    server_name linux.lb.com;\n    charset utf8;\n\n    location \/ {\n        root \/code\/lb;\n        index index.html;\n    }\n}<\/code><\/pre>\n<h4>2\uff09\u51c6\u5907\u7f51\u7ad9<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# mkdir \/code\/lb\n[root@web01 ~]# echo &quot;\u6211\u662fweb0111111111111&quot; &gt; \/code\/lb\/index.html\n[root@web01 ~]# chown -R www.www \/code\/<\/code><\/pre>\n<h4>3\uff09\u914d\u7f6ehosts\u8bbf\u95ee<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# systemctl restart nginx\n\n10.0.0.7 linux.lb.com\n\n\u8bbf\u95ee<\/code><\/pre>\n<h3>3.web01\u51c6\u5907\u7ad9\u70b9<\/h3>\n<h4>1\uff09\u914d\u7f6enginx<\/h4>\n<pre><code class=\"language-bash\">[root@web02 ~]# vim \/etc\/nginx\/conf.d\/linux.lb.com.conf\nserver {\n    listen 80;\n    server_name linux.lb.com;\n    charset utf8;\n\n    location \/ {\n        root \/code\/lb;\n        index index.html;\n    }\n}<\/code><\/pre>\n<h4>2\uff09\u51c6\u5907\u7f51\u7ad9<\/h4>\n<pre><code class=\"language-bash\">[root@web02 ~]# mkdir \/code\/lb\n[root@web02 ~]# echo &quot;\u6211\u662fweb0222222222222&quot; &gt; \/code\/lb\/index.html\n[root@web02 ~]# chown -R www.www \/code\/<\/code><\/pre>\n<h4>3\uff09\u914d\u7f6ehosts\u8bbf\u95ee<\/h4>\n<pre><code class=\"language-bash\">[root@web02 ~]# systemctl restart nginx\n\n10.0.0.8 linux.lb.com\n\n\u8bbf\u95ee<\/code><\/pre>\n<h3>4.\u914d\u7f6e\u8d1f\u8f7d\u5747\u8861\u914d\u7f6e\u6587\u4ef6<\/h3>\n<pre><code class=\"language-bash\">[root@lb01 ~]# vim \/etc\/nginx\/conf.d\/linux.lb.com.conf\nupstream web_group {\n    server 172.16.1.7:80;\n    server 172.16.1.8;\n}\n\nserver {\n    listen 80;\n    server_name linux.lb.com;\n\n    location \/ {\n        proxy_pass http:\/\/web_group;\n        include proxy_params;\n    }\n}<\/code><\/pre>\n<h3>5.\u51c6\u5907\u4ee3\u7406\u4f18\u5316\u6587\u4ef6<\/h3>\n<pre><code class=\"language-bash\">[root@lb01 ~]# vim \/etc\/nginx\/proxy_params \n\nproxy_set_header Host $http_host;\nproxy_set_header X-Real-IP $remote_addr;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\nproxy_connect_timeout 10s;\nproxy_read_timeout 10s;\nproxy_send_timeout 10s;\nproxy_buffering on;\nproxy_buffer_size 8k;\nproxy_buffers 8 8k;<\/code><\/pre>\n<h3>6.\u91cd\u542f\u8bbf\u95ee\u6d4b\u8bd5<\/h3>\n<pre><code class=\"language-bash\">1.\u91cd\u542f\n[root@lb01 ~]# nginx -t\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful\n[root@lb01 ~]# systemctl restart nginx\n\n2.\u914d\u7f6ehosts\n10.0.0.4 linux.lb.com<\/code><\/pre>\n<h2>\u4e8c\u3001\u8d1f\u8f7d\u5747\u8861\u7ed3\u5408\u9879\u76ee<\/h2>\n<h3>1.\u914d\u7f6ewordpress\u8d1f\u8f7d\u5747\u8861<\/h3>\n<pre><code class=\"language-bash\">[root@lb01 ~]# vim \/etc\/nginx\/conf.d\/linux.wp.com.conf\nupstream blog {\n    server 172.16.1.7;\n    server 172.16.1.8;\n}\n\nserver {\n    listen 80;\n    server_name linux.wp.com;\n\n    location \/ {\n        proxy_pass http:\/\/blog;\n        include proxy_params;\n    }   \n}\n\n#\u91cd\u542f\n[root@lb01 ~]# systemctl restart nginx<\/code><\/pre>\n<h3>2.\u914d\u7f6ehosts\u67e5\u770b\u7f51\u7ad9<\/h3>\n<pre><code class=\"language-bash\">10.0.0.4 linux.wp.com<\/code><\/pre>\n<h3>3.\u914d\u7f6ezh\u7684\u8d1f\u8f7d\u5747\u8861<\/h3>\n<pre><code class=\"language-bash\">[root@lb01 ~]# vim \/etc\/nginx\/conf.d\/linux.zh.com.conf\nupstream zh {\n    server 172.16.1.7;\n    server 172.16.1.8;\n}\n\nserver {\n    listen 80;\n    server_name linux.zh.com;\n\n    location \/ {\n        proxy_pass http:\/\/zh;\n        include proxy_params;\n    }\n}<\/code><\/pre>\n<h3>4.\u8d1f\u8f7d\u5747\u8861\u5e38\u89c1\u95ee\u9898<\/h3>\n<h4>1\uff09\u95ee\u9898<\/h4>\n<pre><code class=\"language-bash\">\u5982\u679c\u540e\u7aef\u670d\u52a1\u5668\u51fa\u73b0\u95ee\u9898\uff0c\u8d1f\u8f7d\u5747\u8861\u4ecd\u7136\u4f1a\u5c06\u8bf7\u6c42\u53d1\u9001\u7ed9\u76f8\u5e94\u673a\u5668\n\n\u5982\u679c\u540e\u53f0\u670d\u52a1\u8fde\u63a5\u8d85\u65f6\uff0cNginx\u662f\u672c\u8eab\u662f\u6709\u673a\u5236\u7684\uff0c\u5982\u679c\u51fa\u73b0\u4e00\u4e2a\u8282\u70b9down\u6389\u7684\u65f6\u5019\uff0cNginx\u4f1a\u66f4\u636e\u4f60\u5177\u4f53\u8d1f\u8f7d\u5747\u8861\u7684\u8bbe\u7f6e\uff0c\u5c06\u8bf7\u6c42\u8f6c\u79fb\u5230\u5176\u4ed6\u7684\u8282\u70b9\u4e0a\uff0c\u4f46\u662f\uff0c\u5982\u679c\u540e\u53f0\u670d\u52a1\u8fde\u63a5\u6ca1\u6709down\u6389\uff0c\u4f46\u662f\u8fd4\u56de\u9519\u8bef\u5f02\u5e38\u7801\u4e86\u5982:504\u3001502\u3001500,\u8fd9\u4e2a\u65f6\u5019\u4f60\u9700\u8981\u52a0\u4e00\u4e2a\u8d1f\u8f7d\u5747\u8861\u7684\u8bbe\u7f6e\uff0c\u5982\u4e0b\uff1aproxy_next_upstream http_500 | http_502 | http_503 | http_504 |http_404;\u610f\u601d\u662f\uff0c\u5f53\u5176\u4e2d\u4e00\u53f0\u8fd4\u56de\u9519\u8bef\u7801404,500...\u7b49\u9519\u8bef\u65f6\uff0c\u53ef\u4ee5\u5206\u914d\u5230\u4e0b\u4e00\u53f0\u670d\u52a1\u5668\u7a0b\u5e8f\u7ee7\u7eed\u5904\u7406\uff0c\u63d0\u9ad8\u5e73\u53f0\u8bbf\u95ee\u6210\u529f\u7387\u3002<\/code><\/pre>\n<h4>2\uff09\u89e3\u51b3\u95ee\u9898\u7684\u6a21\u5757<\/h4>\n<pre><code class=\"language-bash\">Syntax: proxy_next_upstream error | timeout | invalid_header | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | http_429 | non_idempotent | off ...;\nDefault:    proxy_next_upstream error timeout;\nContext:    http, server, location<\/code><\/pre>\n<h4>3\uff09\u914d\u7f6e<\/h4>\n<pre><code class=\"language-bash\">[root@lb01 ~]# vim \/etc\/nginx\/conf.d\/linux.wp.com.conf\nupstream blog {\n    server 172.16.1.7;\n    server 172.16.1.8;\n}\n\nserver {\n    listen 80;\n    server_name linux.wp.com;\n\n    location \/ {\n        proxy_pass http:\/\/blog;\n        include proxy_params;\n        #\u53ef\u4ee5\u914d\u7f6e\uff0c\u53ef\u4ee5\u5199\u5230include\n        proxy_next_upstream http_500 | http_502 | http_503 | http_504 | http_403 | http_404;\n    }\n}\n\n#\u91cd\u542f\n[root@lb01 ~]# systemctl restart nginx<\/code><\/pre>\n<h2>\u4e09\u3001\u8d1f\u8f7d\u5747\u8861\u8c03\u5ea6\u7b97\u6cd5<\/h2>\n<table>\n<thead>\n<tr>\n<th><strong>\u8c03\u5ea6\u7b97\u6cd5<\/strong><\/th>\n<th><strong>\u6982\u8ff0<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u8f6e\u8be2<\/td>\n<td>\u6309\u65f6\u95f4\u987a\u5e8f\u9010\u4e00\u5206\u914d\u5230\u4e0d\u540c\u7684\u540e\u7aef\u670d\u52a1\u5668(\u9ed8\u8ba4)<\/td>\n<\/tr>\n<tr>\n<td>weight<\/td>\n<td>\u52a0\u6743\u8f6e\u8be2,weight\u503c\u8d8a\u5927,\u5206\u914d\u5230\u7684\u8bbf\u95ee\u51e0\u7387\u8d8a\u9ad8<\/td>\n<\/tr>\n<tr>\n<td>ip_hash<\/td>\n<td>\u6bcf\u4e2a\u8bf7\u6c42\u6309\u8bbf\u95eeIP\u7684hash\u7ed3\u679c\u5206\u914d,\u8fd9\u6837\u6765\u81ea\u540c\u4e00IP\u7684\u56fa\u5b9a\u8bbf\u95ee\u4e00\u4e2a\u540e\u7aef\u670d\u52a1\u5668<\/td>\n<\/tr>\n<tr>\n<td>url_hash<\/td>\n<td>\u6309\u7167\u8bbf\u95eeURL\u7684hash\u7ed3\u679c\u6765\u5206\u914d\u8bf7\u6c42,\u662f\u6bcf\u4e2aURL\u5b9a\u5411\u5230\u540c\u4e00\u4e2a\u540e\u7aef\u670d\u52a1\u5668<\/td>\n<\/tr>\n<tr>\n<td>least_conn<\/td>\n<td>\u6700\u5c11\u94fe\u63a5\u6570,\u54ea\u4e2a\u673a\u5668\u94fe\u63a5\u6570\u5c11\u5c31\u5206\u53d1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>1.\u8f6e\u8be2\u7684\u914d\u7f6e\u65b9\u6cd5<\/h3>\n<pre><code class=\"language-bash\">upstream blog {\n    server 172.16.1.7;\n    server 172.16.1.8;\n}<\/code><\/pre>\n<h3>2.\u52a0\u6743\u8f6e\u8be2\u914d\u7f6e<\/h3>\n<pre><code class=\"language-bash\">upstream blog {\n    server 172.16.1.7 weight=1;\n    server 172.16.1.8 weight=2;\n}<\/code><\/pre>\n<h3>3.ip_bash\u914d\u7f6e\u65b9\u6cd5<\/h3>\n<pre><code class=\"language-bash\">upstream web_group {\n    server 172.16.1.7:80;\n    server 172.16.1.8;\n    ip_hash;\n}\n\n#\u4e00\u822c\u7528\u6765\u505a\u4f1a\u8bdd\u4fdd\u6301<\/code><\/pre>\n<h2>\u56db\u3001\u8d1f\u8f7d\u5747\u8861\u540e\u7aef\u72b6\u6001<\/h2>\n<table>\n<thead>\n<tr>\n<th><strong>\u72b6\u6001<\/strong><\/th>\n<th><strong>\u6982\u8ff0<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>down<\/td>\n<td>\u5f53\u524d\u7684server\u6682\u65f6\u4e0d\u53c2\u4e0e\u8d1f\u8f7d\u5747\u8861<\/td>\n<\/tr>\n<tr>\n<td>backup<\/td>\n<td>\u9884\u7559\u7684\u5907\u4efd\u670d\u52a1\u5668<\/td>\n<\/tr>\n<tr>\n<td>max_fails<\/td>\n<td>\u5141\u8bb8\u8bf7\u6c42\u5931\u8d25\u7684\u6b21\u6570<\/td>\n<\/tr>\n<tr>\n<td>fail_timeout<\/td>\n<td>\u7ecf\u8fc7max_fails\u5931\u8d25\u540e, \u670d\u52a1\u6682\u505c\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td>max_conns<\/td>\n<td>\u9650\u5236\u6700\u5927\u7684\u63a5\u6536\u8fde\u63a5\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>1.down\u72b6\u6001\u914d\u7f6e<\/h3>\n<pre><code class=\"language-bash\">upstream blog {\n    #\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7ef4\u62a4\u573a\u666f\u4f7f\u7528\n    server 172.16.1.7 down;\n    server 172.16.1.8;\n}<\/code><\/pre>\n<h3>2.backup\u72b6\u6001\u914d\u7f6e<\/h3>\n<pre><code class=\"language-bash\">upstream web_group {\n    server 172.16.1.7;\n    server 172.16.1.8 backup;\n}<\/code><\/pre>\n<h3>3.\u8bbf\u95ee\u9519\u8bef\u72b6\u6001\u914d\u7f6e<\/h3>\n<pre><code class=\"language-bash\">upstream web_group {\n    server 172.16.1.7;\n    server 172.16.1.8 max_fails=3 fail_timeout=10s;\n}<\/code><\/pre>\n<h3>4.\u6700\u5927\u8fde\u63a5\u6570\u914d\u7f6e<\/h3>\n<pre><code class=\"language-bash\">upstream web_group {\n    server 172.16.1.7;\n    server 172.16.1.8 max_conns=100;\n}<\/code><\/pre>\n<h2>\u4e94\u3001Nginx\u8d1f\u8f7d\u5747\u8861\u5065\u5eb7\u68c0\u67e5\uff08\u6269\u5c55\uff09<\/h2>\n<pre><code class=\"language-bash\">\u5728Nginx\u5b98\u65b9\u6a21\u5757\u63d0\u4f9b\u7684\u6a21\u5757\u4e2d\uff0c\u6ca1\u6709\u5bf9\u8d1f\u8f7d\u5747\u8861\u540e\u7aef\u8282\u70b9\u7684\u5065\u5eb7\u68c0\u67e5\u6a21\u5757\uff0c\u4f46\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u6a21\u5757\u3002\nnginx_upstream_check_module\u6765\u68c0\u6d4b\u540e\u7aef\u670d\u52a1\u7684\u5065\u5eb7\u72b6\u6001\u3002<\/code><\/pre>\n<h3>1.\u5b89\u88c5\u4f9d\u8d56<\/h3>\n<pre><code class=\"language-bash\">[root@lb02 ~]# yum install -y gcc glibc gcc-c++ pcre-devel openssl-devel patch<\/code><\/pre>\n<h3>2.\u4e0b\u8f7d\u7b2c\u4e09\u65b9\u6a21\u5757<\/h3>\n<pre><code class=\"language-bash\">[root@lb02 ~]# wget http:\/\/nginx.org\/download\/nginx-1.14.2.tar.gz\n[root@lb02 ~]# wget https:\/\/github.com\/yaoweibin\/nginx_upstream_check_module\/archive\/master.zip<\/code><\/pre>\n<h3>3.\u89e3\u538b\u53ca\u5b89\u88c5<\/h3>\n<pre><code class=\"language-bash\">[root@lb02 ~]# tar xf nginx-1.14.2.tar.gz\n[root@lb02 ~]# unzip master.zip<\/code><\/pre>\n<h3>4.\u8fdb\u5165nginx\u76ee\u5f55\uff0c\u6253\u8865\u4e01(nginx\u7684\u7248\u672c\u662f1.14\u8865\u4e01\u5c31\u9009\u62e91.14\u7684,p1\u4ee3\u8868\u5728nginx\u76ee\u5f55\uff0cp0\u662f\u4e0d\u5728nginx\u76ee\u5f55)<\/h3>\n<pre><code class=\"language-bash\">[root@lb02 ~]# cd nginx-1.14.2\/\n\n[root@lb02 nginx-1.14.2]# patch -p1 &lt;..\/nginx_upstream_check_module-master\/check_1.14.0+.patch\n\n[root@lb02 nginx-1.14.2]# .\/configure --prefix=\/etc\/nginx --sbin-path=\/usr\/sbin\/nginx --modules-path=\/usr\/lib64\/nginx\/modules --conf-path=\/etc\/nginx\/nginx.conf --error-log-path=\/var\/log\/nginx\/error.log --http-log-path=\/var\/log\/nginx\/access.log --pid-path=\/var\/run\/nginx.pid --lock-path=\/var\/run\/nginx.lock --http-client-body-temp-path=\/var\/cache\/nginx\/client_temp --http-proxy-temp-path=\/var\/cache\/nginx\/proxy_temp --http-fastcgi-temp-path=\/var\/cache\/nginx\/fastcgi_temp --http-uwsgi-temp-path=\/var\/cache\/nginx\/uwsgi_temp --http-scgi-temp-path=\/var\/cache\/nginx\/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=\/root\/nginx_upstream_check_module-master --with-cc-opt=&#039;-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC&#039; --with-ld-opt=&#039;-Wl,-z,relro -Wl,-z,now -pie&#039;\n\n[root@lb02 nginx-1.14.2]# make &amp;&amp; make install<\/code><\/pre>\n<h3>5.\u5728\u5df2\u6709\u7684\u8d1f\u8f7d\u5747\u8861\u4e0a\u589e\u52a0\u5065\u5eb7\u68c0\u67e5\u7684\u529f\u80fd<\/h3>\n<pre><code class=\"language-bash\">[root@lb01 conf.d]# cat proxy_web.conf\nupstream web {\n    server 172.16.1.7:80 max_fails=2 fail_timeout=10s;\n    server 172.16.1.8:80 max_fails=2 fail_timeout=10s;\n    check interval=3000 rise=2 fall=3 timeout=1000 type=tcp;\n    #interval  \u68c0\u6d4b\u95f4\u9694\u65f6\u95f4\uff0c\u5355\u4f4d\u4e3a\u6beb\u79d2\n    #rise      \u8868\u793a\u8bf7\u6c422\u6b21\u6b63\u5e38\uff0c\u6807\u8bb0\u6b64\u540e\u7aef\u7684\u72b6\u6001\u4e3aup\n    #fall      \u8868\u793a\u8bf7\u6c423\u6b21\u5931\u8d25\uff0c\u6807\u8bb0\u6b64\u540e\u7aef\u7684\u72b6\u6001\u4e3adown\n    #type      \u7c7b\u578b\u4e3atcp\n    #timeout   \u8d85\u65f6\u65f6\u95f4\uff0c\u5355\u4f4d\u4e3a\u6beb\u79d2\n}\n\nserver {\n    listen 80;\n    server_name linux.lb.com;\n    location \/ {\n        proxy_pass http:\/\/web;\n        include proxy_params;\n    }\n\n    location \/upstream_check {\n        check_status;\n    }\n}<\/code><\/pre>\n<h3>6.\u91cd\u542f\u8bbf\u95ee\u9875\u9762<\/h3>\n<pre><code class=\"language-bash\">#\u91cd\u542f\n#\u914d\u7f6ehosts\n#\u8bbf\u95ee\nhttp:\/\/linux.lb.com\/upstream_check<\/code><\/pre>\n<h2>\u516d\u3001Nginx\u8d1f\u8f7d\u5747\u8861\u4f1a\u8bdd\u4fdd\u6301<\/h2>\n<h3>1.\u4ec0\u4e48\u662f\u4f1a\u8bdd\u4fdd\u6301<\/h3>\n<pre><code class=\"language-bash\">\u6211\u4eec\u5728\u8bbf\u95ee\u7f51\u7ad9\u7684\u65f6\u5019\uff0c\u8fdb\u884c\u767b\u9646\u4ee5\u540e\uff0c\u670d\u52a1\u5668\u4e0a\u56de\u751f\u6210\u4e00\u4e2asession\uff0c\u7136\u540e\u670d\u52a1\u5668\u4f1a\u643a\u5e26\u7740session_id\u8fd4\u56de\u7ed9\u6d4f\u89c8\u5668\u8bb0\u5f55\u4e00\u4e2acookie\u503c\uff0c\u5f53\u7b2c\u4e8c\u6b21\u8bbf\u95ee\u65f6\uff0ccookie\u4f1a\u6765\u670d\u52a1\u5668\u4e0a\u4e0esession\u8fdb\u884c\u5bf9\u6bd4\uff0c\u5982\u679c\u5bf9\u6bd4\u6210\u529f\uff0c\u5219\u4e0d\u9700\u8981\u91cd\u65b0\u767b\u5f55\n\n\u5728\u4f7f\u7528\u8d1f\u8f7d\u5747\u8861\u7684\u65f6\u5019\u4f1a\u9047\u5230\u4f1a\u8bdd\u4fdd\u6301\u7684\u95ee\u9898\uff0c\u53ef\u901a\u8fc7\u5982\u4e0b\u65b9\u5f0f\u8fdb\u884c\u89e3\u51b3\u3002\n1.\u4f7f\u7528nginx\u7684ip_hash\uff0c\u6839\u636e\u5ba2\u6237\u7aef\u7684IP\uff0c\u5c06\u8bf7\u6c42\u5206\u914d\u5230\u5bf9\u5e94\u7684IP\u4e0a\n2.\u57fa\u4e8e\u670d\u52a1\u7aef\u7684session\u4f1a\u8bdd\u5171\u4eab\uff08NFS\uff0cMySQL\uff0cmemcache\uff0credis\uff0cfile\uff09<\/code><\/pre>\n<h3>2.session\u5171\u4eab\u7684\u65b9\u6cd5<\/h3>\n<pre><code class=\"language-bash\">1.\u628a\u591a\u53f0\u540e\u7aef\u670d\u52a1\u5668session\u6587\u4ef6\u76ee\u5f55\u6302\u8f7d\u5230NFS\u540c\u4e00\u76ee\u5f55\n2.\u901a\u8fc7\u7a0b\u5e8f\u5c06session\u5b58\u50a8\u5230mysql\u6570\u636e\u5e93\n3.\u901a\u8fc7\u7a0b\u5e8f\u5c06session\u5b58\u50a8\u5230redis\u7f13\u5b58<\/code><\/pre>\n<h3>3.web01\u4e0a\u642d\u5efaphpmyadmin<\/h3>\n<h4>1\uff09\u4e0a\u4f20\u5305<\/h4>\n<pre><code class=\"language-bash\">[root@web01 ~]# cd \/code\/\n[root@web01 code]# rz                                                                               \n[root@web01 code]# ll\n-rw-r--r--. 1 root root 11060845 Oct 18 10:48 phpMyAdmin-4.9.0.1-all-languages.zip<\/code><\/pre>\n<h4>2\uff09\u89e3\u538b<\/h4>\n<pre><code class=\"language-bash\">\u5e76\u6539\u540d[root@web01 code]# unzip phpMyAdmin-4.9.0.1-all-languages.zip\n[root@web01 code]# mv phpMyAdmin-4.9.0.1-all-languages php<\/code><\/pre>\n<h4>3\uff09\u4fee\u6539\u8fde\u63a5\u6570\u636e\u5e93\u4ee3\u7801<\/h4>\n<pre><code class=\"language-bash\">[root@web01 code]# cp \/code\/php\/{config.sample.inc.php,config.inc.php}\n[root@web01 code]# vim \/code\/php\/config.inc.php\n$cfg[&#039;Servers&#039;][$i][&#039;host&#039;] = &#039;172.16.1.51&#039;;<\/code><\/pre>\n<h4>4\uff09\u6388\u6743\u7ad9\u70b9\u76ee\u5f55<\/h4>\n<pre><code class=\"language-bash\">[root@web01 code]# chown -R www.www \/code\/<\/code><\/pre>\n<h4>5\uff09\u914d\u7f6enginx<\/h4>\n<div id=\"rml_readmorelogin_placeholder\" style=\"position:relative;\"><div id=\"rml_fade_content\" style=\"position: absolute;\r\ntop:-10em;\r\nwidth:100%;\r\nheight:10em;\r\nbackground: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\"><\/div><div class=\"wpf-controller aru_rml_from_in_post\" style=\"background-color:#eeeeee;border:5px solid #cce6ff;\" id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><h2 id=\"Header\">\u67e5\u770b\u66f4\u591a<\/h2><div id=\"Message\"><p>\u8054\u7cfb\u7ba1\u7406\u5458\u5fae\u4fe1tutu19192010\uff0c\u6ce8\u518c\u8d26\u53f7<\/p>\n<\/div><div id=\"StatusBarHeader\"><\/div><form id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><input name=\"post_id\" value=\"329\" type=\"hidden\"\/><input name=\"_init_callback\" value=\"InitLogin\" type=\"hidden\"\/><input name=\"post_id\" value=\"329\" type=\"hidden\"\/><input name=\"rt_ype\" value=\"1\" type=\"hidden\"\/><input name=\"nonce\" value=\"4145893969\" type=\"hidden\"\/><input name=\"_wpnonce\" value=\"d4e099963b\" type=\"hidden\"\/><input name=\"_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_proxy_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_view\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginView\" type=\"hidden\"\/><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\" width=\"400px\"><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Username:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"username\" value=\"\" type=\"text\"\/><\/td><\/tr><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Password:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"password\" value=\"\" type=\"password\"\/><\/td><\/tr><\/tbody><\/table><p class=\"wpf-table-placeholder submit\"><button class=\"wp_plugin_framework_ajax_button\" type=\"button\" style=\"background-color:#4D90FE;;color:#ffffff;;border:1px solid #3079ed;\" name=\"_event\" value=\"ButtonLogin\">Log in<\/button><\/p><\/td><td class=\"wpf-table-placeholder-input\"><\/td><\/tr><\/tbody><\/table><\/form><div id=\"ButtonStartRegister\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=register\">Register<\/a><\/div><div id=\"Link1\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=lostpassword\">Forgotten username or password?<\/a><\/div><div id=\"StatusBarFooter\"><\/div><\/div><\/div><div id=aru_remaining_content><\/div>","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u8d1f\u8f7d\u5747\u8861 Nginx\u8981\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u9700\u8981\u7528\u5230proxy_pass\u4ee3\u7406\u6a21\u5757\u914d\u7f6e Nginx\u8d1f\u8f7d\u5747\u8861\u4e0eNginx [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":253,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/329"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329"}],"version-history":[{"count":1,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":9615,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions\/9615"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/media\/253"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}