nginx tcp負(fù)載均衡的具體實(shí)現(xiàn)
mysql負(fù)載均衡
安裝mysql
yum install -y mariadb-server systemctl start mariadb systemctl enable mariadb ss -ntl

創(chuàng)建數(shù)據(jù)庫并授權(quán)
MariaDB [(none)]> create database wordpress; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all privileges on wordpress .* to "wordpress"@"192.168.33.%" identified by "123456"; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec)
配置nginx
vim /apps/nginx/conf/nginx.conf
}
stream {
upstream mysql_server {
server 192.168.33.171:3306 max_fails=3 fail_timeout=30s;
}
server {
listen 192.168.33.180:3306;
proxy_connect_timeout 30s;
proxy_timeout 300s;
proxy_pass mysql_server;
}
}
寫入時(shí)閉合http


訪問

redis負(fù)載均衡
安裝redis
wget https://download.redis.io/releases/redis-6.0.6.tar.gz tar -zxvf redis-6.0.6.tar.gz cd redis-6.0.6 make cd src/ redis-server ss -ntl

修改文件
vim /root/redis-4.0.14/redis.conf 修改為bind 0.0.0.0
配置nginx
stream {
upstream mysql_server {
server 192.168.33.171:3306 max_fails=3 fail_timeout=30s;
server 192.168.33.149:6379 max_fails=3 fail_timeout=30s;
}
server {
listen 192.168.33.180:6379;
proxy_connect_timeout 30s;
proxy_timeout 300s;
proxy_pass mysql_server;}
server {
listen 192.168.33.180:3306;
proxy_connect_timeout 30s;
proxy_timeout 300s;
proxy_pass mysql_server;
}
}訪問

到此這篇關(guān)于nginx tcp負(fù)載均衡的具體實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)nginx tcp負(fù)載均衡內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Nginx+keepalived雙機(jī)熱備技術(shù)實(shí)踐
- 生產(chǎn)環(huán)境部署Nginx服務(wù)器雙機(jī)熱備部署keepalived的步驟(多種模式教程)
- Nginx結(jié)合keepalived實(shí)現(xiàn)雙機(jī)熱備方案
- Nginx雙機(jī)熱備的實(shí)現(xiàn)步驟
- Nginx+Keepalived實(shí)現(xiàn)雙機(jī)熱備
- keepalived雙機(jī)熱備nginx的配置方法
- Nginx+Tomcat負(fù)載均衡群集全過程
- Nginx部署負(fù)載均衡服務(wù)的步驟全解析
- nginx負(fù)載均衡配置方式
- nginx負(fù)載均衡及詳細(xì)配置方法
- nginx實(shí)現(xiàn)負(fù)載均衡與實(shí)例解讀
- Nginx實(shí)現(xiàn)負(fù)載均衡的配置步驟
- keepalived+nginx+httpd實(shí)現(xiàn)的雙機(jī)熱備+負(fù)載均衡
相關(guān)文章
nginx+tomcat實(shí)現(xiàn)Windows系統(tǒng)下的負(fù)載均衡搭建教程
下面小編就為大家分享一篇nginx+tomcat實(shí)現(xiàn)Windows系統(tǒng)下的負(fù)載均衡搭建教程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助2017-12-12
nginx 配置代理服務(wù)地址最后多加反斜杠和不加反斜杠的區(qū)別小結(jié)
在使用Nginx配置代理服務(wù)時(shí),地址最后是否添加反斜杠(/)會(huì)對(duì)代理的URL處理產(chǎn)生影響,下面就來具體介紹一下,感興趣的可以了解一下2024-08-08
nginx+lua(openresty)實(shí)現(xiàn)黑/白名單權(quán)限控制的示例
本文介紹了如何使用Openresty進(jìn)行權(quán)限控制和灰度發(fā)布,具體通過定時(shí)器定期更新黑名單數(shù)據(jù),進(jìn)行用戶過濾和權(quán)限管控,具有一定的參考價(jià)值,感興趣的可以了解一下2024-09-09
Nginx代理MySQL實(shí)現(xiàn)通過域名連接數(shù)據(jù)庫的詳細(xì)教程
我們的生產(chǎn)環(huán)境基本上都部署在云服務(wù)器上,例如應(yīng)用服務(wù)器、MySQL服務(wù)器等,如果MySQL服務(wù)器直接暴露在公網(wǎng),就會(huì)存在很大的風(fēng)險(xiǎn),為了保證數(shù)據(jù)安全,MySQL服務(wù)器的端口是不對(duì)外開放的,所以本文介紹了Nginx代理MySQL實(shí)現(xiàn)通過域名連接數(shù)據(jù)庫的詳細(xì)教程2024-07-07
Nginx作為反向代理時(shí)傳遞客戶端IP的設(shè)置方法
因?yàn)閚ginx的優(yōu)越性,現(xiàn)在越來越多的用戶在生產(chǎn)環(huán)境中使用nginx作為前端,不管nginx在前端是做負(fù)載均衡還是只做簡(jiǎn)單的反向代理,都需要把日志轉(zhuǎn)發(fā)到后端real server,以方便我們檢查程序的各種故障2014-08-08

