Zabbix-(一) 安裝與部署

Zabbix-(一)安裝與部署

一.前言

本文記錄在Centos7.6平臺 經過yum安裝部署Zabbix 4.4php

準備

  • Centos7.6 虛擬機一臺(ip: 192.168.152.140)前端

  • Mysql 8.0.12數據庫(ip: 192.168.152.1)mysql

二.安裝

1.安裝php

yum安裝phplinux

# yum install -y php

2.安裝httpd

yum安裝httpdweb

# yum install -y httpd

3. 安裝zabbix各組件

  1. 添加rpm包sql

    # rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
  2. 安裝zabbix-server-mysqlshell

    # yum install -y zabbix-server-mysql
  3. 安裝zabbix-web-mysql數據庫

    # yum install -y zabbix-web-mysql
  4. 安裝zabbix-agentvim

    # yum install -y zabbix-agent

三.初始化zabbix數據庫

  1. mysql建立zabbix用戶,密碼爲zabbixcentos

    CREATE USER 'zabbix'@'%' IDENTIFIED BY 'zabbix';
  2. 建立zabbix數據庫,併爲zabbix用戶賦予權限

    CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
    
    GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'%';
  3. 初始化schema

    注: zabbix sql在下面的這個路徑

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

    a. 若是zabbix主機安裝了mysql-client那麼能夠向mysql寫入初始化sql

    # zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -h192.168.152.1 -uzabbix -p zabbix

    b. 若是zabbix沒有安裝mysql-client,那麼則能夠將create.sql.gz文件導出,再執行sql,這裏就不在贅述

四.配置zabbix

  1. 配置zabbix-server

    # vim /etc/zabbix/zabbix_server.conf

    能夠修改server相關配置,例如:端口,日誌,SSL,數據庫,告警腳本路徑等

    這裏修改數據庫配置和容許的ip

    DBHost=192.168.152.1
    DBName=zabbix
    DBUser=zabbix
    DBPassword=zabbix
    DBPort=3306
    
    StatsAllowedIP=0.0.0.0/0
  2. 配置zabbix前端

    # vim /etc/httpd/conf.d/zabbix.conf
    # 修改時區
    php_value date.timezone Asia/Shanghai
  3. SELinux 配置

    # setsebool -P httpd_can_network_connect on
    # setsebool -P zabbix_can_network on
    # service httpd restart
  4. zabbix-agent配置

    # vim /etc/zabbix/zabbix_agentd.conf
    # zabbix server地址
    Server=192.168.152.140
    
    ServerActive=192.168.152.140
    
    Hostname=Zabbix-server

五.啓動zabbix

  1. 啓動zabbix-server和httpd

    # systemctl restart zabbix-server httpd
  2. 啓動zabbix-agent

    # systemctl start zabbix-agent

六.訪問zabbix界面

訪問 http://192.168.152.140/zabbix/

七.其餘

部署問題

  1. mysql zabbix 帳號問題,啓動zabbix-server時,出現了

    9213:20191029:144309.734 [Z3001] connection to database 'zabbix' failed: [2059] Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory

    解決: 修改zabbix帳號

    ALTER USER 'zabbix'@'%' IDENTIFIED WITH mysql_native_password BY 'zabbix';
  2. 未關閉selinux,出現

    10947:20191029:145011.030 cannot start preprocessing service: Cannot bind socket to "/var/run/zabbix/zabbix_server_preprocessing.sock": [13] Permission denied.

    解決:臨時關閉selinux

    # setenforce 0

參考文檔

官方文檔

相關文章
相關標籤/搜索