LNMP與Zabbix4.0 環境部署

LNMP+Zabbix4.0 環境部署

環境

關閉防火牆,Selinux

systemctl stop firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

服務端

LNMP環境所需要的安裝包如下。主要以rpm包爲主。不是源碼安裝

[root@json-server ~]# rpm -qa | grep nginx
nginx-1.16.0-1.el7.ngx.x86_64
[root@json-server ~]# rpm -qa |grep php
php-common-5.4.16-46.el7.x86_64
php-5.4.16-46.el7.x86_64
php-cli-5.4.16-46.el7.x86_64
php-fpm-5.4.16-46.el7.x86_64
php-pdo-5.4.16-46.el7.x86_64
php-mysql-5.4.16-46.el7.x86_64
[root@json-server ~]# rpm -qa | grep mysql
mysql-community-common-5.7.26-1.el7.x86_64
mysql-community-release-el7-7.noarch
mysql-community-libs-5.7.26-1.el7.x86_64
mysql-community-server-5.7.26-1.el7.x86_64
mysql-community-client-5.7.26-1.el7.x86_64
mysql-community-libs-compat-5.7.26-1.el7.x86_64

詳細的LNMP搭建參考:LNMP搭建詳解

安裝zabbix

rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
yum clean all
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get zabbix-web zabbix-sender

## failed to link /usr/share/zabbix/fonts/graphfont.ttf -> /etc/alternatives/zabbix-web-font: No such file or directory

## 進行解決
## 在windows裏面找一個顯示中文的字體文件複製到服務器中

mkdir /usr/share/zabbix/fonts
mv SIMHEI.TTF /usr/share/zabbix/fonts/graphfont.ttf
ln -s /usr/share/zabbix/fonts/graphfont.ttf /etc/alternatives/zabbix-web-font

創建,配置zabbix

1.創建zabbix庫,並授權用戶

mysql -uroot -p123456
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@'%' identified by '123456';
msyql> flush privileges

2.解壓zabbix數據庫文件並導入數據庫

gunzip /usr/share/doc/zabbix-server-mysql*/create.sql.gz

# 方法1:
mysql -uroot -p zabbix >/usr/share/doc/zabbix-server-mysql*/create.sql

# 方法2:
mysql -uroot -p123456
mysql> use zabbix;
mysql> source create.sql的路徑;
mysql> show tables;

# 方法3:
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

# 移動文件到web根目錄
cp -rp /usr/share/zabbix/ /usr/share/nginx/html/

啓動各項服務

systemctl restart mysqld nginx zabbix-server.service  zabbix-agent.service php-fpm
systemctl enable mysqld nginx zabbix-server.service  zabbix-agent.service php-fpm

訪問網頁,從網頁進行安裝

出現上圖,按照要求進行設置相關配置文件

主要的配置文件有:

  • /etc/php.ini
  • /etc/httpd/conf.d/zabbix.conf

當全部爲綠色後就可以進行下一步

登錄的時候,默認賬戶名Admin,密碼zabbix

參考文獻:zabbix安裝官方參考
參考文獻:zabbix圖像配置參考

解決zabbix亂碼問題

沒有任何顯示或者顯示人看不懂的,表明存在亂碼,需要進行解決
1.在window拷貝一個能顯示中午的字體文件到zabbix-server的/usr/share/zabbix/fonts目錄下面,注意字體文件的權限
2.製作字體文件名改爲graphfont.ttf軟連接

mv /usr/share/nginx/html/zabbix/fonts/SIMHEI.TTF ./fonts/graphfont.ttf

3.重啓服務

systemctl restart zabbix-agent.service zabbix-server.service nginx php-fpm.service mysqld.service 

解決Zabbix server is not running :the information displayed may not be current.

在登錄了zabbix首頁之後,可能在底部會出現
Zabbix server is not running :the information displayed may not be current.

可能出現的原因:

  • 防火牆阻止了nginx服務
  • 數據庫授權有問題
  • zabbix的web配置文件配置問題
  • dns的解析問題

1.防火牆

# 關閉防火牆和selinux
systemctl status firewalld
systemctl stop firewalld
systemctl disabled firewalld

# 關閉selinux
setenforce 0   # 臨時關閉
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config

2.更改zabbix的web配置文件
配置文件名:zabbix.conf.php
可以通過find / -name "zabbix.conf.php"查找,之後按照下圖進行修改

3.數據庫授權
一般問題不會在這,因爲安裝之前已經授權了,但由於剛纔修改了web文件,需要重新授權

mysql -uroot -p123456
mysql> grant all privileges on zabbix.* to zabbix@'%' identified by 123456;
mysql> flush privileges;
mysql> exit

4.檢查dns,並修改
1.修改DNS
vim /etc/hosts
2.重啓nginx
systemctl restart nginx

5.檢查配置文件

vim /etc/zabbix/zabbix_server.conf
DBHost=192.168.50.66
DBName=zabbix
DBUser=zabbix
DBPassword=123456

6.重啓服務
systemctl restart zabbix-agent.service zabbix-server.service nginx php-fpm.service mysqld.service

7.登錄web界面
http://192.168.50.66/zabbix

LAMP 與 zabbix 環境部署
LNMP 環境部署
官方安裝zabbix文檔
官方源碼安裝zabbix文檔

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章