MySQL 数据库性能 一键调优工具 tuning-primer.sh
1 背景知识
2 调优工具安装
#root>
wget https://raw.githubusercontent.com/BMDan/tuning-primer.sh/main/tuning-primer.sh
这里也提供镜像下载 [[000-inbox/MySQL/tuning-primer.sh]]。
3 调优工具使用
3.1 执行一键调优脚本
sh tuning-primer.sh
3.2 输入 MySQL 数据库用户与密码
Using login values from ~/.my.cnf
- INITIAL LOGIN ATTEMPT FAILED -
Testing for stored webmin passwords:
None Found
Could not auto detect login info!
Found potential sockets: /var/lib/mysql/mysql.sock /var/run/mysqld/mysqlx.sock
Will use client's default socket (this is normally correct).
Would you like to override my socket choice?: [y/N] n
Do you have your login handy ? [y/N] : y
User: root
Password:
Would you like me to create a ~/.my.cnf file for you? If you answer 'N',
then I'll create a secure, temporary one instead. [y/N] : n
从第 7
行开始的说明:
提示 | 值 |
---|---|
8行:是否使用默认套接字链接。 | y |
9行:是否启用手动登录。 | y |
10行:用户名。 | root |
11行:用户密码 | kingbase |
12行:是否创建 ~/.my.cnf 文件保存用户和密码 |
n |
13行:是否创建一个安全的临时文件保存用户和密码。 | n |
3.3 添加调优参数
根据建议的调优结果进行参数调优。
- 编辑
my.cnf
文件。
vi /etc/my.cnf
- 填写参数内容。
key_buffer_size=512K
max_connections=1000
4 调优结果验证
systemctl restart mysqld.service
ksql -u root -p
show variables where variable_name in ('key_buffer_size','max_connections');
+-----------------+--------+
| Variable_name | Value |
+-----------------+--------+
| key_buffer_size | 524288 |
| max_connections | 1000 |
+-----------------+--------+
2 rows in set (0.01 sec)