轉自 linux公社
今天在這里介紹一下確認mariaDB(和MySQL一樣)的鏈接數及線程數的方法。MariaDB和MySQL有什么不一樣,現在還沒有弄清楚。
這是減少數據庫的負載,並能提高數據庫運行效率的入門。
連接mariaDB
# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 1176 Server version: 5.5.41-MariaDB-log MariaDB Server Copyright (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.htm
MariaDB Proxy讀寫分離的實現 http://www.linuxidc.com/Linux/2014-05/101306.htm
Linux下編譯安裝配置MariaDB數據庫的方法 http://www.linuxidc.com/Linux/2014-11/109049.htm
CentOS系統使用yum安裝MariaDB數據庫 http://www.linuxidc.com/Linux/2014-11/109048.htm
安裝MariaDB與MySQL並存 http://www.linuxidc.com/Linux/2014-11/109047.htm
Ubuntu 上如何將 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