lepus監控數據庫
192.168.1.128 mini2
需要的所有軟件包:
https://pan.baidu.com/s/1uAZqYnST0VwoCLL3Ir3FCg
Lepus安裝需要Lamp環境
安裝LAMP:
關閉selinux
[root@mini2 ~]# vim /etc/selinux/config
SELINUX=disabled
[root@mini2 ~]# setenforce 0
[root@mini2 ~]# yum install -y httpd php mariadb mariadb-server php-mysql
[root@mini2 ~]#yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
啟動服務
[root@mini2 ~]# systemctl start httpd
[root@mini2 ~]# systemctl start mariadb.service
[root@mini2 ~]# systemctl enable mariadb.service
[root@mini2 ~]# systemctl enable httpd
mariadb安裝完是沒有密碼的,需要設置密碼
[root@mini2 ~]# mysqladmin -uroot -p password '123'
Enter password:
測試一下:php是否能連接數據庫
[root@mini2 ~]# vim /var/www/html/index.php
<?php
$link=mysql_connect("localhost","root","123");
if(!$link) echo "FAILD!連接錯誤,用戶名密碼不對";
else echo "OK!可以連接";
?>
[root@mini2 ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@mini2 ~]# firewall-cmd --reload
success
安裝 MySQLdb for python (如果需要監控MySQL則必須安裝)
安裝MySQLdb for python依賴包
[root@mini2 ~]# yum -y install gcc libffi-devel python-devel openssl-devel mysql-devel zlib-devel
[root@mini2 src]# ls
distribute-0.6.28.tar.gz Lepus.zip MySQLdb-python.zip.zip
[root@mini2 src]# unzip MySQLdb-python.zip.zip
[root@mini2 src]# which mysql_config
/usr/bin/mysql_config
[root@mini2 src]# cd MySQLdb1-master/
[root@mini2 MySQLdb1-master]# vim site.cfg
mysql_config = /usr/bin/mysql_config #修改後
[root@mini2 MySQLdb1-master]# python setup.py build
報錯意思urllib2.HTTP錯誤403:需要SSL
解決辦法:
[root@mini2 MySQLdb1-master]# cd ..
[root@mini2 src]# tar zxf distribute-0.6.28.tar.gz
[root@mini2 src]# cd distribute-0.6.28/
[root@mini2 distribute-0.6.28]# python setup.py build
[root@mini2 distribute-0.6.28]# python setup.py install
[root@mini2 distribute-0.6.28]# cd ../MySQLdb1-master/
[root@mini2 MySQLdb1-master]# python setup.py build
[root@mini2 MySQLdb1-master]# python setup.py install #安裝成功
安裝lepus
[root@mini2 MySQLdb1-master]# cd ..
[root@mini2 src]# unzip Lepus.zip
[root@mini2 src]# cd Lepus_v3.8_beta/
在監控機創建監控數據庫,並授權。
[root@mini2 Lepus_v3.8_beta]# mysql -uroot -p123
MariaDB [(none)]> create database lepus default character set utf8;
MariaDB [(none)]> grant select,insert,update,delete,create on lepus.* to 'lepus_user'@'%' identified by '123';
導入表和數據
[root@mini2 Lepus_v3.8_beta]# mysql -uroot -p123 lepus < sql/lepus_table.sql
[root@mini2 Lepus_v3.8_beta]# mysql -uroot -p123 lepus < sql/lepus_data.sql
登錄數據庫更改表的信息
MariaDB [(none)]> use lepus
MariaDB [lepus]> alter table mysql_status modify column max_connect_errors bigint(18);
MariaDB [lepus]> alter table mysql_status_history modify column max_connect_errors bigint(18);
被監控數據庫,本次監控的是本機
MariaDB [lepus]> grant select,super,process,reload,show databases,replication client on *.* to 'lepus_monitor'@'%' identified by '123';
進入到Lepus軟件包的python文件夾
[root@mini2 Lepus_v3.8_beta]# cd python/
授予install.sh可執行權限
[root@mini2 python]# chmod +x install.sh
執行安裝
[root@mini2 python]# ./install.sh
修改配置文件
[root@mini2 python]# vim /usr/local/lepus/etc/config.ini
###監控機MySQL數據庫連接地址###
[monitor_server]
host="192.168.1.129"
port=3306
user="lepus_user"
passwd="123"
dbname="lepus
[root@mini2 python]# ln -s /usr/local/lepus/lepus /etc/init.d/
[root@mini2 python]# service lepus start
lepus server start success! #服務啟動成功
安裝WEB管理臺
[root@mini2 Lepus_v3.8_beta]# cp -rf php/* /var/www/html/
cp: overwrite ‘/var/www/html/index.php’? y
[root@mini2 Lepus_v3.8_beta]# vim /var/www/html/application/config/database.php
通過瀏覽器打開監控界面,即可登錄系統。.默認管理員賬號密碼admin/Lepusadmin登錄後請修改管理員密碼,增加普通賬號。
監控成功
監控mini1mysql數據庫
[root@mini1 ~]# mysql -uroot -p123456
mysql> grant select,super,process,reload,show databases,replication client on *.* to 'lepus_monitor'@'%' identified by '123';
也需要關閉selinux
[root@mini1 ~]# setenforce 0
[root@mini2 Lepus_v3.8_beta]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.128 mini1.centos7.com
192.168.1.129 mini2.centos7.com
[root@mini1 ~]# firewall-cmd --permanent --add-port=3306/tcp
[root@mini1 ~]# firewall-cmd --reload
[root@mini2 Lepus_v3.8_beta]# service lepus stop
[root@mini2 Lepus_v3.8_beta]# service lepus start
[root@mini2 Lepus_v3.8_beta]#
lepus監控數據庫