1、查看最大連接數(shù)
mysql> show variables like 'max_connections';
默認(rèn)連接數(shù)為151
2矮瘟、修改最大連接數(shù)
/etc/mysql/mysql.conf.d/mysqld.cnf
[mysql]
max_connections = 10000
3姑廉、重啟確認(rèn)狀態(tài)
service mysql restart
執(zhí)行【1】操作后,結(jié)果為214俐末,非配置文件中設(shè)置10000
查詢?nèi)罩景l(fā)現(xiàn)
65 2018-12-19T03:40:41.567706Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 50000)
66 2018-12-19T03:40:41.567763Z 0 [Warning] Changed limits: max_connections: 214 (requested 10000)
67 2018-12-19T03:40:41.567768Z 0 [Warning] Changed limits: table_open_cache: 400 (requested 2000)
4料按、查看系統(tǒng)limit限制
# 查詢文件限制
$ ulimit -n
1024
5、修改系統(tǒng)限制
- 在/etc/security/limits.conf最后增加如下兩行記錄
* hard nofile 65535 * soft nofile 65535
- 編輯/etc/pam.d/common-session卓箫,加入一行
session required pam_limits.so
- 編輯/etc/profile载矿,加入
執(zhí)行cource 命令使配置生效ulimit -SHn 65535
- 確認(rèn)修改是否成功
執(zhí)行【4】命令,返回65535,系統(tǒng)限制修改成功
6闷盔、再次重啟確認(rèn)狀態(tài)
重復(fù)【3】操作后弯洗,發(fā)現(xiàn)仍為 214, 問(wèn)題出在mysql.service配置上
7逢勾、修改mysql配置
- 查找mysql.service 啟動(dòng)文件
$ systemctl status mysql.service ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2018-12-19 23:53:28 CST; 16min ago Process: 25857 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS) Process: 25843 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 25856 (mysqld) Tasks: 28 (limit: 4915) Memory: 185.9M CPU: 1.577s CGroup: /system.slice/mysql.service └─25856 /usr/sbin/mysqld
- 在mysql.service中追加以下配置
LimitNOFILE=65535 LimitNPROC=65535
8牡整、重啟確認(rèn)
END
ps:mysql log 時(shí)間戳默認(rèn)采用UTC,使用時(shí)應(yīng)修改為系統(tǒng)時(shí)區(qū)
配置查詢:mysql> show variables like 'log%';
配置修改:
mysql> SET GLOBAL log_timestamps = SYSTEM; -- 立即生效溺拱,重啟失效
在配置文件中添加 log_timestamps=SYSTEM ???????? # 永久生效