lepus安裝記錄

靜以致遠√團團發表於2017-02-10
參考官方手冊:
安裝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####

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29320885/viewspace-2133354/,如需轉載,請註明出處,否則將追究法律責任。

相關文章