nginx--tcp负载均衡

mysql负载均衡

安装mysql

复制代码
yum install -y mariadb-server
systemctl start mariadb
systemctl enable mariadb
ss -ntl

创建数据库并授权

复制代码
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;
 }
}

写入时闭合http

访问

redis负载均衡

安装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;
 }
}

访问

相关推荐
君穆南19 小时前
基于 NFS 与 Rsync 实现跨服务器 Seafile 数据平滑迁移实战
linux·运维·git
bloglin9999919 小时前
scp、rsync远程文件同步
linux·运维·服务器
迦南的迦 亚索的索19 小时前
LINUX环境
linux·运维·服务器
yuanjj8819 小时前
linux下调试域格CLM920 NC5等9x07平台模块 QMI拨号
linux·运维·服务器
IMPYLH20 小时前
Linux 的 printenv 命令
linux·运维·服务器·bash
SilentSamsara20 小时前
SSH 远程管理:密钥登录 + 隧道转发,一次性配置好
linux·运维·服务器·ubuntu·centos·ssh
Cx330❀21 小时前
Linux命名管道(FIFO)通信:从原理到实操,一文搞懂跨进程通信
大数据·linux·运维·服务器·elasticsearch·搜索引擎
嵌入式×边缘AI:打怪升级日志21 小时前
嵌入式Linux应用开发快速入门(从零到第一个程序)
linux·运维·notepad++
AI、少年郎21 小时前
MiniMind第 2 篇:破除大模型 “神秘感“, 环境搭建|Win/Linux 本地快速部署
linux·运维·服务器·ai·大模型训练·大模型微调·大模型原理
乐维_lwops1 天前
五层架构全景解析:Lerwee 运维智能体如何实现 “从感知到行动”(二)
运维·架构·运维智能体