1. 程式人生 > >部署zabbix環境的搭建

部署zabbix環境的搭建

部署zabbix環境的搭建

部署zabbix環境的搭建

配置LAMP環境(因為之前已經搭建過了lnmp所以這裏就不一一演示了)

也可以yum源安裝:

[[email protected] ~]#yum install make mysql-server httpd php mysql-devel gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xml unixODBC-devel OpenIPMI-devel libxml2-devel

下載zabbix安裝包:

wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.7/zabbix-3.2.7.tar.gz

1、新建一個zabbix賬戶:

[[email protected] ~]useradd zabbix -s /sbin/nologin

2、創建zabbix數據庫、並賦給咱必須權限:

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> grant all on zabbix.* to [email protected] identified by ‘zabbix‘;

flush privileges;

下載zabbix,並且導入數據庫,

[[email protected] src]# cd /usr/local/src/zabbix-2.2.2

[[email protected] zabbix-2.2.2]# cd database/mysql/

[[email protected] mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql

[[email protected] mysql]# mysql -uzabbix -pzabbix zabbix < images.sql

[[email protected] mysql]# mysql -uzabbix -pzabbix zabbix < data.sql

4、編譯安裝zabbix_server:

[[email protected] zabbix-2.2.2]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --prefix=/usr/local/zabbix

[[email protected] zabbix-2.2.2]# make && make install

5、編輯nginx.conf支持index.php

假如使用apache的時候就改apache下的配置文件原理一樣)

[[email protected] zabbix-2.2.2]# vim /usr/local/nginx/conf/nginx.conf

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root /web;

index index.php index.html index.htm;

}

………………………………

location ~ \.php$ {###(把location裏面的前面註釋#去掉後修改成)

root /web; ###(index.php存放的目錄)

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

6、修改zabbix文件對應的數據庫賬號和密碼:

[[email protected] zabbix-2.2.2]# vim /usr/local/zabbix/etc/zabbix_server.conf

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

7、復制啟動腳本,並修改相應選項:

[[email protected] zabbix-2.2.2]# cp misc/init.d/fedora/core5/zabbix_server /etc/init.d/

[[email protected] zabbix-2.2.2]# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

修改兩個配置文件把

[[email protected] zabbix-2.2.2]# vim /etc/init.d/zabbix_agentd

ZABBIX_BIN="/usr/local/sbin/zabbix_agentd" 改成ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"

[[email protected] zabbix-2.2.2]# vim /etc/init.d/zabbix_server

ZABBIX_BIN="/usr/local/sbin/zabbix_server"改成ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server"

啟動:

[[email protected] zabbix-2.2.2]# /etc/init.d/zabbix_server start

[[email protected] zabbix-2.2.2]# /etc/init.d/zabbix_agentd start

[[email protected] zabbix-2.2.2]# chkconfig zabbix_agentd on

[[email protected] zabbix-2.2.2]# chkconfig zabbix_server on

8、修改php.ini文件支持大小,不然web也沒容易報錯:

[[email protected] zabbix-2.2.2]# vim /usr/local/php/etc/php.ini

max_execution_time = 300

max_input_time = 300

date.timezone =Asia/Shanghai

post_max_size = 32M

重啟nginx使php配置生效

9、復制zabbixphp項目早http目錄下,並且給權限:

[[email protected] /]# cd /usr/local/src/zabbix-3.2.7/frontends/

[[email protected] frontends]#

[[email protected] frontends]# cp -rf php /web

[[email protected] htdocs]# chown -R apache.apache /web

在這裏我是使用nginx+php的所以在php配置文件:vim /usr/local/nginx/conf/nginx.conf修改網頁主目錄:

location ~ \.php$ {

root /web;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

所以php網頁目錄就要放在/web目錄下 以上操作改為nginx實現。

重啟服務:

啟動php服務:

ps -ef | grep php | awk ‘{print $2}‘ | xargs kill -9

想要達到php不會自動掛掉就執行

/usr/local/php/sbin/php-fpm --daemonize -c /usr/local/php/etc/php.ini &

####--daemonize:關閉終端php不會down掉 -c:指定配置文件 & :後臺運行

啟動nginx:

/usr/local/nginx/sbin/nginx -s reload

[[email protected] frontends]# netstat -ntlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 50648/zabbix_agentd

tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 50584/zabbix_server

tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 35148/php-fpm

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 35053/mysqld

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 24389/nginx

tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 1852/X

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2327/sshd

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 26396/master

tcp 0 0 :::6000 :::* LISTEN 1852/X

tcp 0 0 :::22 :::* LISTEN 2327/sshd

tcp 0 0 ::1:25 :::* LISTEN 26396/master

端口:80 9000 10050 10051起來了就可以!

10、然後訪問web: http://IP/php/index.php默認下一步:

11、安裝gettext擴展模塊(有時候會出現很多模塊沒安裝上網查找一下就ok)

面對的問題:

在安裝zabbix時碰到如下錯誤:

PHP gettext extension missing (PHP configuration parameter --with-gettext)

分析可知道在編譯安裝php時,沒有加上--with-gettext

擴展安裝gettext時:

1、先進入php源文件中在cd /usr/local/src/php-5.5.38/ext/gettext目錄下

2、在執行/usr/local/PHP/bin/phpize

3、./configure –with-php-config=/usr/local/php/bin/php-config

4、make && make install

6、系統缺少gettext-devel工具庫,或者已經編譯安裝了gettext但是在編譯php時沒找到路徑

vim /usr/local/php/etc/php.ini

找到extensions選項,添加如下項:

extension = "gettext.so"

5、重啟php,nginx服務

安裝成功,登錄的賬號默認為:Admin,密碼為:zabbix:

訪問zabbix

技術分享

12agent安裝步驟:

客戶端安裝的話不用依賴LAMP環境,直接裝上就好

1)添加賬戶:

[[email protected] ~]# useradd zabbix -s /sbin/nologin

2)編譯安裝zabbix_agent:

[[email protected] zabbix-2.2.2]# ./configure --with-net-snmp --with-libcurl --enable-agent --prefix=/usr/local/zabbix

[[email protected] zabbix-2.2.2]# make && make install

3)設置啟動項和修改配置文件:

[[email protected] zabbix-2.2.2]# cp misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

[[email protected] zabbix-2.2.2]# chmod 700 /etc/init.d/zabbix_agentd

[[email protected] zabbix-2.2.2]# vim /etc/init.d/zabbix_agentd

ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"

4)修改zabbix指向的服務器:

[[email protected] zabbix-2.2.2]# vim /usr/local/zabbix/etc/zabbix_agentd.conf

Server=192.168.10.205

[[email protected] fonts]# pwd

/var/www/html/zabbix/fonts

上傳一個字體:替換

[[email protected] fonts]# mv simhei.ttf DejaVuSans.ttf


本文出自 “第一個legehappy51cto博客” 博客,請務必保留此出處http://legehappy.blog.51cto.com/13251607/1966047

部署zabbix環境的搭建