centos7 修改 mariadb 最大连接数

目的

在 centos7 下修改 mariadb 最大连接数

获得 maraidb 帮助

  1. 启动 maradb

    systemctl start mariadb

  2. 执行下面

    /usr/libexec/mysqld –help –verbose > /root/mariadb.help

查询连接数

通过下面命令, 可以查询到当前 maraidb 连接数状态

MariaDB [(none)]> show status like '%conn%';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| Aborted_connects         | 0     |   <- 被中断的连接, 可能由于密码错误或者权限错误, 或者其他原因断开连接
| Connections              | 3     |   <- 服务器启动至今, 曾经完成过的客户端连接次数
| Max_used_connections     | 1     |   <- 服务器启动至今, 曾经出现过的最大并发连接
| Ssl_client_connects      | 0     |   <- 通过 ssl 方式的客户端连接
| Ssl_connect_renegotiates | 0     |
| Ssl_finished_connects    | 0     |
| Threads_connected        | 1     |   <- 当前正在与 mariadb 交互的客户端连接数
+--------------------------+-------+
7 rows in set (0.00 sec)

通过下面命令, 可以查询当前 maraidb 与连接数相关的配置
注意, max_connctions, max_user_connections 两个参数只可以选择一种对用户连接进行限制

MariaDB [(none)]> show variables like '%conn%';
+--------------------------+-----------------+
| Variable_name            | Value           |
+--------------------------+-----------------+
| character_set_connection | utf8            |  <- 字符集
| collation_connection     | utf8_general_ci |  <- 字符集
| connect_timeout          | 10              |  <- 连接超时
| extra_max_connections    | 1               |
| init_connect             |                 |  <- 连接后执行的初始化脚本
| max_connect_errors       | 10              |
| max_connections          | 6000            |  <- 最大并发数 (不分客户)
| max_user_connections     | 0               |  <- 最大用户并发(分连接用户名)
+--------------------------+-----------------+
8 rows in set (0.00 sec)

配置方法

1 修改 /etc/my.cnf.d/server.cnf

max-connections    = 6000
open-files-limit = 6000

2 修改 /usr/lib/systemd/system/mariadb.service

[Service]
Type=simple
User=mysql
Group=mysql
LimitNOFILE=infinity    <- 添加

3 重启 mariadb

[root@ns-zabbix ~]# systemctl daemon-reload
[root@ns-zabbix ~]# systemctl restart mariadb

猜你喜欢

转载自blog.csdn.net/signmem/article/details/79972089
今日推荐