1. 程式人生 > >天兔(Lepus)數據庫監控系統安裝筆記

天兔(Lepus)數據庫監控系統安裝筆記

req color .html cte 設置 %s 找到 bre upd

天兔(Lepus)數據庫監控系統安裝筆記

一、部署:
本次操作系統:centos6.9 IP:192.168.153.145
Lepus_v3.8_beta
MySQL-python-1.2.5
xampp-linux-x64-1.8.2-5-installer.run

Lepus安裝需要Lamp環境,lepus官網手冊也建議采用XAMPP的方式安裝,XAMPP的一鍵部署LAMP環境省心省力
註意:xampp會把apache,mysql,php都安裝,所以建議幹凈的環境中進行安裝,高版本的XAMPP中可能不是Mysql而是MariaDB

1.安裝XAMPP:
本次采用的是:xampp-linux-x64-1.8
.2-5-installer.run 本次放在/opt下面了。 [root@localhost opt]# wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/1.8.2/xampp-linux-x64-1.8.2-5-installer.run/download [root@localhost opt]# chmod +x xampp-linux-x64-1.8.2-5-installer.run [root@localhost opt]# ./chmod +x xampp-linux-x64-1.8.2-5-installer.run [root@localhost opt]#
/opt/lampp/lampp start [root@localhost opt]# vim /etc/profile #追加環境變量 export PATH=$PATH:/opt/lampp/bin/ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lampp/lib [root@localhost opt]# source /etc/profile
2.安裝MySQL-python,本次下載的 MySQL-python-1.2.5.zip [下載網址 https://pypi.org/project/MySQL-python/]
[root@localhost opt]# wget
https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip [root@localhost opt]# unzip MySQL-python-1.2.5.zip [root@localhost opt]# cd MySQL-python-1.2.5 [root@localhost MySQL-python-1.2.5]# which mysql_config /opt/lampp/bin/mysql_config [root@localhost MySQL-python-1.2.5]# vim site.cfg #添加內容 mysql_config = /opt/lampp/bin/mysql_config [root@localhost MySQL-python-1.2.5]# python setup.py build [root@localhost MySQL-python-1.2.5]# python setup.py install
3.安裝lepus:[Lepus數據庫企業監控系統3.8 Beta版本官方下載.zip ,lepus官網下載http://www.lepus.cc/soft/download/18]
[root@localhost opt]# unzip Lepus數據庫企業監控系統3.8 Beta版本官方下載.zip
#解壓後,先配置mysql數據庫。
    mysql> create database lepus default character set utf8;
    mysql>grant select,insert,update,delete,create on lepus.* to lepus_user@% identified by 密碼;
    mysql> flush privileges;
[root@localhost opt]# mysql -uroot -p lepus < /opt/Lepus_v3.8_beta/sql/lepus_table.sql
[root@localhost opt]# mysql -uroot -p lepus < /opt/Lepus_v3.8_beta/sql/lepus_data.sql
    mysql>use lepus
    mysql>alter table mysql_status modify column max_connect_errors bigint(18);
    mysql>alter table mysql_status_history modify column max_connect_errors bigint(18);
#添加被監控主機建議建立數據庫賬號,如備機上的數據庫,創建lepus_monitor賬號即可
    mysql> grant select,super,process,reload,show databases,replication client on *.* tolepus_monitor@% identified by 密碼;
    mysql> flush privileges;
[root@localhost opt]# cd Lepus_v3.8_beta/python/
[root@localhost python]# chmod +x install.sh
[root@localhost python]# ./install.sh
[root@localhost python]# vim /usr/local/lepus/etc/config.ini
[monitor_server]
host="192.168.153.145"
port=3306
user="lepus"
passwd="密碼"
dbname="lepus"
[root@localhost opt]# cp -r /opt/Lepus_v3.8_beta/php/* /opt/lampp/htdocs/
[root@localhost opt]# vim /opt/lampp/htdocs/application/config/database.php
$db[‘default‘][‘hostname‘]= ‘192.168.153.145‘;
$db[‘default‘][‘port‘]     = ‘3306‘;
$db[‘default‘][‘username‘]= ‘lepus‘;
$db[‘default‘][‘password‘]= ‘密碼‘;
$db[‘default‘][‘database‘]= ‘lepus‘;
$db[‘default‘][‘dbdriver‘]= ‘mysql‘;
[root@localhost opt]# cd /usr/local/lepus/
[root@localhost opt]# lepus start
lepus server startsuccess!
    #有問題看日誌
    [root@localhost opt]# tail -f /usr/local/lepus/nohup.out 
    [root@localhost opt]# tail -f /usr/local/lepus/logs/lepus.log
4.配置http
vim /opt/lampp/etc/extra/httpd-vhosts.conf 刪除原有的,改為
<VirtualHost*:80>
    AddDefaultCharset UTF-8
    DocumentRoot "/opt/lampp/htdocs"
    ServerName xxxx.com #此處自定義,與/etc/hosts參照[可選]
    <Directory"/opt/lampp/htdocs">
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>
    ErrorLog"|/usr/local/apache/bin/rotatelogs /home/logs/apache/php_%Y%m%d_error.log86400 480"
    CustomLog"|/usr/local/apache/bin/rotatelogs /home/logs/apache/php_%Y%m%d_access.log86400 480" common
</VirtualHost>
通過瀏覽器輸入192.168.153.145打開監控界面,即可登錄系統。默認管理員賬號密碼admin/Lepusadmin登錄後請修改管理員密碼,增加普通賬號。
5.設置開機啟動:
#讓xampp開機自動啟動
sudo ln -s /opt/lampp/lampp /etc/init.d/lampp
sudo chkconfig --add lampp

二、擴展閱讀:安裝過程中可能遇到的報錯如:     

1.安裝好lepus之後啟動 lepus start
lepus server start fail!
解決辦法: 看日誌tail -f /usr/local/lepus/logs/lepus.log 發現錯誤:
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/bin/bash: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
egrep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
解決辦法:有人說少了glibc包,32/64的都安裝了,然並沒有用。 vim /opt/lampp/lampp找到export LD_ASSUME_KERNEL=2.2.5這一行,並修改內容為export LD_ASSUME_KERNEL=2.8.0,保存退出就可以解決了。當然修改為不低於2.6.32的其他值也可以。找了下這個設置的資料解釋,原來這個配置是為了舊操作系統的一些兼容性問題。【參考資料https://www.cnblogs.com/shengulong/p/7262346.html?utm_source=itdadao&utm_medium=referral】

2.安裝MySQL-python過程中,如:ImportError: No module named setuptools
解決辦法:setuptools安裝完成之後再安裝[https://files.pythonhosted.org/packages/6f/10/5398a054e63ce97921913052fde13ebf332a3a4104c50c4d7be9c465930e/setuptools-26.1.1.zip]
[root@localhost opt]# cd setuptools-26.1.1
[root@localhost setuptools-26.1.1]# python setup.py install

3.lepus安裝過程中如果報錯,根據報錯信息來操作比如:
ln -s /usr/lib64/libssl.so.1.0.1e /usr/lib64/libssl.so.1.0.0
ln -s /usr/lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so.1.0.0


4.[root@HE3 lepus]#vi check_redis.py
148
149 except Exception, e:
150 logger_msg="check redis %s:%s : %s" %(host,port,e)
151 #logger.warning(logger_msg)
152
153 try:
154 connect=0
155 sql="insert into redis_status(server_id,host,port,tags,connect) values(% s,%s,%s,%s,%s)"

151行的註釋掉就解決redis不能監控slave的bug了

5.---MySQL復制監控中無法看圖形
vi /opt/lampp/htdocs/application/controllers/lp_mysql.php
337行,去掉‘mysql/replication‘,改為parent::check_privilege();
原來為parent::check_privilege(‘mysql/replication‘);

6.---修復mysql復制圖表時間偏移導致數據不準確
影響:線型圖表時間偏移
修復:修改vi /opt/lampp/htdocs/application/controllers/lp_mysql.php
352行找到public function replication()的$chart_reslut[$i][‘delay‘]=$dbdata[‘delay‘],修該為:
$chart_reslut[$i][‘delay‘] = !empty($dbdata[‘delay‘]) ? $dbdata[‘delay‘] : 0;

7.---修復mysql5.7復制監控沒數據
mysql> set global show_compatibility_56=on;

8.默認用nginx跑web管理臺會有問題,需要加個rewrite
location /
{
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
加入後仍然報 File not found....錯誤,nginx.conf配置文件進一步檢查。

天兔(Lepus)數據庫監控系統安裝筆記