目錄mysql
wget https://raw.githubusercontent.com/dblucyne/dodba_tools/master/doDBA --no-check-certificate wget https://raw.githubusercontent.com/dblucyne/dodba_tools/master/doDBA.conf --no-check-certificate chmod +x doDBA 或者 git pull https://github.com/dblucyne/dodba_tools
./doDBA -help -help # 顯示幫助 -c string # 指定配置文件 (default "doDBA.conf") -h string # 鏈接的 host/IP -sys # 打印Linux的信息 -myall # 打印Linux和MySQL的信息 -mysql # 打印MySQL的信息 -innodb # 打印InnoDB存儲引擎的信息 -mytop # 打印MySQL processlist,相似top -i <duration> # 刷新間隔的秒數 (默認1s) -t <int> #當MySQL Threads_running到達閾值時會輸出 show processlist和showengine innodb status到dodba.log中 (默認50) -hP <string> # 主機端口 (默認 "22") -hp <string> # 主機密碼 -hu <string> # 主機用戶 (默認 "root") -mP <string> # MySQL端口 (默認 "3306") -mp <string> # MySQL密碼 -mu <string> # MySQL用戶 -rds # 忽略Linux信息 -log # 按照日期輸出到日誌文件 -nocolor # 不加顏色輸出
cat doDBA.conf { "Host":"", "Huser": "root", "Hport": "22", "Hpwd": "", "Muser": "dodba", "Mpwd": "dodba", "Mport":"3306" }
./doDBA -c=doDBA.conf
Linux: groupadd dodba useradd dodba -g dodba echo xxxx | passwd dbdba --stdin
MySQL: create user dodba@’xxx.xxx.xxx.%’ identified by ‘dodba’; grant process on *.* to dodba@'xxx.xxx.xxx.%';
mkdir -p /data/doDBA_log/piwik/mysql{1,2}_log/{myall,innodb}
cat start_doDBA.sh #!/bin/bash host_ip=("10.10.xx.xx") INST_NAME="xxx" data_source=("myall","innodb") for IP in ${host_ip[@]} for SRC in ${data_source[@]} do cd /data/doDBA_log/${inst_name}/mysql1_log/myall/ ./doDBA -h ${IP} -c /data/doDBA_log/${INST_NAME}/mysql1_log/${SRC}/${INST_NAME}_doDBA.conf -$SRC -t=20 -log & done
cat kill_doDBA.sh #!/bin/bash ps -ef | grep doDBA | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1
crontab -e 0 0 # # # sh kill_doDBA.sh 1 0 # # # sh start_doDBA.sh
./doDBA -c doDBA.conf -mysql -log
show global status where Variable_name in ( "Com_select", "Com_insert", "Com_update", "Com_delete", "Innodb_buffer_pool_read_requests", "Innodb_buffer_pool_reads", "Innodb_rows_inserted", "Innodb_rows_updated", "Innodb_rows_deleted", "Innodb_rows_read", "Threads_running", "Threads_connected", "Threads_cached", "Threads_created", "Bytes_received", "Bytes_sent", "Innodb_buffer_pool_pages_data", "Innodb_buffer_pool_pages_free", "Innodb_buffer_pool_pages_dirty", "Innodb_buffer_pool_pages_flushed", "Innodb_data_reads", "Innodb_data_writes", "Innodb_data_read", "Innodb_data_written", "Innodb_os_log_fsyncs", "Innodb_os_log_written", "Slow_queries", "Created_tmp_disk_tables", "Created_tmp_tables", "Open_tables", "Open_files", "Table_locks_immediate", "Table_locks_waited" );
./doDBA -c doDBA.conf -innodb -log
show global status where Variable_name in ( "Com_select", "Com_insert", "Com_update", "Com_delete", "Innodb_buffer_pool_read_requests", "Innodb_buffer_pool_reads", "Innodb_rows_inserted", "Innodb_rows_updated", "Innodb_rows_deleted", "Innodb_rows_read", "Threads_running", "Threads_connected", "Threads_cached", "Threads_created", "Bytes_received", "Bytes_sent", "Innodb_buffer_pool_pages_data", "Innodb_buffer_pool_pages_free", "Innodb_buffer_pool_pages_dirty", "Innodb_buffer_pool_pages_flushed", "Innodb_data_reads", "Innodb_data_writes", "Innodb_data_read", "Innodb_data_written", "Innodb_os_log_fsyncs", "Innodb_os_log_written", "Slow_queries", "Created_tmp_disk_tables", "Created_tmp_tables", "Open_tables", "Open_files", "Table_locks_immediate", "Table_locks_waited" );
./doDBA -c doDBA.conf -sys -log
./doDBA -c doDBA.conf -myall -log
show global status where Variable_name in ( "Com_select", "Com_insert", "Com_update", "Com_delete", "Innodb_buffer_pool_read_requests", "Innodb_buffer_pool_reads", "Innodb_rows_inserted", "Innodb_rows_updated", "Innodb_rows_deleted", "Innodb_rows_read", "Threads_running", "Threads_connected", "Threads_cached", "Threads_created", "Bytes_received", "Bytes_sent", "Innodb_buffer_pool_pages_data", "Innodb_buffer_pool_pages_free", "Innodb_buffer_pool_pages_dirty", "Innodb_buffer_pool_pages_flushed", "Innodb_data_reads", "Innodb_data_writes", "Innodb_data_read", "Innodb_data_written", "Innodb_os_log_fsyncs", "Innodb_os_log_written", "Slow_queries", "Created_tmp_disk_tables", "Created_tmp_tables", "Open_tables", "Open_files", "Table_locks_immediate", "Table_locks_waited" );
/doDBA -h=10.1.xx.xx -myall DoDBA tools on host 10.1.xx.xx ---------+---load--avg---+-----cpu-usage-----+-swap+----net----+----mysql-status-------+-slow---th---+---bytes--- time | 1m 5m 10m | usr sys iow ide | si so| recv send | QPS TPS ins upd del| sql run con | recv send --------+-----------------+----------------------+------+------------+------------------------+---------------+----------- 13:52:00 | 4.00 3.68 3.60| 0.7 0.3 0.0 99.0 | 0 0 | 316K 4.3M| 203 58 22 36 0 | 0 2 52 | 86K 1.8M 13:52:01 | 4.00 3.68 3.60| 5.3 0.3 0.1 94.3 | 0 0 | 275K 2.0M| 251 67 27 40 0 | 0 3 76 | 104K 3.2M 13:52:02 | 4.00 3.68 3.60| 6.4 0.5 0.1 93.0 | 0 0 | 371K 4.1M| 380 810 24 786 0 | 0 3 40 | 311K 5.0M 13:52:03 | 4.00 3.68 3.60| 5.4 0.4 0.0 94.2 | 0 0 | 510K 4.2M| 648 283 30 253 0 | 1 3 52 | 216K 1.4M 13:52:04 | 4.00 3.68 3.60| 5.7 0.4 0.0 93.8 | 0 0 | 385K 2.7M| 108 69 45 24 0 | 0 4 48 | 71K 2.1M 13:52:05 | 3.92 3.66 3.59| 6.2 0.5 0.0 93.3 | 0 0 | 206K 2.0M| 339 96 52 44 0 | 0 3 37 | 107K 1.9M
./doDBA -h=10.1.xx.xx -myall -rds DoDBA tools on host 10.1.xx.xx ---------+----load--avg----+-----cpu-usage-----+swap+----net----+-----mysql-status------+-slow---th---+---bytes--- time | 1m 5m 10m | usr sys iow ide|siso| recv send|QPS TPS ins upd del| sql run con| recv send ---------+------------------+-------------------+----+-----------+-----------------------+-------------+----------- 17:19:17 | 0.00 0.00 0.00 | 0.0 0.0 0.0 0.0 | 0 0 | 0K 0K | 144 155 73 82 0 | 0 1 5 | 113K 229K 17:19:18 | 0.00 0.00 0.00 | 0.0 0.0 0.0 0.0 | 0 0 | 0K 0K | 66 113 32 81 0 | 0 2 6 | 79K 109K 17:19:19 | 0.00 0.00 0.00 | 0.0 0.0 0.0 0.0 | 0 0 | 0K 0K | 273 117 30 87 0 | 1 2 20 | 135K 502K 17:19:20 | 0.00 0.00 0.00 | 0.0 0.0 0.0 0.0 | 0 0 | 0K 0K | 207 173 74 99 0 | 1 2 17 | 137K 279K 17:19:21 | 0.00 0.00 0.00 | 0.0 0.0 0.0 0.0 | 0 0 | 0K 0K | 161 233 105 128 0 | 0 1 5 | 146K 193K
./doDBA -h=10.1.xx.xx -myall -t=3 2016/12/14 11:47:52 ----------------processlist--------------- ID:606374462 User:ums_read Host:10.1.xx.xx:31886 DB:mia Command:Query Time:3121 State:Sending data Info:SELECT ...................... ===================================== 2016-12-14 11:49:16 7f93ece24700 INNODB MONITOR OUTPUT ===================================== Per second averages calculated from the last 1 seconds ----------------- BACKGROUND THREAD ----------------- srv_master_thread loops: 11256164 srv_active, 0 srv_shutdown, 27867 srv_idle srv_master_thread log flush and writes: 11284031 ---------- SEMAPHORES ---------- OS WAIT ARRAY INFO: reservation count 1562657988 OS WAIT ARRAY INFO: signal count 11589318962 Mutex spin waits 7915500772, rounds 7044249291, OS waits 29061199 RW-shared spins 15964124137, rounds 99809511531, OS waits 1188604739 RW-excl spins 1056480533, rounds 26766008869, OS waits 261290579 ........................................
./doDBA -c doDBA.conf -mytop