类别 | 版本 |
---|---|
操作系统 | Centos 7.4 |
数据库版本 | MySQL 5.6.49 |
天兔版本 | lepus 3.7 |
依赖软件
1.MySQL 5.0及以上(必须,用来存储监控系统采集的数据)
2.Apache 2.2及以上 (必须,WEB服务器运行服务器)
3.PHP 5.3以上 (必须,提供WEB界面支持)
4.Python2 (必须,推荐2.6及以上版本,执行数据采集和报警任务,不支持Python3)
5.Python连接和监控数据库的相关驱动模块包:
MySQLdb for python (Python连接MySQl的接口,用于监控MySQL,此模块必须安装)
cx_oracle for python (Python连接Oracle的接口,非必须,如果需要监控oracle此模块必须安装)
Pymongo for python (Python连接MongoDB的接口,非必须,如果需要监控MongoDB此模块必须安装 )
redis-py for python (Python连接Redis的接口,非必须,如果需要监控Redis此模块必须安装)
lepus官方文档
http://www.lepus.cc/manual/index
-- yum一键搞定
yum install mysql-server httpd php -y
如果自己已手工安装了mysql,这个地方可以不用再安装
chkconfig httpd on
chkconfig mysqld on
yum install gcc python-devel mysql-devel net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xml -y
-- 配置http服务
vi /etc/httpd/conf/httpd.conf
ServerName 10.31.1.6:80
--重启http服务器
service httpd start
sed -i "s/;date.timezone =/date.timezone = Asia\/Shanghai/g" /etc/php.ini
sed -i "s#max_execution_time = 30#max_execution_time = 300#g" /etc/php.ini
sed -i "s#post_max_size = 8M#post_max_size = 32M#g" /etc/php.ini
sed -i "s#max_input_time = 60#max_input_time = 300#g" /etc/php.ini
sed -i "s#memory_limit = 128M#memory_limit = 128M#g" /etc/php.ini
sed -i "/;mbstring.func_overload = 0/ambstring.func_overload = 2\n" /etc/php.ini
很多操作系统是自带python 2版本的,如果有,此处略过
因为lepus不兼容python 3版本,如是python 3版本,要卸载掉,再安装python 2版本
cd /usr/local/src
wget https://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
tar jxf Python-2.7.2.tar.bz2
cd Python-2.7.2
./configure --prefix=/usr/local/python2.7
make && make install
yum -y install python-setuptools
wget https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip --no-check-certificate
unzip MySQL-python-1.2.5.zip
cd MySQL-python-1.2.5
python setup.py build
python setup.py install
如果没有redis监控需求
cd /usr/local/src/
wget https://pypi.python.org/packages/source/r/redis/redis-2.10.3.tar.gz
tar xf redis-2.10.3.tar.gz
cd redis-2.10.3
python setup.py install
下载3.7版本
http://www.lepus.cc/soft/17
cd /usr/local/src
ll Lepus3.7.zip
unzip Lepus3.7.zip
cd /usr/local/src/lepus_v3.7/sql/
mysql -uroot -p -h10.31.1.6
create database lepus default character set utf8;
grant select,insert,update,delete,create on lepus.* to 'lepus'@'localhost' identified by 'lepus';
grant select,insert,update,delete,create on lepus.* to 'lepus'@'127.0.0.1' identified by 'lepus';
-- 监控mysql 8.0版本需要加上这个
ALTER USER 'lepus'@'10.31.1.%' IDENTIFIED WITH mysql_native_password BY 'lepus';
flush privileges;
-- 录入数据
source lepus_table.sql
source lepus_data.sql
cd /usr/local/src/lepus_v3.7/python
sh install.sh
cd /usr/local/lepus/
chmod +x *.sh
chmod +x *.py
修改配置文件
vim etc/config.ini
###监控机MySQL数据库连接地址###
[monitor_server]
host="127.0.0.1"
port=3306
user="lepus"
passwd="lepus"
dbname="lepus"
[root@uatest ]# lepus start
nohup: appending output to `nohup.out'
lepus server start success!
cp -rf /usr/local/src/lepus_v3.7/php/* /var/www/html/
cd /var/www/html/application/config/
service httpd restart
线上的要有防火墙,不能直接关闭了事
service iptables stop
setenforce 0
浏览器输入:http://10.31.1.6
默认管理员账号密码admin/Lepusadmin
-- 添加监控账号 MySQL 8
create user 'lepus'@'10.31.1.%' ;
grant all privileges on *.* to 'lepus'@'10.31.1.%' ;
ALTER USER 'lepus'@'10.31.1.%' IDENTIFIED WITH mysql_native_password BY 'lepus';
flush privileges;
-- 添加监控账号 MySQL 8之前版本
create user 'lepus'@'10.31.1.%' identified by 'abc123';
grant all privileges on *.* to 'lepus'@'10.31.1.%' ;
flush privileges;
慢sql监控
进到对应的目录下,找到脚本lepus_slowquery.sh,要把该脚本发送到被监控的DB端,结合任务计划调用,而且被监控端要percona-toolkit
cd /usr/local/lepus/client/mysql/
ls -l lepus_slowquery.sh
scp ./lepus_slowquery.sh root@10.31.1.112:/u01/my3306/lepus/
-- 格式转一下
dos2unix lepus_slowquery.sh
sed -i "s/\\r/\\n/g" lepus_slowquery.sh
sed -i /^$/d lepus_slowquery.sh
-- 10.31.1.112上操作
cd /usr/local/src/
wget https://www.percona.com/downloads/percona-toolkit/2.2.11/RPM/percona-toolkit-2.2.11-1.noarch.rpm
yum install perl-IO-Socket-SSL perl-DBD-MySQL perl-Time-HiRes -y
rpm -ivh percona-toolkit-2.2.11-1.noarch.rpm
-- 编辑配置文件
vim /u01/my3306/lepus/slowquery.sh
-- 112上慢日志路径
/u01/my3306/log/slow.log
-- 当我运行了 lepus_slowquery.sh后,慢日志文件变为
被监控主机配置crontab
*/5 * * * * sh /u01/my3306/lepus/lepus_slowquery.sh > /dev/null 2>&1
需要被监控的主机才安装这个服务
安装snmp服务
yum install -y net-snmp net-snmp-utils
vim /etc/snmp/snmpd.conf
把#号去掉,开启下面这行
修改下面的为all
-- 重启服务
[root@uattest config]# service snmpd start
Redirecting to /bin/systemctl start snmpd.service
1.https://www.cnblogs.com/xuanzhi201111/p/5200757.html
2.https://www.jianshu.com/p/ff62001d9f1c
3.https://www.cnblogs.com/yiyuf/p/4121383.html