Nginx.代理MySQL


Nginx.代理MySQL 

  1. Nginx在安裝的時候,需要加上一個參數:--with-stream 

    即Nginx安裝指令為:./configure --prefix=/u01/app/nginx  --with-stream

    Nginx的安裝教程,可參見:https://www.cnblogs.com/Charles-Yuan/articles/9737617.html

 

  2. nginx安裝完成后,編輯nginx.conf文件,指令:

    vim  /u01/app/nginx/conf/nginx.conf

    在文件的最下方(位置也可以不是最下方,stream必須和http平級)添加如下內容:

    stream {

      upstream cloudsocket {
        hash $remote_addr consistent;
        server 數據庫實際IP:數據庫實際端口號 weight=5 max_fails=3 fail_timeout=30s;
      }
      server {
        listen 數據庫代理端口號;
        proxy_connect_timeout 10s;
        proxy_timeout 300s;
        proxy_pass cloudsocket;
      }
    }

 

  3. 重啟nginx服務器.

 

如有問題,歡迎糾正!!!

如有轉載,請標明源處:https://www.cnblogs.com/Charles-Yuan/p/9738023.html 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM