1.我這里使用的是ali的yum源
#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#setenforce 0
另:配置文件路徑 在 /etc/selinux/config 里面,需要將其修改,不然關機再開會出現zabbix-server服務啟動失敗的情況。
#systemctl stop firewalld
#systemctl disable firewalld
2.下載安裝zabbix 4.2
官網網址https://www.zabbix.com/download?zabbix=4.2&os_distribution=centos&os_version=7&db=mysql
選擇對應的系統版本,然后按照官網的命令進行下載,安裝。
# rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
# yum clean all
# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
3.安裝mariadb
#yum install -y mariadb-server.x86_64 mariadb-devel.x86_64 mariadb-libs.x86_64
#chmod -R 777 /var/lib/mysql
#systemctl enable mariadb
#systemctl start mariadb
#mysql_secure_installation
Set root password? [Y/n] <– 是否設置root用戶密碼,輸入y並回車或直接回車
New password: <– 設置root用戶的密碼
Re-enter new password: <– 再輸入一次你設置的密碼
a
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
保存退出
#vim /etc/httpd/conf.d/zabbix.conf 修改時區為上海
php_value date.timezone Asia/Shanghai
6.安裝apache
#yum install -y httpd* 粗略安裝,詳細安裝請自行搜尋
7.啟動apache和zabbix
#systemctl start httpd
# systemctl enable httpd
# netstat -an |grep 80
tcp 0 0 192.168.56.11:80 0.0.0.0:* LISTEN
# systemctl start zabbix-server
# systemctl enable zabbix-server
# systemctl start zabbix-agent.service
# systemctl enable zabbix-agent.service
遇到了一些報錯,解決方法:
#yum install policycoreutils-python
# cat /var/log/audit/audit.log | grep zabbix_server | grep denied | audit2allow -M zabbix_server_setrlimit
# semodule -i zabbix_server_setrlimit.pp
# systemctl start zabbix-server
8.訪問zabbix安裝網址
http://ip/zabbix
如果不能訪問,可以查看一下apche狀態是否正常
防火牆firewalld是否關閉
selinux的setenfore狀態是什么?
9.web安裝
①下一步
②等待自我檢測,全部OK即可下一步,有問題需要進行排查。
③填入數據庫密碼
④zabbix命名
⑤確認信息無誤
⑥完成
現在可以登錄zabbix了
默認用戶名密碼:
Admin
zabbix
注:
以上是基於圖形化安裝界面提供的步驟說明,如果沒有安到圖形化這么高級,可能會缺少一些依賴包,下面補充:
#yum install gcc mysql-devel php-mbstring php-bcmath php-mysql OpenIPMI OpenIPMI-devel libcurl libcurl-devel libxml2 libxml2-devel net-snmp net-snmp-devel fping -y