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. 老鼠走迷宫(2)输出所有路径(C语言)

    需求 有一个迷宫,在迷宫的某个出口放着一块奶酪.将一只老鼠由某个入口处放进去,它必须穿过迷宫,找到奶酪.请找出它的行走路径. STEP 1 题目转化 我们用一个二维数组来表示迷宫,用2表示迷宫的墙壁, ...

  2. iOS支付宝SDK回调那坑

    支付宝钱包支付接口开发包2.0标准版(iOS 2.2.1) ,回调不出来,demo给出的方法是: - (BOOL)application:(UIApplication *)application op ...

  3. MATLAB基础知识tips

    网络论坛资源: MATLAB中文论坛https://i.cnblogs.com/EditPosts.aspx?opt=1 circshift 移位函数,circshift(A,SHIFTSIZE).S ...

  4. 生产者与消费者的Java实现

    首先创建maven工程,需要引入的包: <dependencies> <dependency> <groupId>org.apache.kafka</grou ...

  5. sed和awk简介

    什么是sed和awk         sed和awk是Linux环境下数据的处理工具,可以完成对数据的增删改查的功能.         sed处理时是以行尾单位的,awk处理数据时以字段为单位. se ...

  6. PostgreSQL备份工具-pg_backrest(转)

    转自:http://blog.chinaunix.net/uid-7270462-id-5777877.html 官网:https://pgbackrest.org 一.配置集中备份服务器 1.1 备 ...

  7. node中的一些诡异bug

    这种bug一般是监听的端口号被占用了导致的,换个端口号!!!!

  8. onunload、onbeforeunload事件详解--zhuan

    最近项目中做到一个功能:在上传页面用户开始上传文件之后用户点击任意跳转都需要弹出提示层进行二次确定才允许他进行跳转,这样做的目的是为了防止用户的错误操作导致这珍贵的UGC 流失(通常用户在一次上传不成 ...

  9. d3.js入门学习

    个人感觉前端数据可视化是个趋势,并且现在所在公司也是有做这块的项目,虽然我目前还没有接触到公司数据可视化的项目,但是,今后总是要接触的嘛. 今天看了一下公司目前所用的两种数据可视化工具---D3和EC ...

  10. 产生num个不重复的随机数组

    createDiffRandom : function (from,to,num) { // 产生num个不重复的随机数组 var arr=[],json={}; // 随机数数组 , 标记json对 ...