試用了一下Lepus監(jiān)控系統(tǒng)秕狰,感覺不錯(cuò)。記錄一下安裝過程躁染,留個(gè)備份鸣哀。
搭建的環(huán)境:
<pre>
CentOS release 6.6 (Final)
</pre>
我這里是用root帳號(hào)登錄搭建環(huán)境的。
首先Lepus監(jiān)控環(huán)境是通過bs提供服務(wù)的褐啡,使用的是php的ci框架诺舔。這里需要在linux上搭建一個(gè)LAMP環(huán)境。(需要騷等片刻)
<pre>
yum install mysql-server httpd php -y
</pre>
設(shè)置2個(gè)守護(hù)進(jìn)程開機(jī)自啟動(dòng)
<pre>
chkconfig httpd on
chkconfig mysqld on
</pre>
安裝相關(guān)依賴包(喝杯茶备畦,休息一下低飒。)
<pre>
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
</pre>
安裝unzip(如果沒有unzip的話,后面會(huì)用到)
<pre>
yum install unzip
</pre>
這個(gè)時(shí)候懂盐,apache已經(jīng)安裝好了褥赊。由于服務(wù)器在外網(wǎng),不能隨便在80端口發(fā)布web站莉恼,所以我們把端口默認(rèn)改成8080拌喉。
<pre>
vim /etc/httpd/conf/httpd.conf
修改
Listen 80
Listen 8080
</pre>
啟動(dòng)http服務(wù)先:
<pre>service httpd start</pre>
網(wǎng)絡(luò)訪問一下:http://xx.xx.xx.xx:8080 ,發(fā)現(xiàn)不能訪問俐银。嗯尿背,防火墻開著呢。
開啟一下8080端口捶惜,順便把3306端口也開了田藐。
<pre>
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
service iptables save
</pre>
然后檢查一下iptables文件,看看
<pre>
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
</pre>
這里要注意一下吱七,3306和8080的數(shù)據(jù)必須在-A INPUT -j REJECT --reject-with icmp-host-prohibited的前面汽久。修改一下順序,如下:
<pre>
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [5:660]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
</pre>
備注:vim中踊餐,yy復(fù)制一行景醇,p粘貼,dd刪除一行
改完之后吝岭,策略并沒有直接生效三痰,需要關(guān)閉重開一下
<pre>
service iptables stop
service iptables start
</pre>
此時(shí)再網(wǎng)絡(luò)訪問一下:http://xx.xx.xx.xx:8080吧寺,發(fā)現(xiàn)了可愛的apache。
配置一下PHP:
<pre>
[root@localhost ~]# sed -i "s/;date.timezone =/date.timezone = Asia/Shanghai/g" /etc/php.ini
[root@localhost ~]# sed -i "s#max_execution_time = 30#max_execution_time = 300#g" /etc/php.ini
[root@localhost ~]# sed -i "s#post_max_size = 8M#post_max_size = 32M#g" /etc/php.ini
[root@localhost ~]# sed -i "s#max_input_time = 60#max_input_time = 300#g" /etc/php.ini
[root@localhost ~]# sed -i "s#memory_limit = 128M#memory_limit = 128M#g" /etc/php.ini
[root@localhost ~]# sed -i "/;mbstring.func_overload = 0/ambstring.func_overload = 2\n" /etc/php.ini
[root@localhost ~]#
</pre>
安裝python2.7
<pre>
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# wget https://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
[root@localhost src]# tar jxf Python-2.7.2.tar.bz2
[root@localhost src]# cd Python-2.7.2
[root@localhost Python-2.7.2]# ./configure --prefix=/usr/local/python2.7
[root@localhost Python-2.7.2]# make && make install
</pre>
查看一下python版本號(hào):
<pre>
[root@localhost Python-2.7.2]# python
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
exit()
</pre>
咦散劫?怎么還是系統(tǒng)自帶的2.66版本撮执?我們先看一下系統(tǒng)中有哪些python可執(zhí)行文件
<pre>
[root@localhost bin]# find / -name "python"
/usr/local/python2.7/bin/python
/usr/local/src/Python-2.7.2/python
/usr/bin/python
</pre>
可以看到,在/usr/bin/目錄下舷丹,有一個(gè)系統(tǒng)自帶的舊版python抒钱。我們把舊版本用重命名備份一下,然后把新版本連接到該bin目錄下颜凯。
<pre>
[root@localhost bin]# mv /usr/bin/python /usr/bin/python_2_6_6
[root@localhost bin]# ln -s /usr/local/python2.7/bin/python /usr/bin/python
[root@localhost bin]# python
Python 2.7.2 (default, Jan 16 2017, 16:21:48)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
</pre>
升級(jí)完python谋币,發(fā)現(xiàn)yum指令不能用了。
<pre>
[root@localhost src]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7.2 (default, Jan 16 2017, 16:21:48)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
</pre>
因?yàn)閥um默認(rèn)使用的pythom不支持2.7.2症概。咋辦蕾额?
我們要修改一下yum文件里面的python,指定到我們剛才備份的那個(gè)版本(python_2_6_6)彼城。
<pre>
vi /usr/bin/yum
修改
!/usr/bin/python
變成
!/usr/bin/python_2_6_6
</pre>
接下來安裝MySQLdb-python庫
<pre>
[root@localhost bin]# cd /usr/local/src/
[root@localhost src]# wget http://cdn.lepus.cc/cdncache/software/MySQLdb-python.zip
[root@localhost src]# unzip MySQLdb-python.zip
[root@localhost src]# cd MySQLdb1-master/
</pre>
這里需要把mysql_config配置一下
先看一下系統(tǒng)中的mysql的這個(gè)文件在哪诅蝶。
<pre>
[root@localhost MySQLdb1-master]# find / -name "mysql_config"
/usr/lib64/mysql/mysql_config
/usr/bin/mysql_config
</pre>
修改site.cfg文件,把當(dāng)前mysql_config的文件路徑寫對募壕。
<pre>
[root@localhost MySQLdb1-master]# cat site.cfg |grep "mysql_config"
The path to mysql_config.
Only use this if mysql_config is not on your PATH, or you have some weird
mysql_config = /usr/bin/mysql_config
</pre>
然后啟動(dòng)py的安裝腳本
<pre>
[root@localhost MySQLdb1-master]# python setup.py build
[root@localhost MySQLdb1-master]# python setup.py install
</pre>
接下來安裝Lepus采集器
先從官網(wǎng)上下載安裝包调炬。我這里下載的最新測試版(3.8beta),下面的下載地址根據(jù)當(dāng)前版本替換舱馅。
<pre>
[root@localhost src]# wget http://www.lepus.cc/soft/download/18
[root@localhost src]# unzip 18
[root@localhost src]# ls
18 Lepus_v3.8_beta MySQLdb1-master MySQLdb-python.zip Python-2.7.2 Python-2.7.2.tar.bz2
</pre>
在當(dāng)前機(jī)器上mysql中缰泡,創(chuàng)建支持lepus系統(tǒng)需要的數(shù)據(jù)庫,以及導(dǎo)入表結(jié)構(gòu)等等代嗤。(先將mysql初始化帳號(hào)root密碼123456)
<pre>
已經(jīng)配置過的mysql不需要這句初始化密碼命令
[root@localhost src]# mysqladmin -u root password '123456'
創(chuàng)建數(shù)據(jù)庫
[root@localhost src]# mysql -uroot -p123456 -e "create database lepus default character set utf8;"
[root@localhost src]# mysql -uroot -p123456 -e "grant select,insert,update,delete,create on lepus.* to 'lepus'@'localhost' identified by 'lepus';"
[root@localhost src]# mysql -uroot -p123456 -e "grant select,insert,update,delete,create on lepus.* to 'lepus'@'127.0.0.1' identified by 'lepus';"
[root@localhost src]# mysql -uroot -p123456 -e "flush privileges"
</pre>
導(dǎo)入表結(jié)構(gòu)棘钞,初始化數(shù)據(jù)
<pre>
[root@localhost sql]# pwd
/usr/local/src/Lepus_v3.8_beta/sql
[root@localhost sql]# mysql -uroot -p123456 lepus < lepus_table.sql
[root@localhost sql]# mysql -uroot -p123456 lepus < lepus_data.sql
</pre>
環(huán)境好了,接下來運(yùn)行安裝腳本干毅。到安裝包的python目錄宜猜。
<pre>
[root@localhost python]# pwd
/usr/local/src/Lepus_v3.8_beta/python
[root@localhost python]# sh 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.
[root@localhost python]#
</pre>
給腳本可執(zhí)行權(quán)限,修改數(shù)據(jù)庫配置文件
<pre>
[root@localhost python]# cd /usr/local/lepus/
[root@localhost lepus]# chmod +x *.sh
[root@localhost lepus]# chmod +x *.py
[root@localhost lepus]# vim etc/config.ini
監(jiān)控機(jī)MySQL數(shù)據(jù)庫連接地址###
[monitor_server]
host="localhost"
port=3306
user="lepus"
passwd="lepus"
dbname="lepus"
</pre>
啟動(dòng)lepus服務(wù)
<pre>
[root@localhost lepus]# lepus start
</pre>
現(xiàn)在基本安裝完畢硝逢。剩下的是安裝web管理系統(tǒng)姨拥。把php文件夾(/usr/local/src/Lepus_v3.8_beta/php)整個(gè)移動(dòng)到apache發(fā)布目錄下。(新版是php文件夾趴捅,舊版好像是www文件夾垫毙。)
<pre>
[root@localhost www]# cp -rf /usr/local/src/Lepus_v3.8_beta/php/* /var/www/html/
</pre>
修改php的數(shù)據(jù)庫配置文件霹疫。
<pre>
[root@localhost html]# cd /var/www/html/application/config/
[root@localhost config]# vim database.php
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['port'] = '3306';
$db['default']['username'] = 'lepus';
$db['default']['password'] = 'lepus';
$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;
</pre>
配置完畢之后拱绑,打開http://xx.xx.xx.xx:8080,發(fā)現(xiàn)系統(tǒng)已經(jīng)部署好了丽蝎。
默認(rèn)管理員賬號(hào)密碼admin/Lepusadmin
登錄一下猎拨,體驗(yàn)吧0蛎辍!红省!
搭建過程參照:http://www.cnblogs.com/xuanzhi201111/p/5200757.html