LAMP與zabbix4.0 環境部署

LAMP與zabbix4.0 環境部署

環境

關閉防火牆,Selinux

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

LAMP環境部署

yum -y install http mariadb mariadb-server mariadb-devel php-fpm php
vim /var/www/html/index.php
	<?php
		phpinfo();
	?>
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

systemctl restart httpd php-fpm  mariadb
systemctl enable httpd php-fpm mariadb
mysql_secure_installation 	# 初始化mariadb
mysql -uroot -p   # 能夠正常登錄
reboot
http://192.168.50.66/index.php    # 測試是否能夠正常解析php

補充:
apache的web目錄在:/var/www/html

安裝zabbix4.0.

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

## 如果出現下面的情況
## 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  /var/www/html/

啓動各項服務

systemctl restart zabbix-server zabbix-agent httpd php-fpm mariadb
systemctl enbale zabbix-server zabbix-agent httpd php-fpm mariadb

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

出現上圖,按照要求進行設置相關配置文件 **主要的配置文件有:**
  • /etc/php.ini
  • /etc/httpd/conf.d/zabbix.conf

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

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

注意: 圖片可能是其他版本的,但不影響操作

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

解決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 httpd php-fpm.service mariadb

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

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