轉載自:https://blog.csdn.net/m0_38039437/article/details/79613260php
首先向你們闡述LAMP(Linux+Apache+MySQL +PHP)基礎環境配置。html
配置LAMP基礎環境的方式有不少種,最簡單的方式有yum安裝、RPM包安裝等方式、安裝集成環境包(例如lampp/xampp等)。您也能夠手動編譯安裝相關軟件。這裏咱們不推薦使用YUM進行安裝,YUM安裝的PHP環境能夠由於缺乏某些依賴包致使500錯誤。若是你有能力,能夠進行編譯安裝,按照須要的模塊編譯PHP和MYSQL數據庫,這種方式也是目前大型WEB推薦的方式。若是你沒法進行編譯安裝,咱們推薦你使用Xampp集成環境包進行安裝,xampp是一個可靠的穩定的lamp套件,目前已被諸多公司用於生產服務器的部署,目前Lepus的開發環境,測試環境以及線上官網的WEB環境,都是運行在xampp環境下面,而且一直都是穩定的。python
Xampp下載地址:https://www.apachefriends.org/download.htmlmysql
Xampp幫助文檔:https://www.apachefriends.org/faq_linux.htmllinux
PS:注意你的版本號,高版本的XAMPP中不是MySQL而是MariaDB。redis
基礎環境sql
1
2
3
4
|
$ uname -r
3.10.0-327.28.3.el7.x86_64
$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
|
安裝XAMPPmongodb
對於安裝XAMPP須要特別注意,lepus目前版本3.7和3.8好像只對PHP 5支持比較完美,因此安裝XAMPP時最好安裝5.5的版本,本人測試了PHP 5.五、PHP 5.六、PHP 7.2只有PHP5可用,而且對於PHP 7連驅動程序都要改變一下。若是你不想踩坑,最好全部軟件版本對應本博客來搭建lepus。固然,後面可能會支持更高版本的PHP,這個須要你進行測試。shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
$ wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/5.5.38/xampp-linux-x64-5.5.38-3-installer.run
$ chmod +x xampp-linux-x64-5.5.38-3-installer.run
$ ./xampp-linux-x64-5.5.38-3-installer.run
----------------------------------------------------------------------------
Welcome to the XAMPP Setup Wizard.
----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.
XAMPP Core Files : Y (Cannot be edited)
XAMPP Developer Files [Y/n] :y
Is the selection above correct? [Y/n]: y
----------------------------------------------------------------------------
Installation Directory
XAMPP will be installed to /opt/lampp
Press [Enter] to continue:
----------------------------------------------------------------------------
Setup is now ready to begin installing XAMPP on your computer.
Do you want to continue? [Y/n]: y
----------------------------------------------------------------------------
Please wait while Setup installs XAMPP on your computer.
Installing
0% ______________ 50% ______________ 100%
#########################################
----------------------------------------------------------------------------
Setup has finished installing XAMPP on your computer.
|
追加環境變量(可執行文件、庫文件和頭文件)數據庫
1
2
3
4
|
$ cat /etc/profile
export PATH=$PATH:/opt/lampp/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lampp/lib
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/opt/lampp/include
|
1
|
$ source /etc/profile
|
啓動LAMP
1
2
3
4
5
|
$ /opt/lampp/lampp start
Starting XAMPP for Linux 5.5.38-3...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...ok.
|
PS:lampp命令支持stop、status、start、restart命令。
讓xampp開機自動啓動
1
2
|
$ ln -s /opt/lampp/lampp /etc/init.d/lampp
$ chkconfig --add lampp
|
簡單介紹一下XAMPP組件配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# HTTPD主配置文件;
/opt/lampp/etc/httpd.conf
# PHP主配置文件;
/opt/lampp/etc/php.ini
# MariaDB主配置文件;
/opt/lampp/etc/my.cnf
# MariaDB數據目錄;
/opt/lampp/var/mysql
# 全部日誌目錄;
/opt/lampp/logs/
|
PS:若是想從新安裝,只須要刪除/opt/lampp便可。
首先安裝Python環境(Python版本要求爲Python2.6以上,不支持Python3)
其次安裝數據庫鏈接Python的驅動包
1. 安裝MySQLdb for python (必須安裝)
MySQLdb爲Python鏈接和操做MySQL的類庫,若是您準備使用lepus系統監控MySQL數據庫,那麼該模塊必須安裝。http://cdn.lepus.cc/cdncache/software/MySQLdb-python.zip已經中止訪問,能夠在此連接下載:
https://down.51cto.com/data/2367660
1
2
3
4
5
6
7
8
9
10
|
$ wget http://cdn.lepus.cc/cdncache/software/MySQLdb-python.zip
$ unzip MySQLdb-python.zip
$ cd MySQLdb1-master/
$ which mysql_config
/opt/lampp/bin/mysql_config
$ vim site.cfg
mysql_config = /opt/lampp/bin/mysql_config
$ yum install gcc libffi-devel python-devel openssl-devel urpmi xterm
$ python setup.py build
$ python setup.py install
|
執行python setup.py build報錯:
2. 安裝Pymongo for python (若是須要監控Mongodb則必須安裝)
pymongo爲Python鏈接和操做MongoDB的類庫,若是您準備使用lepus系統監控MongoDBs數據庫,那麼該模塊必須安裝。
安裝步驟以下:
1
2
3
4
|
$ wget http://cdn.lepus.cc/cdncache/software/pymongo-2.7.tar.gz
$ tar zxvf pymongo-2.7.tar.gz
$ cd pymongo-2.7
$ python setup.py install
|
3. 安裝Redis 驅動 (若是須要監控Redis則必須安裝)
1
2
3
4
|
$ wget http://cdn.lepus.cc/cdncache/software/redis-py-2.10.3.tar.gz
$ tar zxvf redis-py-2.10.3.tar.gz
$ cd redis-2.10.3/
$ python setup.py install
|
4. 測試各個驅動是否正常運行
1
2
3
4
5
6
|
$ python test_driver_mysql.py
MySQL python drivier is ok!
$ python test_driver_mongodb.py
MongoDB python drivier is ok!
$ python test_driver_redis.py
Redis python drivier is ok!
|
安裝Lepus監控系統,在安裝Lepus系統以前,請先根據前面內容安裝LAMP和Python運行基礎環境。
1)軟件包下載:http://www.lepus.cc/soft/18,上傳軟件包到監控機服務器並解壓縮軟件到您的系統
1
2
|
$ unzip Lepus3.8_Beta.zip
$ cd Lepus_v3.8_beta
|
2)在監控機建立監控數據庫並受權
1
2
3
4
|
mysql> create database lepus default character set utf8;
mysql> grant select,insert,update,delete,create on lepus.* to 'lepus_user'@'localhost' identified by '123456';
mysql> grant select,insert,update,delete,create on lepus.* to 'lepus_user'@'%' identified by '123456';
mysql> flush privileges;
|
導入SQL文件夾裏的SQL文件(表結構和數據文件)
1
2
|
$ mysql lepus < sql/lepus_table.sql
$ mysql lepus < sql/lepus_data.sql
|
被監控庫的數據庫只需建立lepus_monitor帳號便可
mysql> grant select,super,process,reload,show databases,replication client on *.* to'lepus_monitor'@'%' identified by 'MANAGER';
mysql> flush privileges;
4)安裝Lpeus程序
進入到軟件包的python文件夾
1
|
$ cd python/
|
授予install.sh可執行權限
1
|
$ chmod +x install.sh
|
執行安裝
1
2
3
4
5
6
7
8
|
$ ./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.
|
5)修改配置文件
進入到安裝目錄,默認爲/usr/local/lepus。
1
2
3
4
5
6
7
8
9
|
$ cd /usr/local/lepus/
$ cat etc/config.ini
###監控機MySQL數據庫鏈接地址###
[monitor_server]
host="127.0.0.1"
port=3306
user="lepus_user"
passwd="123456"
dbname="lepus"
|
6)啓動Lepus (可選)
此時,你能夠執行啓動命令啓動lepus採集進程。
1
2
3
4
|
$ lepus start
lepus server start success!
$ lepus status
lepus server is running...
|
可是由於沒有添加主機,因此查看日誌會看到以下提示,屬於正常提示。您也能夠在部署完Lepus WEB控制檯後再進行啓動。
1
2
3
4
5
6
7
8
9
10
|
$ tail -f logs/lepus.log
2017-02-09 18:57:19 [INFO] check mysql controller started.
2017-02-09 18:57:19 [WARNING] check mysql: not found any servers
2017-02-09 18:57:19 [INFO] check mysql controller finished.
2017-02-09 18:57:37 [INFO] alarm controller started.
2017-02-09 18:57:37 [INFO] alarm controller finished.
2017-02-09 18:58:20 [INFO] check mysql controller started.
2017-02-09 18:58:20 [WARNING] check mysql: not found any servers
2017-02-09 18:58:20 [INFO] check mysql controller finished.
2017-02-09 18:58:20 [INFO] check mysql controller finished.
|
Lepus採集程序安裝完畢!
複製PHP文件夾裏的文件到Apache對應的網站虛擬目錄(備註:根本不一樣的安裝方式,這個目錄是不同的,若是採用xampp安裝的Apache環境,則默認程序目錄爲/opt/lampp/htdocs/),例如:
1
|
$ cp -fr /root/lepus/Lepus_v3.8_beta/php/* /opt/lampp/htdocs/
|
打開application/config/database.php文件,修改PHP鏈接監控服務器的數據庫信息.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
$ cat /opt/lampp/htdocs/application/config/database.php
$db['default']['hostname'] = '127.0.0.1';
$db['default']['port'] = '3306';
$db['default']['username'] = 'lepus_user';
$db['default']['password'] = '123456';
$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;
|
9)登陸進行添加主機和監控
經過瀏覽器輸入IP地址或域名打開監控界面,便可登陸系統。.默認管理員帳號密碼admin/Lepusadmin登陸後請修改管理員密碼,增長普通帳號。
須要在被監控端安裝一個具備all權限的用戶(收集慢查詢日誌也須要高權限用戶)。
參考:
http://www.lepus.cc/manual/index
http://www.dba-china.com/topic/230