centos6.2lnmp環境下安裝zabbix(中文環境)並且監控客戶端
本來也是新學zabbix ,所以今天做個試驗,寫下試驗步驟
zabbix是一個基於WEB介面的提供分散式系統監視以及網路監視功能的企業級的開源解決方案。
特點:
– 支援多語言(包括中文)
– 免費開源
– 自動發現伺服器與網路裝置
– 分散式監視以及WEB集中管理功能
– 可以無agent監視
– 使用者安全認證和柔軟的授權方式
– 通過WEB介面設定或檢視監視結果
– email等通知功能
Zabbix主要功能:
– CPU負荷
– 記憶體使用
– 磁碟使用
– 網路狀況
– 埠監視
– 日誌監視
zabbix服務端192.168.0.19
zabbix客戶端192.168.0.20
都是centos6.2 64位系統記憶體1024M
常用引數說明
–enable-server #安裝zabbix server
–enable-proxy #安裝zabbix proxy
–enable-agent #安裝zabbix agent(如果不監控本機也可以不裝)
–with-mysql #使用mysql做資料庫
–with-net-snmp #支援snmp協議
–with-libcurl #支援curl,用於web服務監控
服務端:192.168.0.19
因為我lnmp 指令碼已經安裝後 編譯安裝的
在lnmp環境安裝好後下載資源,lnmp 環境yum包
1
|
yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath
|
1
2
3
4
5
6
7
8
9
|
wget http: //nchc .dl.sourceforge.net /project/zabbix/ZABBIX %20Latest%20Stable /1 .8.2 /zabbix-1 .8.2. tar .gz
--2013-12-17 18:33:47-- http: //nchc .dl.sourceforge.net /project/zabbix/ZABBIX %20Latest%20Stable /1 .8.2 /zabbix-1 .8.2. tar .gz
正在解析主機 nchc.dl.sourceforge.net... 211.79.60.17, 2001:e10:ffff:1f02::17 正在連線 nchc.dl.sourceforge.net|211.79.60.17|:80... 已連線。 已發出 HTTP 請求,正在等待回應... 200 OK 長度:3706540 (3.5M) [application /x-gzip ]
正在儲存至: “zabbix-1.8.2. tar .gz.1”
57% [==============================================================================================================> ] 2,116,760 677K /s eta(英國中部時61% [========================================================================================================================> ] 2,293,904 688K /s eta(英國中部時68% [======================================================================================================================================> ] 2,556,716 722K /s eta(英國中部時72% [=============================================================================================================================================> ] 2,700,248 752K /s eta(英國中部時79% [==========================================================================================================================================================> ] 2,948,756 850K /s eta(英國中部時85% [======================================================================================================================================================================> ] 3,176,720 896K /s eta(英國中部時91% [=================================================================================================================================================================================> ] 3,381,452 937K /s eta(英國中部時97% [==============================================================================================================================================================================================> ] 3,628,292 983K /s eta(英國中部時100%[===================================================================================================================================================================================================>] 3,706,540 993K /s in 4.6s
2013-12-17 18:33:52 (795 KB /s ) - 已儲存 “zabbix-1.8.2. tar .gz.1” [3706540 /3706540 ])
|
1
2
3
4
5
6
7
8
9
10
|
[root@ceshi install ] # tar zxvf zabbix-1.8.2.tar.gz
zabbix-1.8.2 /src/zabbix_server/discoverer/Makefile .am
zabbix-1.8.2 /src/zabbix_server/poller/
zabbix-1.8.2 /src/zabbix_server/poller/poller .h
zabbix-1.8.2 /src/zabbix_server/poller/checks_ssh .c
zabbix-1.8.2 /src/zabbix_server/poller/checks_internal .c
zabbix-1.8.2 /src/zabbix_server/poller/checks_internal .h
zabbix-1.8.2 /man/zabbix_agentd . man
zabbix-1.8.2 /man/zabbix_proxy . man
zabbix-1.8.2 /man/zabbix_sender . man
|
開始增加資料庫
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@ceshi install ] # mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 5
Server version: 5.1.60-log Source distribution Copyright (c) 2000, 2013, Oracle and /or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and /or its
affiliates. Other names may be trademarks of their respective owners. Type `help;` or `h` for help. Type `c` to clear the current input statement.
mysql> create database zabbix; Query OK, 1 row affected (0.23 sec) mysql> Ctrl-C -- exit !
Aborted [root@ceshi install ] # cd zabbix-1.8.2/create/schema/
[root@ceshi schema] # cat mysql.sql | mysql -uroot -p123456 zabbix
[root@ceshi schema] # cd ../data/
[root@ceshi data] # cat data.sql | mysql -uroot -p123456 zabbix
|
1
2
3
4
5
6
7
8
9
|
[root@ceshi install ] # wget http://iksemel.googlecode.com/files/iksemel-1.4.tar.gz
--2013-12-17 18:44:56-- http: //iksemel .googlecode.com /files/iksemel-1 .4. tar .gz
正在解析主機 iksemel.googlecode.com... 74.125.128.82, 2404:6800:4005:c00::52 正在連線 iksemel.googlecode.com|74.125.128.82|:80... 已連線。 已發出 HTTP 請求,正在等待回應... 200 OK 長度:515581 (503K) [application /x-gzip ]
正在儲存至: “iksemel-1.4. tar .gz”
100%[======================================>] 515,581 1.06M /s in 0.5s
2013-12-17 18:44:57 (1.06 MB /s ) - 已儲存 “iksemel-1.4. tar .gz” [515581 /515581 ])
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@ceshi install ] # tar zxvf iksemel-1.4.tar.gz
iksemel-1.4 /src/Makefile .am
iksemel-1.4 /src/io-posix .c
iksemel-1.4 /src/base64 .c
iksemel-1.4 /src/Makefile . in
iksemel-1.4 /src/dom .c
iksemel-1.4 /src/utility .c
iksemel-1.4 /config .sub
iksemel-1.4 /Makefile .am
iksemel-1.4 /aclocal .m4
iksemel-1.4 /configure
iksemel-1.4 /install-sh
iksemel-1.4 /NEWS
|
編譯
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@ceshi iksemel-1.4] # ./configure
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether g77 accepts -g... yes
checking the maximum length of command line arguments... 100663296
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in ... no
checking dynamic linker characteristics... GNU /Linux ld.so
checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes
config.status: executing depfiles commands |
make && make install
cd zabbix-1.8.2
./configure –prefix=/home/data/websrv/zabbix –enable-server –enable-agent –enable-proxy
–with-mysql=/home/data/websrv/mysql/bin/mysql_config –with-net-snmp –with-libcurl
checking for hstrerror… yes
checking for atoll… yes
checking for getopt_long… yes
checking for strcasestr… yes
checking for getenv… yes
checking for putenv… yes
checking if Oracle support is enabled… no
checking for mysql_config… /home/data/websrv/mysql/bin/mysql_config
checking for main in -lmysqlclient … yes
checking for function PQserverVersion()… no
checking for Zabbix server database selection… ok
checking for pkg-config… /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0… yes
checking for gawk… (cached) gawk
checking for curl-config… /usr/bin/curl-config
checking for the version of libcurl… 7.19.7
checking for libcurl >= version 7.13.1… yes
checking for main in -lcurl… yes
checking whether libcurl is usable… yes
checking for curl_free… yes
checking for net-snmp-config… no
configure: error: Invalid NET-SNMP directory – unable to find net-snmp-config
報錯資訊
編譯安裝zabbix時,配置時報錯以上,導致檢測系統環境不成功。提示unable to find net-snmp-config,說明缺少相關的依賴性。
這是因為,在linux中,大多數軟體都是開源的,並且可以自由使用。因此在開發時可以用到其他的軟體包時我們直接就拿來了,不用在花功夫去重新編寫,這就造成了所謂的依賴性。
那麼怎麼解決該問題那?
解決辦法一
找出net-snmp-config屬於哪個軟體包,然後安裝即可。
yum search net-snmp-config,發現net-snmp-config屬於軟體包net-snmp-devel,安裝該軟體包,解決該問題。
1
|
yum install -y net-snmp-devel
|
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
37
38
39
40
|
config.status: creating src /zabbix_proxy/heart/Makefile
config.status: creating src /zabbix_proxy/housekeeper/Makefile
config.status: creating src /zabbix_proxy/proxyconfig/Makefile
config.status: creating src /zabbix_proxy/datasender/Makefile
config.status: creating upgrades /Makefile
config.status: creating man /Makefile
config.status: creating include /config .h
config.status: executing depfiles commands Configuration: Detected OS: linux-gnu
Install path: /home/data/websrv/zabbix
Compilation arch: linux
Compiler: gcc
Compiler flags: -g -O2 -I /home/data/websrv/mysql/include/mysql -g -DUNIV_LINUX -I /usr/include/rpm -I /usr/local/include -I /usr/lib64/perl5/CORE -I. -I /usr/include
Enable server: yes
With database: MySQL
WEB Monitoring via: cURL
Native Jabber: no
SNMP: net-snmp
IPMI: no
Linker flags: -L /home/data/websrv/mysql/lib/mysql -lcurl -L /usr/lib64 -lnetsnmp -lcrypto -L /usr/lib64 -lnetsnmp -lcrypto
Libraries: -lm -lresolv -liconv -lmysqlclient -lcurl -lnetsnmp
Enable proxy: yes
With database: MySQL
WEB Monitoring via: cURL
SNMP: net-snmp
IPMI: no
Linker flags: -L /home/data/websrv/mysql/lib/mysql -lcurl -L /usr/lib64 -lnetsnmp -lcrypto -L /usr/lib64 -lnetsnmp -lcrypto
Libraries: -lm -lresolv -liconv -lmysqlclient -lcurl -lnetsnmp
Enable agent: yes
Linker flags:
Libraries: -lm -lresolv -liconv
LDAP support: no
IPv6 support: no
*********************************************************** * Now run `make install` *
* * * Thank you for using Zabbix! *
* <http: //www .zabbix.com> *
*********************************************************** |
完成編譯 make && make install
1
2
3
|
make [2]: Nothing to be done for ` install -data-am`.
make [2]: Leaving directory ` /home/data/install/zabbix-1 .8.2`
make [1]: Leaving directory ` /home/data/install/zabbix-1 .8.2`
|
修改PHP配置檔案php.ini內容使其滿足zabbix安裝配置需求
1
2
3
4
|
sed -i `s/^(.*)date.timezone =.*$/date.timezone = Asia/Shanghai/g` /home/data/websrv/php/etc/php .ini
sed -i `s/^(.*)post_max_size =.*$/post_max_size = 16M/g` /home/data/websrv/php/etc/php .ini
sed -i `s/^(.*)max_execution_time =.*$/max_execution_time = 300/g` /home/data/websrv/php/etc/php .ini
sed -i `s/^(.*)max_input_time =.*$/max_input_time = 300/g` /home/data/websrv/php/etc/php .ini
|
新增zabbix服務對應的埠
1
2
3
4
5
6
7
8
|
com-bardac-dw 48556 /tcp # com-bardac-dw
com-bardac-dw 48556 /udp # com-bardac-dw
iqobject 48619 /tcp # iqobject
iqobject 48619 /udp # iqobject
zabbix-agent 10050 /tcp Zabbix Agent
zabbix-agent 10050 /udp Zabbix Agent
zabbix-trapper 10051 /tcp Zabbix Trapper
zabbix-trapper 10051 /udp Zabbix Trapper
|
vim /etc/services
拷貝zabbix的配置檔案到etc下,web相關檔案拷貝到web目錄下
1
2
3
4
|
cd zabbix-1.8.2
mkdir -p /etc/zabbix
cp misc /conf/ * /etc/zabbix
cp -r frontends /php /home/data/www/html/request
|
vi /etc/zabbix/zabbix_server.conf
修改資料庫連線的資料庫使用者和密碼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
DBName=zabbix ### Option: DBUser # Database user. Ignored for SQLite. # # Mandatory: no # Default: # DBUser= DBUser=zabbix ### Option: DBPassword # Database password. Ignored for SQLite. # Comment this line if no password is used. # # Mandatory: no # Default: DBPassword=123456 |
修改nginx配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
vim /home/data/websrv/nginx/conf/nginx .conf
server { listen 80; server_name 192.168.0.19; #access_log logs/zabbix_access.log main; location / { root /home/data/www/html/request ;
index index.html index.htm index.php; } location ~ .php$ { root /home/data/www/html/request ;
fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_index index.php; include fastcgi_params; } } } |
1
2
|
[root@ceshi zabbix-1.8.2] # service nginx start
Starting nginx daemon: nginx |
啟動zabbix
1
2
3
|
[root@ceshi zabbix-1.8.2] # /home/data/websrv/zabbix/sbin/zabbix_server
/home/data/websrv/zabbix/sbin/zabbix_server [7375]: User zabbix does not exist.
/home/data/websrv/zabbix/sbin/zabbix_server [7375]: Cannot run as root !
|
啟動時報錯
用下面方法解決:
[root@ceshi zabbix-1.8.2]# useradd zabbix
[root@ceshi zabbix-1.8.2]# /home/data/websrv/zabbix/sbin/zabbix_server
1
2
3
4
5
6
7
8
9
10
11
12
|
如果其他啟動報錯、 zabbix_server: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file : No such file or directory
因為我的 mysql client 庫不在系統預設庫中,做以下修改後重新啟動就可以了: echo /usr/local/mysql/lib/mysql/ >> /etc/ld .so.conf
ldconfig * 啟動 Zabbix Agentd /etc/init .d /zabbix-agentd start
# /etc/init.d/zabbix-agentd start Starting zabbix_agentd: /home/data/websrv/zabbix/sbin/zabbix_agentd : error while loading shared libraries: libiconv.so.2: cannot open shared object file : No such fileor directory
用下面方法解決: # echo /usr/local/lib/ >> /etc/ld.so.conf # ldconfig |
進行zabbix安裝
如果有faild的專案,請以如下方法逐一解決:
PHP version:PHP版本,要求5.1.6以上
PHP memory limit:修改php.ini檔案“memory_limit”引數
PHP post max size:修改php.ini檔案“post_max_size”引數
PHP upload max filesize:修改php.ini檔案“upload_max_filesize”引數
PHP max execution time:修改php.ini檔案“max_execution_time”引數
PHP max input time:修改php.ini檔案“max_input_time”引數
PHP timezone:修改php.ini檔案“date.timezone”引數,改為Asia/Shanghai
PHP database support:如果使用的是MySQL資料庫,則需要安裝php-mysql庫支援,我的系統是CentOS 5,因此我直接yum install php-mysql即可
PHP BC math:需要安裝BC_math庫
PHP MB string:需要安裝php-mbstring庫,我直接yum install php-mbstring就裝好了
PHP Sockets:需要安裝php socket庫
PHP GD:需要安裝php-gd庫,yum install php-gd
GD PNG Support:需要安裝GD庫的PNG擴充套件支援
libxml module:需要安裝php-xml庫,yum install php-xml
ctype module:需要php ctype支援
然後重新初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@ceshi php-5.3.16] # cd /home/data/install/lnmp/php-5.3.16/ext/bcmath/
[root@ceshi bcmath] # /home/data/websrv/php/bin/phpize
Configuring for :
PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 [root@ceshi bcmath] # ./configure --with-php-config=/home/data/websrv/php/bin/php-config
appending configuration tag "CXX" to libtool
configure: creating . /config .status
config.status: creating config.h make && make install
Installing shared extensions: /home/data/websrv/php/lib/php/extensions/no-debug-non-zts-20090626/
vim php.ini extension= /home/data/websrv/php/lib/php/extensions/no-debug-non-zts-20090626/
|
ok 已經支援
又發現新的報錯
繼續解決
1
2
3
4
5
|
進入資料庫賦予許可權 mysql> grant all on *.* to `zabbix` @ `%` identified by `123456` ;
Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
修改配置檔案 並且給予許可權 解決 [root@ceshi php] # chmod 777 conf
vi zabbix.conf.php.example
global $DB; $DB[ "TYPE" ] = `MYSQL` ;
$DB[ "SERVER" ] = `192.168.0.19` ;
$DB[ "PORT" ] = `3306` ;
$DB[ "DATABASE" ] = `zabbix` ;
$DB[ "USER" ] = `zabbix` ;
$DB[ "PASSWORD" ] = `123456` ;
$ZBX_SERVER = `192.168.0.19` ;
$ZBX_SERVER_PORT = `10051` ;
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; ?> |
使用者名稱是admin,密碼zabbix 預設的
否則永遠進不去
除錯一下 就變成中文介面了哈哈 這點是最好的!
現在我們監控客戶端
客戶端192.168.0.20
1
2
3
4
5
6
7
8
9
10
|
# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.0.5/zabbix-2.0.5.tar.gz # tar xvf zabbix-2.0.5.tar.gz # cd zabbix-2.0.5 # ./configure --prefix=/usr/local/zabbix --enable-agent # make && make install 新增服務 cat >> /etc/services <
zabbix_agent 10050 /tcp
zabbix_trap 10051 /tcp
EOF |
1
2
3
4
|
[root@puttet zabbix-2.0.5] # cp /root/zabbix-2.0.5/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@puttet zabbix-2.0.5] # sed -i `s/BASEDIR=/usr/local/BASEDIR=/usr/local/zabbix/g` /etc/init.d/zabbix_agentd
[root@puttet zabbix-2.0.5] # chkconfig --add zabbix_agentd
[root@puttet zabbix-2.0.5] # chkconfig zabbix_agentd on
|
1
2
3
4
5
6
7
8
9
|
# vim /usr/local/zabbix/etc/zabbix_agentd.conf Server=192.168.0.20 // 配置zabbix伺服器的IP地址
Hostname=linux_client // 配置主機名
PidFile= /var/tmp/zabbix_agentd .pid // 指定pid路徑
LogFile= /var/log/zabbix/zabbix_agentd .log // 指定日誌檔案
儲存退出 #mkdir /var/log/zabbix #touch /var/log/zabbix/zabbix_agentd.log #chown -R zabbix.zabbix /var/log/zabbix |
1
2
3
4
5
|
[root@puttet zabbix-2.0.5] # chown -R zabbix.zabbix /var/log/zabbix
[root@puttet zabbix-2.0.5] # /etc/init.d/zabbix_agentd start
Starting zabbix_agentd: [確定] [root@puttet zabbix-2.0.5] # netstat -tnlp | grep --color zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 8126 /zabbix_agentd
|
在zabbix的服務端執行下面的命令測試與客戶端是否聯通
1
2
|
[root@ceshi php] # /home/data/websrv/zabbix/bin/zabbix_get -s 192.168.0.20 -p10050 -k"net.if.in[eth0,bytes]"
21280557 |
到此試驗完成。
zabbix強大的自定義和批量群組管理功能十分好用.而且個人感覺畫的圖比cacti好看!
最後解決亂碼問題
[root@ceshi php]# vi ./include/defines.inc.php
修改配置檔案 然後重啟服務端即可!
本文轉自 cs312779641 51CTO部落格,原文連結:http://blog.51cto.com/chenhao6/1342692
相關文章
- zabbix安裝中文環境
- zabbix監控客戶端安裝客戶端
- centos6.2LNMP環境安裝(yum)CentOSLNMP
- zabbix分散式監控環境完全編譯安裝部署分散式編譯
- zabbix環境安裝搭建
- zabbix一鍵安裝lnmp環境LNMP
- 在linux環境下安裝JDK並配置環境變數LinuxJDK變數
- Windows 環境下 Python 環境安裝WindowsPython
- .NET環境構建CAS客戶端客戶端
- zabbix 客戶端安裝客戶端
- CentOS 7 下安裝PHP環境並且配置Nginx支援php-fpm模組CentOSPHPNginx
- nginx下搭建nagios監控環境NginxiOS
- AIX環境下監控程式指令碼AI指令碼
- linux或者CentOS環境下安裝.NET Core環境LinuxCentOS
- Windows 環境下安裝 LaravelWindowsLaravel
- Mac環境下安裝PodMac
- Windows 環境下安裝 RedisWindowsRedis
- Windows環境下安裝RabbitMQWindowsMQ
- kali環境下安裝dvwa
- ubuntu下安裝boost環境Ubuntu
- Unbuntu下安裝Go環境Go
- 安裝python虛擬環境並配置虛擬環境以及安裝scrapy模組Python
- Windows環境下嘗試安裝並配置PHP PEARWindowsPHP
- Linux下安裝Go環境LinuxGo
- docker環境下安裝tensorflowDocker
- Windows環境下安裝LinuxWindowsLinux
- Docker 下安裝配置 lnmp 環境DockerLNMP
- linux環境下redis安裝LinuxRedis
- Linux環境下安裝NginxLinuxNginx
- Windows環境下安裝NexusWindows
- Mac環境下安裝配置RedisMacRedis
- windows下配置安裝YAF環境Windows
- windows環境下安裝seleniumWindows
- LINUX環境下安裝TIPTOPLinux
- Linux下Java環境安裝LinuxJava
- ubuntu環境下安裝perf工具Ubuntu
- CAS SSO單點登入客戶端環境搭建客戶端
- window環境下安裝和切換兩個python環境Python