1. 简介
1)简介
Lepus可以在数据库出现故障或者潜在性能问题时,根据用户设置及时将数据库的异常进行报警通知到数据库管理员进行处理和优化,帮助企业解决数据库性能监控问题,及时发现性能和瓶颈,避免由数据库潜在问题造成的直接经济损失。Lepus能够查看各种实时性能状态指标,并且对监控、性能数据进行统计分析,从运维者到决策者多个层面的视角,查看相关报表。帮助决策者对未来数据库容量进行更好的规划,从而降低了硬件成本。
2)可以解决的问题
- 帮助企业解决数据库性能监控问题,及时发现性能和瓶颈,避免由数据库潜在问题造成的直接经济损失
- 帮助企业运维领导决策者更好的统筹数据库容量资源,降低企业硬件成本
- 帮助企业DBA运维人员解决重复和枯燥的工作,提高运维人员工作效率
- 慢查询推送和AWR性能报告,降低数据库运维人员和开发人员的沟通成本
3)安装需求
需要的核心包如下:
以下软件包只需要部署在监控机即可。被监控机无需部署。
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此模块必须安装)
点此下载Lepus3.8_Beta.zip 提取码:5dge
2. lepus监控mysql
1) 安装lamp
[root@localhost ~]# yum install -y httpd php php-mysql mariadb-server mariadb-devel mariadb gcc gcc-c++
2)python版本
[root@localhost ~]# python -V
Python 2.7.5
确保python版本为python2.6及以上,不支持python3
3)安装mysqld for python
401 unzip MySQL-python.zip
407 cd MySQLdb1-master
407 yum -y install epel-release
408 yum -y install mariadb-devel python2-pip python-devel
[root@localhost MySQLdb1-master]# which mysql_config
/usr/bin/mysql_config
[root@localhost MySQLdb1-master]# vim site.cfg
mysql_config = /usr/bin/mysql_config
[root@localhost MySQLdb1-master]# python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/MySQLdb
······
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,4,'final',1) -D__version__=1.2.4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64/mysql -L/usr/lib64 -lmysqlclient -lpthread -lz -lm -ldl -lssl -lcrypto -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so
[root@localhost MySQLdb1-master]# python setup.py install
······
Copying MySQL_python-1.2.4-py2.7-linux-x86_64.egg to /usr/lib64/python2.7/site-packages
Adding MySQL-python 1.2.4 to easy-install.pth file
Installed /usr/lib64/python2.7/site-packages/MySQL_python-1.2.4-py2.7-linux-x86_64.egg
Processing dependencies for MySQL-python==1.2.4
Finished processing dependencies for MySQL-python==1.2.4
4)测试驱动是否正常运行
[root@localhost ~]# unzip Lepus3.8_Beta.zip
[root@localhost ~]# cd Lepus_v3.8_beta/python/
[root@localhost python]# python test_driver_mysql.py
MySQL python drivier is ok!
5)安装lepus采集器
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysqladmin -uroot password 123456
[root@localhost ~]# mysql -uroot -p123456
MariaDB [(none)]> create database lepus default character set utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on lepus.* to lepus@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)
[root@localhost ~]# cd /root/Lepus_v3.8_beta/sql/
[root@localhost sql]# mysql -ulepus -p123456 lepus <lepus_table.sql
[root@localhost sql]# mysql -ulepus -p123456 lepus <lepus_data.sql
[root@localhost sql]# cd ../python/
[root@localhost python]# chmod +x install.sh
[root@localhost python]# ./install.sh
[note] lepus will be install on basedir: /usr/local/lepus
[note] /usr/local/lepus directory does not exist,will be created.
[note] /usr/local/lepus directory created success.
[note] wait copy files.......
[note] change script permission.
[note] create links.
[note] install complete.
[root@localhost python]# cd /usr/local/lepus/
[root@localhost lepus]# vim etc/config.ini
[monitor_server]
host="127.0.0.1"
port=3306
user="lepus"
passwd="123456"
dbname="lepus"
启动lepus
[root@localhost lepus]# lepus start
lepus server start success!
6)安装web管理台
[root@localhost lepus]# cd /root/Lepus_v3.8_beta/php/
[root@localhost php]# cp -a . /var/www/html/
[root@localhost php]# systemctl start httpd
[root@localhost php]# cd /var/www/html/
[root@localhost html]# vim application/config/database.php
51 $db['default']['hostname'] = '127.0.0.1';
52 $db['default']['port'] = '3306';
53 $db['default']['username'] = 'lepus';
54 $db['default']['password'] = '123456';
55 $db['default']['database'] = 'lepus';
56 $db['default']['dbdriver'] = 'mysql';
访问本机ip
[root@localhost html]# firefox 192.168.20.110
默认管理员账号密码admin/Lepusadmin。登录后,修改管理员密码,增加普通账号
7)添加要监控的数据库实例