這是從我的CSDN拷貝來的
先關閉防火牆
centos7默認是firewalld
systemctl stop firewalld.service
systemctl disable firewalld.service
關閉selinux
vim /etc/sysconfig/selinux
SELINUX=后面改為disabled
source /etc/sysconfig/selinux
setenforce 0
安裝一些使用的工具
yum -y install bash* 在輸入bash回車
yum -y install net-tools*
yum -y install vim*
yum -y install wget*
服務端---我是zabbix4.2的
yum -y install http*
如果只是做zabbix服務器,可以不改http端口(80),我是安裝了nginx,已經用了80
我這里改為33333
vim /etc/httpd/conf/httpd.conf
40行左右 Listen 33333
systemctl restart httpd.service
systemctl enable httpd.service
yum -y install php* 只管執行,不要看結果
1 rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
1 yum install -y zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent zabbix-sender
上面的命令,如果沒安裝到100%斷了,就在執行一次,會接着安裝的
解壓數據結構
1 cd /usr/share/doc/zabbix-server-mysql-4.2.0/
1 gunzip create.sql.gz
把解壓的復制到/sql目錄(我自己創建的,導入方便)
安裝數據庫
我是把數據目錄改為/data/mysql/mysql了(創建/data/mysql)
1 yum -y install mariadb* 2 systemctl restart mariadb.service 3 systemctl enable mariadb.service 4 systemctl stop mariadb.service 5 mkdir -p /data/mysql 6 cp -a /var/lib/mysql/ /data/mysql/ 7 vim /etc/my.cnf
讓數據庫不區分大小寫
1 vim /etc/my.cnf.d/server.cnf
找到 [mysqld] 標簽,在下邊添加 lower_case_table_names=1
再啟動
1 systemctl restart mariadb.service
配置mariadb
1 mysql_secure_installation
先回車----輸入y---輸入兩次密碼-----下面一直y
進數據庫
mysql -uroot -p密碼
進入數據庫輸入下面命令:可以用連接數據庫的軟件連接
1 grant all privileges on *.* to 'root'@'%' identified by 'yegoo@123' with grant option;
這段指令容許所有用root用戶輸入密碼登陸該mysql server,如果將'%' 換
乘'192.168.1.124' ,那么只有'192.168.1.124'的主機可以登陸。
'yegoo@123' 是用軟件登錄的密碼,可以和數據庫密碼不一樣
創建一個zabbix庫並設置為u?8的字符編碼格式
1 create database zabbix character set utf8 collate utf8_bin;
創建賬戶並且授權設置密碼
1 grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
給來自localhost的用戶zabbxi分配可對數據庫zabbix所有表進行所有操作的權限,並且設定
密碼為zabbix
我都是把localhost改為'%
我是
1 grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';
導入表
1 systemctl restart mariadb.service
配置zabbix文件
1 vim /etc/zabbix/zabbix_server.conf
1 systemctl restart zabbix-server.service 2 systemctl enable zabbix-server.service
配PHP
時間改為上海的
1 vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai加入下圖
重啟http服務
1 systemctl restart httpd.service
登陸zabbix網址設置(谷歌或火狐)我是用的谷歌
Ip地址/zabbix(我這是192.168.50.128/zabbix)
上面是80端口,我是33333
我這是192.168.50.128:33333/zabbix(下圖是沒改端口時的)
password是我們設置的數據庫密碼zabbix
登陸賬戶是Admin(大寫A)
密碼是zabbix
改中文
zabbix客戶端
1 rpm ‐ivh https://mirrors.aliyun.com/zabbix/zabbix/4.2/rhel/7/x86_64/zabbix‐release‐4.2‐1.el7.noarch.rpm
1 yum -y install zabbix-agent
如果沒安裝完成,再次輸入安裝命令,會繼續的
編輯文件
1 vim /etc/zabbix/zabbix_agentd.conf
在里面找到下面三行
1 Server=192.168.200.4 zabbix服務端的機器IP 2 ServerActive=192.168.200.4 zabbix服務端的機器IP 3 Hostname=9 隨便,我以被監控的機器的ip作為Hostname
啟動
1 systemctl restart zabbix-agent.service 2 systemctl enable zabbix-agent.service