基於LNMP的Zabbix4.0.1部署
阿新 • • 發佈:2018-12-11
轉:
http://www.safecdn.cn/monitor/2018/12/lnmp-zabbix4-0-1-install/306.html
Zabbix4.0.1部署 一 安裝源和Zabbix的依賴包: 1 新增源 wget -q -O - http://www.atomicorp.com/installers/atomic | sh 2 安裝LAMP環境 yum -y install nginx php php-mysql mysql mysql-server vim nmap php-fpm 3 安裝拓展包 yum -y install mysql-devel libcurl-devel net-snmp-devel php-bcmath php-ldap php-mbstring php-gd php-xmlwriter libevent-devel libevent pcre* 二 新增使用者: groupadd zabbix useradd -g zabbix -s /sbin/nologin zabbix 三 建立資料庫並新增授權賬號: #啟動mysql資料庫 /etc/init.d/mysqld start #解決中文亂碼問題 mysql -e "create database zabbix character set utf8;" #對使用者進行授權 mysql -e "grant all privileges on zabbix.* to [email protected] identified by '[email protected]';"
四 下載zabbix
zabbix下載地址:
http://repo.zabbix.com/zabbix/
https://sourceforge.net/projects/zabbix/
1 下載原始碼
wget "https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz/download" -O zabbix-4.0.1.tar.gz
2 編譯安裝
tar -zxvf zabbix-4.0.1.tar.gz
cd zabbix-4.0.1
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
make -j 4 && make install
4 #匯入資料庫
cd /tmp/zabbix-4.0.1
mysql -uzabbix -p' [email protected]' -hlocalhost zabbix < database/mysql/schema.sql
mysql -uzabbix -p'[email protected]' -hlocalhost zabbix < database/mysql/images.sql
mysql -uzabbix -p'[email protected]' -hlocalhost zabbix < database/mysql/data.sql
5 #修改配置在zabbix包路徑下
sed -i 's/^DBUser=.*$/DBUser=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf
sed -i 's/^.*DBPassword=.*$/ [email protected]/g' /usr/local/zabbix/etc/zabbix_server.conf
sed -i 's/^DBSocket=.*$/DBSocket=\/var\/lib\/mysql\/mysql.sock /usr/local/zabbix/etc/zabbix_server.conf
cp -r frontends/php /var/www/html/zabbix
cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd
6 #新增服務埠
cat >>/etc/services <<EOF
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
EOF
7 #修改php.ini
sed -i 's/^\(.*\)date.timezone =.*$/date.timezone = Asia\/Shanghai/g' /etc/php.ini
sed -i 's/^\(.*\)post_max_size =.*$/post_max_size = 16M/g' /etc/php.ini
sed -i 's/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g' /etc/php.ini
sed -i 's/^\(.*\)max_input_time =.*$/max_input_time = 300/g' /etc/php.ini
sed -i 's/^\(.*\)always_populate_raw_post_data =.*$/always_populate_raw_post_data = .*/g' /etc/php.ini
8#配置nginx
vim /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 10.0.5.150;
location / {
root /var/www/html/zabbix;
index index.php index.html;
}
location ~ \.php$ {
root /var/www/html/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_scrip
t_name;
include fastcgi_params;
}
9#修改許可權
chown -R root:root /var/lib/php/
chmod 777 /var/lib/php/session/
10 #啟動服務
/etc/init.d/nginx start
/etc/init.d/php-fpm start
/etc/init.d/mysqld start
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
chkconfig nginx on
chkconfig mysqld on
chkconfig php-fpm on
echo "/etc/init.d/zabbix_server start" >> /etc/rc.local
echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.local
五 WEB頁面配置:
訪問http://10.0.5.150/setup.php
1、確認每個Required都是ok的才會顯示Next按鈕,如果有Fail的需要完善系統要求
2、這裡主要下,出現Fail的原因是zabbix的配置檔案沒有,需要點選“Download configuration file”將zabbix.conf.php下載到本地在上傳到伺服器的zabbix/conf/目錄下即可 到此web頁面配置完畢,直接訪問IP就可以登入,zabbix的預設登陸賬號是admin,密碼是zabbix 3、更換中文字型,登陸後在頁面的右上邊點選“Prefile” 4、在Language選項中選擇“Chinese(zh_CN)”,然後Save
Zabbix4.0.1部署 一 安裝源和Zabbix的依賴包: 1 新增源 wget -q -O - http://www.atomicorp.com/installers/atomic | sh 2 安裝LAMP環境 yum -y install nginx php php-mysql mysql mysql-server vim nmap php-fpm 3 安裝拓展包 yum -y install mysql-devel libcurl-devel net-snmp-devel php-bcmath php-ldap php-mbstring php-gd php-xmlwriter libevent-devel libevent pcre* 二 新增使用者: groupadd zabbix useradd -g zabbix -s /sbin/nologin zabbix 三 建立資料庫並新增授權賬號: #啟動mysql資料庫 /etc/init.d/mysqld start #解決中文亂碼問題 mysql -e "create database zabbix character set utf8;" #對使用者進行授權 mysql -e "grant all privileges on zabbix.* to
2、這裡主要下,出現Fail的原因是zabbix的配置檔案沒有,需要點選“Download configuration file”將zabbix.conf.php下載到本地在上傳到伺服器的zabbix/conf/目錄下即可 到此web頁面配置完畢,直接訪問IP就可以登入,zabbix的預設登陸賬號是admin,密碼是zabbix 3、更換中文字型,登陸後在頁面的右上邊點選“Prefile” 4、在Language選項中選擇“Chinese(zh_CN)”,然後Save