今天在这里介绍一下确认mariaDB(和MySQL一样)的链接数及线程数的方法。MariaDB和MySQL有什么不一样,现在还没有弄清楚。这是减少数据库的负载,并能提高数据库运行效率的入门。连接mariaDB# mysql -uroot -pEnter password:Welcome to the MariaDB monitor.Commands end with ; or g.Your MariaDB connection id is 1176Server version: 5.5.41-MariaDB-log MariaDB ServerCopyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.Type "help;" or "h" for help. Type "c" to clear the current input statement.MariaDB [(none)]>最大连接数MariaDB [(none)]> show global variables like "max_connections";+-----------------+-------+| Variable_name | Value |+-----------------+-------+| max_connections | 151 |+-----------------+-------+1 row in set (0.00 sec)MariaDB启动后的累计连接数MariaDB [(none)]> show global status like "Connections";+---------------+-------+| Variable_name | Value |+---------------+-------+| Connections | 1190|+---------------+-------+1 row in set (0.00 sec)mariaDB启动后的最大同时连接数MariaDB [(none)]> show global status like "Max_used_connections";+----------------------+-------+| Variable_name| Value |+----------------------+-------+| Max_used_connections | 7 |+----------------------+-------+1 row in set (0.00 sec)MariaDB线程信息MariaDB [(none)]> show global status like "Thread_%";+-------------------------+-------+| Variable_name | Value |+-------------------------+-------+| Threadpool_idle_threads | 0 || Threadpool_threads| 0 || Threads_cached| 6 || Threads_connected | 1 || Threads_created | 7 || Threads_running | 1 |+-------------------------+-------+6 rows in set (0.01 sec)
- Threads_cached:备用的线程数(线程是可以再利用的)
- Threads_connected:现在的连接数
- Threads_created:备用的线程不足时,会生成新线程(这个值不断变大时,表示Threads_cached不足)
- Threads_running:正在执行中的线程,也可以说是不在Sleep状态的线程
Threads_cached + Threads_connected < thread_cache_size是理想的状态。MariaDB [(none)]> show global variables like ‘thread_cache_size’;+——————-+——-+| Variable_name | Value |+——————-+——-+| thread_cache_size | 52|+——————-+——-+1 row in set (0.00 sec)小结
从以上也可以看出来,在MySQL上使用的命令基本上也可以在MariaDB使用。最重要的是,MySQL逻辑和MariaDB逻辑还看不出有什么不一样,看出不同可能需要更深入的使用MariaDB。Linux系统教程:如何检查MariaDB服务端版本 http://www.linuxidc.com/Linux/2015-08/122382.htmMariaDB Proxy读写分离的实现 http://www.linuxidc.com/Linux/2014-05/101306.htmLinux下编译安装配置MariaDB数据库的方法 http://www.linuxidc.com/Linux/2014-11/109049.htmCentOS系统使用yum安装MariaDB数据库 http://www.linuxidc.com/Linux/2014-11/109048.htm安装MariaDB与MySQL并存 http://www.linuxidc.com/Linux/2014-11/109047.htmUbuntu 上如何将 MySQL 5.5 数据库迁移到 MariaDB 10 http://www.linuxidc.com/Linux/2014-11/109471.htm
[翻译]Ubuntu 14.04 (Trusty) Server 安装 MariaDB http://www.linuxidc.com/Linux/2014-12/110048htm
MariaDB 的详细介绍:请点这里
MariaDB 的下载地址:请点这里
本文永久更新链接地址