mysql数据库监控利器lepus天兔⼯具安装和部署
需要的核⼼包如下:
以下软件包只需要部署在监控机即可。被监控机⽆需部署。
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此模块必须安装)
⼀.基本环境安装
(1)安装LAMP环境Lepus对MySQL性能还是有⼀定的影响的,特别是当我们的被监控端越来越多,监控项也⽐较多时,建议安装mysql5.6⼆进制版本)
先安装mysql,⼆进制安装包mysql-5.6.36-linux-glibc2.5-x86_
groupadd -r mysql
useradd -g mysql -r -s /sbin/nologin mysql
tar -zxvf mysql-5.6.36-linux-glibc2.5-x86_ -C /usr/local
cd /usr/local
ln -sv mysql-5.6.36-linux-glibc2.5-x86_64 mysql
cd mysql
chown -sql ./*
mkdir /data/mydata -p
chown -sql /data/mydata
mkdir /data/binlogs
chown -sql /data/binlogs
cd /usr/local
scripts/mysql_install_db --datadir=/data/mydata --user=mysql
将服务脚本拷贝到启动项
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
cp myf /etc/myf
vim /etc/myf
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4
[mysqld]
port = 3306
innodb_file_per_table = 1
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
default_storage_engine = InnoDB
skip-name-resolve
skip-external-locking
datadir = /data/mydata
log-bin=/data/binlogs/master-bin
binlog_format=row
socket=/tmp/mysql.sock
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
mysql下载的zip版本安装步骤key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
# 启动服务
service mysqld start
删除匿名⽤户,配置root密码
mysql> update user set password=PASSWORD('AJaC7uiKkYxbytGiEJBn') where user='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> flush privileges;
通过以下⽅式安装LAP
yum install httpd php -y
(2)开机⾃启动httpd,mysqld
chkconfig httpd on
chkconfig mysqld on
(3)安装lepus server需要的依赖包
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
(4)配置httpd并启动
# vim /etc/httpd/f
# 修改默认的ServerName
ServerName localhost:8090
监听8090端⼝
Listen 8090
启动httpd服务
# service httpd start
(5)配置php
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
验证lamp环境是否Ok
vim /var/www/html/info.php
<?php
phpinfo();
>
访问ip/info.php看是否打印lamp环境信息
(7) 安装MySQLdb-python,解压后,编辑site.cfg,到mysql_config,把#号去掉,并指定mysql_config的路径
mkdir lepus 
wget github/farcepest/MySQLdb1/archive/MySQLdb-1.2.5.zip
unzip MySQLdb-python.zip
[root@u04ck04 lepus]# cd MySQLdb1-MySQLdb-1.2.5/
[root@u04ck04 MySQLdb1-MySQLdb-1.2.5]# which mysql_config
/usr/local/mysql/bin/mysql_config(此处查mysql_config命令的所在,不同⽅式安装的mysql,可能存在不同的地⽅!)[root@vpn MySQLdb1-master]# pwd
/data/mysqldata/lepus/MySQLdb1-MySQLdb-1.2.5
[root@vpn MySQLdb1-master]# vi site.cfg
mysql_config = /usr/local/mysql/bin/mysql_config    (位置填写上⼀个查到的位置)
# yum install -y python-pip
# python setup.py build
# python setup.py install
(8)安装redis驱动,如果没有redis需要监控可以跳过此步骤:
# cd /usr/local/src/
# wget /packages/source/r/redis/redis-2.10.
# tar xf redis-2.10.
# cd redis-2.10.3
# python setup.py install
(9)安装pymongo模块(如果没有需要监控的Mongodb可以跳过)
# wget github/mongodb/mongo-python-driver/archive/2.7.2.zip
# upzip 2.7.2.zip
# cd mongo-python-driver-2.7.2
# python setup.py install
测试各个模块安装是否正常运⾏
[root@u04ck04 lepus]# pwd
/
usr/local/lepus
[root@u04ck04 lepus]# python test_driver_mysql.py
MySQL python drivier is ok!
[root@u04ck04 lepus]# python test_driver_mongodb.py
MongoDB python drivier is ok!
[root@u04ck04 lepus]# python test_driver_redis.py
Redis python drivier is ok!
⼆、安装Lepus采集器
(1) 下载Lepus软件包下载地址:/soft/17
然后登录数据库创建lepus数据库和MySQL⽤户
# pwd
/
usr/local/src
# unzip Lepus.zip
#创建lepus库并授权
mysql -uroot -pAJaC7uiKkYxbytGiEJBn -e "create database lepus default character set utf8;"
mysql -uroot -pAJaC7uiKkYxbytGiEJBn -e "grant select,insert,update,delete,create on lepus.* to 'lepus'@'localhost' identified by 'lepus';"
mysql -uroot -pAJaC7uiKkYxbytGiEJBn -e "grant select,insert,update,delete,create on lepus.* to 'lepus'@'127.0.0.1' identified by 'lepus';"
mysql -uroot -pAJaC7uiKkYxbytGiEJBn -e "flush privileges"
(2) 导⼊lepus数据库初始化数据,建议使⽤root⽤户导,进⼊到lepus解包以后的⽬录
cd /usr/local/src/lepus_v3.7/sql
mysql -uroot -pAJaC7uiKkYxbytGiEJBn lepus < lepus_table.sql
mysql -uroot -pAJaC7uiKkYxbytGiEJBn lepus < lepus_data.sql
验证表是否创建成功
# mysql -uroot -pAJaC7uiKkYxbytGiEJBn -e "use lepus;show tables;" Warning: Using a password on the command line interface can be insecure. +---------------------------------+
| Tables_in_lepus |
+---------------------------------+
| admin_log |
| admin_menu |
| admin_privilege |
| admin_role |
| admin_role_privilege |
| admin_user |
| admin_user_role |
| alarm |
| alarm_history |
| alarm_temp |
| db_servers_mongodb |
| db_servers_mysql |
| db_servers_oracle |
| db_servers_os |
| db_servers_redis |
| db_status |
| lepus_status |
| mongodb_status |
| mongodb_status_history |
| mysql_bigtable |
| mysql_bigtable_history |
| mysql_connected |
| mysql_processlist |
| mysql_replication |
| mysql_replication_history |
| mysql_slow_query_review |
| mysql_slow_query_review_history |
| mysql_slow_query_sendmail_log |
| mysql_status |
| mysql_status_history |
| options |
| oracle_status |
| oracle_status_history |
| oracle_tablespace |
| oracle_tablespace_history |
| os_disk |
| os_disk_history |
| os_diskio |
| os_diskio_history |
| os_net |
| os_net_history |
| os_status |
| os_status_history |
| redis_replication |
| redis_replication_history |
| redis_status |
| redis_status_history |
+---------------------------------+

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。