1.orzdba_monitor.sh脚本使用

  • ./orzdba_monitor.sh 主要是用nohup同时在后台调用orzdba,启动下面三个命令
[root@node02 scripts]# ps -ef |grep orzdba
root 19887 1 0 17:40 ? 00:00:00 /usr/bin/perl -w /scripts/orzdba -i 10 -t -mysql -innodb_rows -L /r2/monitor/log_orzdba_mysql -logfile_by_day
root 19888 1 0 17:40 ? 00:00:00 /usr/bin/perl -w /scripts/orzdba -i 10 -t -sys -d sda -L /r2/monitor/log_orzdba_sys -logfile_by_day
root 19889 1 0 17:40 ? 00:00:00 /usr/bin/perl -w /scripts/orzdba -i 10 -processlist -L /r2/monitor/log_orzdba_proc -logfile_by_day
  • 根据实际情况,需要修改变量:

    • SCRIPTS_FILE=/scripts --脚本所在目录
    • MONITOR=/r2/monitor --监控日志保存目录
    • DEVICE_NAME="sda" --数据库所在的硬盘盘符
    • DELETE_DAYS=15 --日志保存天数
  • 添加权限

[root@node02 scripts]# chmod 755 orzdba
[root@node02 scripts]# chmod 755 orzdba_monitor.sh
  • 计划任务

    • crontab -e
    • 每5分钟执行一次脚本,如果没有进程就启动
    • */5 * * * * /scripts/orzdba_monitor.sh >/dev/null 2>&1
  • 日志,分别生成三个日志,根据日期截断日志,可以设置保存日志的天数

    • 日志目录显示如下:
[root@node01 monitor]# ll /r2/monitor/
total 194052
-rw-r--r-- 1 root root 225257 Apr 24 15:36 log_orzdba_mysql.2018-04-24
-rw-r--r-- 1 root root 180040747 Apr 24 15:36 log_orzdba_proc.2018-04-24
-rw-r--r-- 1 root root 202990 Apr 24 15:36 log_orzdba_sys.2018-04-24
-rw-r--r-- 1 root root 114 Apr 24 15:35 orzdba.log

2.orzdba

  • 根据实际情况,在orzdba中修改帐号信息。
my $user="root";       # -u   --mysql帐号
my $pass="iforgot"; # -p --mysql密码
my $host="localhost"; # -h --mysqlhost
  • 验证帐号如下:
[root@node02 scripts]#  ./orzdba -u root -p iforgot -h localhost -innodb  -C 5 -i 2  2>/dev/null
.=================================================.
| Welcome to use the dba tool ! |
'=============== Date : 2018-04-23 ===============' Local_Host: node02.mysql.com Local_IP: 192.168.49.247 MySQL_Host: localhost MySQL_DB :
ttt MySQL_Var : binlog_format[ROW] character_set_server[utf8] enforce_gtid_consistency[ON] gtid_mode[ON]
log_bin[ON] max_allowed_packet[4194304] max_binlog_cache_size[17179869184G] max_binlog_size[1G]
max_connect_errors[100000] max_connections[10000] max_user_connections[9990] open_files_limit[50000]
skip_name_resolve[ON] sync_binlog[0] table_definition_cache[912] table_open_cache[1024]
thread_cache_size[64] wait_timeout[31536000] innodb_adaptive_flushing[ON] innodb_adaptive_hash_index[ON] innodb_buffer_pool_size[4G] innodb_file_per_table[ON]
innodb_flush_log_at_trx_commit[2] innodb_flush_method[O_DIRECT] innodb_io_capacity[200] innodb_lock_wait_timeout[5]
innodb_log_buffer_size[16M] innodb_log_file_size[2G] innodb_log_files_in_group[2] innodb_max_dirty_pages_pct[75.000000]
innodb_open_files[1024] innodb_read_io_threads[4] innodb_thread_concurrency[64] innodb_write_io_threads[4] -------- ---innodb bp pages status-- -----innodb data status---- --innodb log-- his --log(byte)-- read ---query---
time | data free dirty flush| reads writes read written|fsyncs written| list uflush uckpt view inside que|
18:08:12| 0 0 0 0| 0 0 0 0| 0 0| 0 0 0 0 0 0|
18:08:14| 104298 157834 3 0| 0 0 0 0| 0 0| 61 0 9 0 0 0|
18:08:16| 104298 157834 0 1| 0 1 0 24k| 0 0| 61 0 9 0 0 0|
  • 帮助命令(./orzdba -I)
Usage :
Command line options : -I,--help Print Help Info.
-i,--interval Time(second) Interval.
-C,--count Times.
-t,--time Print The Current Time.
-nocolor Print NO Color. -l,--load Print Load Info.
-c,--cpu Print Cpu Info.
-s,--swap Print Swap Info.
-d,--disk Print Disk Info.
-n,--net Print Net Info. -u MySQL User(default root).
-P MySQL Password(default iforgot).
-P,--port Port number to use for mysql connection(default 3306).
-S,--socket Socket file to use for mysql connection.
-h,--host Host (hostname/IP). -mysql Print MySQLInfo (include -t,-com,-hit,-T,-B).
-innodb Print InnodbInfo(include -t,-innodb_pages,-innodb_data,-innodb_log,-innodb_status)
-com Print MySQL Status(Com_select,Com_insert,Com_update,Com_delete).
-hit Print Innodb Hit%.
-processlist Print Show Full Processlist
-innodb_rows Print Innodb Rows Status(Innodb_rows_inserted/updated/deleted/read).
-innodb_pages Print Innodb Buffer Pool Pages Status(Innodb_buffer_pool_pages_data/free/dirty/flushed)
-innodb_data Print Innodb Data Status(Innodb_data_reads/writes/read/written)
-innodb_log Print Innodb Log Status(Innodb_os_log_fsyncs/written)
-innodb_status Print Innodb Status from Command: 'Show Engine Innodb Status';
(history list/ log unflushed/uncheckpointed bytes/ read views/ queries inside/queued) -T,--threads Print Threads Status(Threads_running,Threads_connected,Threads_created,Threads_cached).
-B,--bytes Print Bytes received from/send to MySQL(Bytes_received,Bytes_sent).
-rt Print MySQL DB RT(us). -sys Print SysInfo (include -t,-l,-c,-s).
-lazy Print Info (include -t,-l,-c,-s,-com,-hit). -L,--logfile Print to Logfile.
-logfile_by_day One day a logfile,the suffix of logfile is 'yyyy-mm-dd';
and is valid with -L.
Sample :
shell> ./orzdba -u xxxxx -p xxxxx -innodb -C 5 -i 2 2>/dev/null
shell> ./orzdba -u xxxxx -p xxxxx -lazy -d sda -C 5 -i 2 2>/dev/null
shell> ./orzdba -h xxxxx -u xxxxx -p xxxxx -processlist -C 5 -i 2 2>/dev/null
shell> nohup ./orzdba -u xxxxx -p xxxxx -lazy -d sda -C 5 -i 2 -L /tmp/orzdba.log > /dev/null 2>&1 &

3.问题

1.没有创建监控目录,请排查脚本执行权限

2.监控目录里面没有获取到日志文件,请排查MySQL访问权限或者监控盘符配置错误

3.报"orzdba_xxxx未启动,开始执行",但没获取到日志,请排查是否有已启动的线程,kill掉,重新执行

orzdba_monitor.sh脚本使用的更多相关文章

  1. orzdba_monitor.sh和orzdba

    1.脚本 #!/bin/bash # line: V1.0 # mail: gczheng@139.com # data: 2018-04-23 # script_name: orzdba_monit ...

  2. sh脚本异常:/bin/sh^M:bad interpreter: No such file or directory

    在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory. 分析:这是不同系统编码格式引起的:在windows系统中 ...

  3. linux执行sh脚本文件命令

    linux执行sh脚本文件命令 很多时候需要多个命令来完成一项工作,而这个工作又常常是重复的,这个时候我们自然会想到将这些命令写成sh脚本,下次执行下这个脚本一切就都搞定了,下面就是发布代码的一个脚本 ...

  4. .sh脚本判断判断某一变量是否为某一数值

    .sh脚本中,判断某一变量(例如:OEM_CUSTOMER_SUPPORT)是否为某一数值(例如:0),并根据条件做不同处理,写法如下: if [ $OEM_CUSTOMER_SUPPORT -eq  ...

  5. sh脚本学习之: sh脚本 、sed、awk

    sh脚本 sh命令的批处理文件,支持更复杂的逻辑. Shell中的变量 参数 $0 当前脚本路径 $1....$n 脚本执行对应的第n个参数 条件判断 文件判断 test [op] path e存在 ...

  6. 安装GRID时跑root.sh脚本报错(ORA-27091: unable to queue I/O)

    在安装GRID过程中,运行root.sh脚本时报如下信息: Adding Clusterware entries to upstart CRS-2672: Attempting to start 'o ...

  7. sh脚本异常:bad interpreter: No such file or directory

    转:http://bluedest.iteye.com/blog/1674963 在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file o ...

  8. ubuntu sh脚本双击运行

    自从13.04以后,双击sh脚本文件就已经默认是geidt打开了,要想运行,从nautilus-->文件-->首选项-->行为-->可执行文件 有三个选项,默认是第二个,如果想 ...

  9. sh脚本执行Java程序

    1.不引用Jar包或者资源文件夹 最简单的程序Hello World. 首先创建Hello.java public class Hello { public static void main(Stri ...

随机推荐

  1. vs 2013远程调试

    1. 找到本机Remote Debugger/x64文件夹,将其拷贝到远程机器上 2.运行x64文件夹下的msvsmon.exe,将其设置为“无身份验证模式”,记住端口号,一会儿要用到 3.在vs中打 ...

  2. Git远程操作详解(转)

    转自:http://www.ruanyifeng.com/blog/2014/06/git_remote.html Git远程操作详解   Git是目前最流行的版本管理系统,学会Git几乎成了开发者的 ...

  3. 《利用Python进行数据分析》笔记---第2章--1880-2010年间全美婴儿姓名

    写在前面的话: 实例中的所有数据都是在GitHub上下载的,打包下载即可. 地址是:http://github.com/pydata/pydata-book 还有一定要说明的: 我使用的是Python ...

  4. [Linux] jq:命令行JSON处理工具

    jq命令帮助我们很方便地在终端查看和处理json文件 jq命令的帮助信息: abby@abby:bgs$ jq -h jq - commandline JSON processor [version ...

  5. 自己手写一个SpringMVC框架

    前端框架很多,但没有一个框架称霸,后端框架现在Spring已经完成大一统.所以学习Spring是Java程序员的必修课. Spring框架对于Java后端程序员来说再熟悉不过了,以前只知道它用的反射实 ...

  6. 使用vue与element组件

    1.安装element npm i element-ui -S 2.引入 在main.js写入一下内容 import Vue from 'vue'; import ElementUI from 'el ...

  7. JVM原理三-----GC模块,垃圾回收

    GC方法:在JVM启动时填入参数(比如:-XX:+UseConcMarkSweepGC ) 算法区分: 1.古老回收算法: Reference Counting  ,对象有一个引用,即增加一个计数,删 ...

  8. HDU2222 Keywords Search ac自动机第一题

    指针我一般都会出错,所以还是自己写数组版本. In the modern time, Search engine came into the life of everybody like Google ...

  9. 每天一个linux命令(文件操作):【转载】find命令之exec

    find是我们很常用的一个Linux命令,但是我们一般查找出来的并不仅仅是看看而已,还会有进一步的操作,这个时候exec的作用就显现出来了. exec解释: -exec  参数后面跟的是command ...

  10. bzoj 5288 游戏

    bzoj 5288 游戏 显然从点 \(x\) 出发,能到达的点是包含 \(x\) 的一段区间.用 \(L,R\) 两个数组记录每个点对应的区间端点. 如果能预处理出 \(L,R\) ,询问显然可以 ...