1.Lepus安裝須要Lamp環境,Lamp環境的安裝我的認爲比較費勁,XAMPP的一鍵部署LAMP環境省心省力, lepus官網手冊也建議採用XAMPP的方式安裝,lepus也是在XAMPP上進行研發的,看官網安裝手冊,看了半天也沒成功,通過多日奮戰,終於實現lepus的快速,輕量化部署,並能用ie瀏覽器監控。php
注意xampp會把apache,mysql,php都安裝,因此要在乾淨的環境中進行安裝,以避免安裝兩個mysql,兩個mysql也是能夠的,我這裏是乾淨的環境。html
2.LAMP環境搭建python
安裝XAMPPmysql
Xampp下載地址:https://www.apachefriends.org/download.htmllinux
注意你的版本號,高版本的XAMPP中可能不是Mysql而是MariaDBnginx
[root@HE3home]# chmod +x xampp-linux-x64-1.8.2-5-installer.runweb
[root@HE3home]# ./xampp-linux-x64-1.8.2-5-installer.runredis
[root@HE3home]# /opt/lampp/lampp startsql
[root@HE3 home]#vi /etc/profile 追加環境變量mongodb
export PATH=$PATH:/opt/lampp/bin/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lampp/lib
[root@HE3home]#source /etc/profile
3.安裝Lepus
下載MySQLdb-python.zip是lepus安裝後監控mysql所必需的 可加入天兔羣去下載這個壓縮包,若是不能下載,我在本文最後的附件中上傳了
[root@HE3 home]#unzip MySQLdb-python.zip
[root@HE3 home]# cd MySQLdb1-master/
[root@HE3MySQLdb1-master]# which mysql_config
/opt/lampp/bin/mysql_config
[root@HE3MySQLdb1-master]# vi site.cfg
mysql_config= /opt/lampp/bin/mysql_config
[root@HE3~]#yum install gcc libffi-devel python-devel openssl-devel
[root@HE3~]# yum install urpmi xterm
[root@HE3MySQLdb1-master]# python setup.py build
[root@HE3MySQLdb1-master]# python setup.py install
python setup.py build會出錯
wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
tar xf distribute-0.6.35.tar.gz
cd distribute-0.6.35
python setup.py install
安裝完distribute 就在python setup.py build就不會出錯
數據庫配置
監控庫
mysql> create database lepus default character set utf8;
mysql>grant select,insert,update,delete,create on lepus.* to 'lepus_user'@'%' identified by 'MANAGER';
mysql> flush privileges;
[root@HE3lepus_v3.7]# mysql -uroot -p lepus < sql/lepus_table.sql
[root@HE3lepus_v3.7]# mysql -uroot -p lepus < 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 *.* to'lepus_monitor'@'%' identified by 'MANAGER';
mysql> flush privileges;
lepus配置
[root@HE3lepus_v3.7]# cd python/
[root@HE3 python]#chmod +x install.sh
[root@HE3 python]#./install.sh
[root@HE3 python]#vi /usr/local/lepus/etc/config.ini
###監控機MySQL數據庫鏈接地址###
[monitor_server]
host="127.0.0.1"
port=3306
user="lepus_user"
passwd="MANAGER"
dbname="lepus"
拷貝前先備份以防萬一
[root@HE3lepus_v3.7]# cp -r php/* /opt/lampp/htdocs/
[root@HE3lepus_v3.7]# mkdir -p /opt/lampp/htdocs/application/config/
[root@HE3lepus_v3.7]# vi /opt/lampp/htdocs/application/config/database.php
$db['default']['hostname'] = '192.168.197.136';
$db['default']['port'] = '3306';
$db['default']['username'] = 'lepus_user';
$db['default']['password'] = 'MANAGER';
$db['default']['database'] = 'lepus';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
[root@HE3lepus_v3.7]# cd /usr/local/lepus/
[root@HE3 lepus]#lepus start
lepus server startsuccess!
---------------------redis----------------------
[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了
--redis頁面顯示權限拒絕
redis的php文件裏的權限的行都註釋了,就顯示出來了
--------------------mysql--------------------
---MySQL複製監控中沒法看圖形
vi /opt/lampp/htdocs/application/controllers/lp_mysql.php
337行,去掉'mysql/replication',改成parent::check_privilege();
原來爲parent::check_privilege('mysql/replication');
---修復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;
---修復mysql5.7複製監控沒數據
mysql> set global show_compatibility_56=on;
--------------------監控MongoDB報錯------------------
若是MongoDB沒有開啓認證,監控會報錯
2017-10-18 11:33:39 [WARNING] check mongodb xxxx:27017 : Authentication failed.
對於沒有開啓認證的MongoDB解決方案:
將check_mongodb.py中的 db.authenticate(user,passwd)註釋掉便可登陸無需用戶名密碼的MongoDB
----------------------------nginx.conf-------------------------
默認用nginx跑web管理臺會有問題,須要加個rewrite
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } }
加入後仍然報 File not found....錯誤,能不能把一個正常發佈在nginx下的lepus,nginx.conf配置文件發出來,共享下
vijay2015 @: 1022xiyang 2015年04月28日 09:29:161#
我這邊加過以後就OK了配置以下:
server {
listen 8001;
server_name lepus;
location / {
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
root /usr/local/www;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/local/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
~
安裝Lep