Monk的学习笔记

宠辱不惊,闲看庭前花开花落;去留无意,漫随天外云卷云舒。

  • 博客访问: 2070252
  • 博文数量: 164
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-14 10:49
  • 认证徽章:
个人简介

每个人都有梦想,去实现吧!

文章分类

全部博文(164)

文章存档

2017年(11)

2016年(18)

2015年(36)

2014年(81)

2013年(18)

分类: 其他

2017-02-10 11:33:32

参考官方手册:http://www.lepus.cc/manual/index
安装xampp集成环境
[root@230_42-tiantu_monitor lepus]# ./xampp-linux-x64-5.6.24-1-installer.run
[root@230_42-tiantu_monitor lepus]# /opt/lampp/lampp start
[root@230_42-tiantu_monitor lepus]# /opt/lampp/bin/mysql -uroot -p
初始密码为空
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'work123'
MariaDB [(none)]> flush privileges;

yum install -y libffi-devel python-devel openssl-devel mysql-devel libxml2 libxml2-dev
[root@230_42-tiantu_monitor lepus]# yum install -y libffi-devel python-devel openssl-devel mysql-devel libxml2 libxml2-dev libxslt* zlib openssl ncurses-devel gcc
[root@230_42-tiantu_monitor lepus]# unzip MySQL-python-1.2.5.zip
[root@230_42-tiantu_monitor lepus]# cd MySQL-python-1.2.5
[root@230_42-tiantu_monitor lepus]# python setup.py build
[root@230_42-tiantu_monitor lepus]# python setup.py install

[root@230_42-tiantu_monitor lepus]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
Preparing... ########################################### [100%]
1:oracle-instantclient11.########################################### [100%]
[root@230_42-tiantu_monitor lepus]# rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
Preparing... ########################################### [100%]
1:oracle-instantclient11.########################################### [100%]
[root@230_42-tiantu_monitor lepus]# rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
Preparing... ########################################### [100%]
1:oracle-instantclient11.########################################### [100%]
[root@230_42-tiantu_monitor lepus]# rpm -ivh oracle-instantclient11.2-tools-11.2.0.4.0-1.x86_64.rpm
Preparing... ########################################### [100%]
1:oracle-instantclient11.########################################### [100%]
[root@230_42-tiantu_monitor ~]# cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/local/lib
export TNS_ADMIN=/usr/local/oracle/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
export PATH=$PATH:$ORACLE_HOME
export LD_LIBRARY_PATH
export PATH
[root@230_42-tiantu_monitor ~]# cd $ORACLE_HOME
[root@230_42-tiantu_monitor client64]# mkdir -p network/admin/
[root@230_42-tiantu_monitor client64]# vi network/admin/tnsnames.ora
[root@230_42-tiantu_monitor ~]# tar zxvf pymongo-3.3.0.tar.gz
[root@230_42-tiantu_monitor ~]# cd pymongo-3.3.0
[root@230_42-tiantu_monitor ~]# python setup.py build
[root@230_42-tiantu_monitor ~]# python setup.py install

yum -y install mysql-devel libxml2 libxml2-dev libxslt* zlib gcc openssl
yum install python-devel mysql-devel zlib-devel openssl-devel
yum install ncurses-devel

系统监控

[root@20_52-mongodb3_test ~]# yum install net-snmp*
[root@20_52-mongodb3_test ~]# vi /etc/snmp/snmpd.conf
40 # sec.name source community
41 com2sec notConfigUser 192.168.20.136 lepus

61 # group context sec.model sec.level prefix read write notif
62 access notConfigGroup "" any noauth exact all none none

84 ## incl/excl subtree mask
85 view all included .1 80

[root@localhost ~]# vi /etc/init.d/snmpd
#OPTIONS="-LS0-6d -Lf /dev/null -p /var/run/snmpd.pid"
OPTIONS="-LS 4 d -p /var/run/snmpd.pid -a"

[root@localhost ~]# service snmpd restart

慢SQL监控

客户端配置
安装后toolkit
rpm -ivh MySQL-shared-compat-5.6.32-1.el6.x86_64.rpm
yum -y install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
yum -y install perl-IO-Socket-SSL install perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL
tar zxvf percona-toolkit_2.2.15-2.tar.gz
cd percona-toolkit-2.2.15/
perl Makefile.PL
make
make install

######MySQL slow query
*/5 * * * * /opt/scripts/mysql/slow_query.sh

#!/bin/bash
#****************************************************************#
# ScriptName: /usr/local/sbin/lepus_slowquery.sh
# Create Date: 2014-03-25 10:01
# Modify Date: 2014-03-25 10:01
#***************************************************************#

#config lepus database server
lepus_db_host="l192.168.1.1"
lepus_db_port=3306
lepus_db_user="root"
lepus_db_password="test"
lepus_db_database="lepus"

#config mysql server
mysql_client="/usr/local/mysql/bin/mysql"
mysql_host="127.0.0.1"
mysql_port=3306
mysql_user="root"
mysql_password="test"

#config slowqury
slowquery_dir="/mysqldb/mysql/log/"
slowquery_long_time=5
slowquery_file=`$mysql_client -h$mysql_host -P$mysql_port -u$mysql_user -p$mysql_password -e "show variables like 'slow_query_log_file'"|grep log|awk '{print $2}'`
pt_query_digest="/usr/local/bin/pt-query-digest"

#config server_id
lepus_server_id=286

#collect mysql slowquery log into lepus database
$pt_query_digest --user=$lepus_db_user --password=$lepus_db_password --port=$lepus_db_port --review h=$lepus_db_host,D=$lepus_db_database,t=mysql_slow_query_review --history h=$lepus_db_host,D=$lepus_db_database,t=mysql_slow_query_review_history --no-report --limit=100% --filter=" \$event->{add_column} = length(\$event->{arg}) and \$event->{serverid}=$lepus_server_id " $slowquery_file > /tmp/lepus_slowquery.log

##### set a new slow query log ###########
tmp_log=`$mysql_client -h$mysql_host -P$mysql_port -u$mysql_user -p$mysql_password -e "select concat('$slowquery_dir','slowquery_',date_format(now(),'%Y%m%d'),'.log');"|grep log|sed -n -e '2p'`

#config mysql slowquery
$mysql_client -h$mysql_host -P$mysql_port -u$mysql_user -p$mysql_password -e "set global slow_query_log=1;set global long_query_time=$slowquery_long_time;"
$mysql_client -h$mysql_host -P$mysql_port -u$mysql_user -p$mysql_password -e "set global slow_query_log_file = '$tmp_log'; "

#delete log before 7 days
cd $slowquery_dir
/usr/bin/find ./ -name 'slowquery_*' -mtime +7|xargs rm -rf ;

####END####
阅读(784) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册