參考博文:https://blog.csdn.net/qq_44895681/article/details/106209354
我是以多實例安裝mysql5.7 的,安裝方法請看我的博客;這里使用3307端口mysql,sock地址:/opt/data/3307/mysql.sock
安裝完成后再進行以下操作:
1、安裝zabbix源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm yum clean all
2、安裝server與agent
安裝失敗多是網絡不佳,多執行幾次就好了。。。
yum install zabbix-server-mysql zabbix-agent -y
注意:
如果安裝中報錯:Delta RPMs disabled because /usr/bin/applydeltarpm not installed,則安裝 deltarpm軟件。
yum -y install deltarpm
3、安裝Zabbix frontend
yum install centos-release-scl -y vim /etc/yum.repos.d/zabbix.repo [zabbix-frontend] ... enabled=1 ...
4、安裝Zabbix前端包
yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y
5、創建和初始化zabbix數據庫
# mysql -uroot -pv,qZo#%?q0z* -S /opt/data/3307/mysql.sock
create database zabbix character set utf8 collate utf8_bin; create user zabbix@localhost identified by 'v,qZo#%?q0z*'; grant all privileges on zabbix.* to zabbix@localhost; quit;
6、導入zabbix數據
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pv,qZo#%?q0z* zabbix -S /opt/data/3307/mysql.sock
7、配置zabbix文件
一共四個文件
/etc/zabbix/zabbix_server.conf DBPassword=v,qZo#%?q0z* /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf # listen 80; # server_name example.com; 取消以上兩行的注釋 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf listen.acl_users = apache,nginx 新增nginx ; php_value[date.timezone] = Europe/Riga 取消注釋,並修改成Asia/Shanghai
這個文件內只保留一下內容,可以之間覆蓋掉原有的 [root@db1 ~]# egrep -v '^$|#' /etc/opt/rh/rh-nginx116/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/opt/rh/rh-nginx116/log/nginx/error.log; pid /var/opt/rh/rh-nginx116/run/nginx/nginx.pid; include /opt/rh/rh-nginx116/root/usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/opt/rh/rh-nginx116/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/opt/rh/rh-nginx116/nginx/mime.types; default_type application/octet-stream; include /etc/opt/rh/rh-nginx116/nginx/conf.d/*.conf; }
8、修改php.ini
根據自己實際情況修改,默認是不要修改的。。。
安裝zabbix之后注冊輸入mysql數值后報錯:Error connecting to database: No such file or directory
把mysql.sock 通過軟鏈接到一個指定位置。
mkdir /var/lib/mysql ln -s /opt/data/3307/mysql.sock /var/lib/mysql/mysql.sock 修改php.ini文件 [root@db1 ~]# vim /etc/opt/rh/rh-php72/php.ini 1119行 mysqli.default_socket = /var/lib/mysql/mysql.sock
9、啟動zabbix及其組件服務
systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
10、web打開
在瀏覽器內輸入IP地址,輸入必要的信息
zabbix默認賬號:Admin 密碼:zabbix
11、圖形顯示框框問題
解決方法: 將本地電腦C:\windows\fonts\simkai.ttf拷貝到centos7下的/usr/share/zabbix/assets/fonts chmod 777 simkai.ttf vim /usr/share/zabbix/include/defines.inc.php define('ZBX_GRAPH_FONT_NAME', 'graphfont'); 修改為: define('ZBX_GRAPH_FONT_NAME', 'simkai');
12、被監控端安裝agent
wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-agent2-5.0.4-1.el7.x86_64.rpm rpm -ivh zabbix-agent2-5.0.4-1.el7.x86_64.rpm
注意:(未實際測試)
如果下載的zabbix-agent 5.0安裝包使用rpm
安裝時提示“錯誤:依賴檢測失敗:libpcre.so.0()(64bit)
”,則可以使用zabbix 5.0 Yum源來安裝zabbix-agent 5.0軟件。
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm yum clean all 使用Zabbix 5.0 Yum源文件安裝zabbix-agent 5.0軟件,並且將gpgcheck=1修改為gpgcheck=0,防止出現“獲取GPG密鑰失敗”報錯。 修改Zabbix 5.0 Yum源配置文件: [root@localhost ~]# sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.repos.d/zabbix.repo [root@localhost ~]# cat /etc/yum.repos.d/zabbix.repo [zabbix] name=Zabbix Official Repository - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/ enabled=1 gpgcheck=0 //修改gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 [zabbix-frontend] name=Zabbix Official Repository frontend - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend enabled=1 gpgcheck=0 //修改gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 [zabbix-debuginfo] name=Zabbix Official Repository debuginfo - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/debuginfo/ enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 gpgcheck=0 //修改gpgcheck=0 [zabbix-non-supported] name=Zabbix Official Repository non-supported - $basearch baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=0 //修改gpgcheck=0 [root@localhost ~]# yum -y install zabbix-agent //安裝zabbix-agent 5.0軟件 ... 已安裝: zabbix-agent.x86_64 0:5.0.0-1.el7 完畢!
13、編輯agent配置文件(未實踐)
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf 119 Server=127.0.0.1,192.168.2.128 //Zabbix-server地址,多個用","隔開 160 ServerActive=192.168.2.128 //主動檢查本主機數據發送給Zabbix-server 171 #Hostname=Zabbix server 172 Hostname=192.168.2.129 //客戶端IP地址 [root@localhost ~]# systemctl start zabbix-agent [root@localhost ~]# systemctl enable zabbix-agent [root@localhost ~]# ss -antulp | grep :10050 tcp LISTEN 0 128 *:10050 *:* users:(("zabbix_agentd",pid=3389,fd=4),("zabbix_agentd",pid=3388,fd=4),("zabbix_agentd",pid=3387,fd=4),("zabbix_agentd",pid=3386,fd=4),("zabbix_agentd",pid=3385,fd=4),("zabbix_agentd",pid=3384,fd=4)) tcp LISTEN 0 128 :::10050 :::* users:(("zabbix_agentd",pid=3389,fd=5),("zabbix_agentd",pid=3388,fd=5),("zabbix_agentd",pid=3387,fd=5),("zabbix_agentd",pid=3386,fd=5),("zabbix_agentd",pid=3385,fd=5),("zabbix_agentd",pid=3384,fd=5))