CentOS 7.8 x64 安裝zabbix 5.0 LTS
CentOS 7.8 x64 安裝zabbix 5.0 LTS
官網教程
-
https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=nginx
手把手安裝教程
-
安裝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 【清除yum快取】
-
-
安裝zabbix server 和 agent
-
$ yum install zabbix-server-mysql zabbix-agent 【後面出現的互動確認 全部選擇Y】
-
-
安裝zabbix前端
-
$ yum install centos-release-scl 【安裝前端release】
-
$ vi /etc/yum.repos.d/zabbix.repo 【修改配置】 ... enabled=1 ...
-
-
安裝mysql資料庫
- 本次mysql安裝我們選擇rpm安裝方式,安裝的mysql版本為5.7.30
-
下載mysql 5.7.30 rpm包
-
解壓
- tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
-
檢視系統裡是否已經有安裝過mysql,有則解除安裝
- rpm -qa|grep mariadb 【檢視】
- rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64【解除安裝】
-
安裝mysql5.7所需要的依賴
- yum install libaio
- yum install perl
- yum install net-tools
-
安裝mysql
- rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm
- rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm
- rpm -ivh mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm
- rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm
- rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
-
配置mysql資料庫
-
啟動mysql
- systemctl start mysqld.service
-
檢視mysql執行狀態
- systemctl status mysqld.service
-
找到root初始密碼
- grep "password" /var/log/mysqld.log
-
修改root密碼
- ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
-
開啟mysql的遠端訪問【下面命令開啟的IP是 192.168.0.1,如要開啟所有的,用%代替IP】
- grant all privileges on . to 'root'@'192.168.0.1' identified by 'password' with grant option;
- flush privileges;
- exit
-
為firewalld新增開放埠【新增mysql埠3306和Tomcat埠8080】
- firewall-cmd --zone=public --add-port=3306/tcp --permanent
- firewall-cmd --zone=public --add-port=8080/tcp --permanent
- 或者選擇吧firewalld服務臨時關閉【service firewalld stop】
-
修改字符集
-
描述【重新登入mysql,然後輸入status,經過觀察,不難發現裡面有兩個不是utf-8】
-
改為utf-8方法:
-
vi /etc/my.cnf
-
新增下列四行 [client] default-character-set=utf8 character-set-server=utf8 collation-server=utf8_general_ci
-
實現的效果如下所示: ``` [client] default-character-set=utf8 # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock character-set-server=utf8 collation-server=utf8_general_ci # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid ```
-
重啟mysqld 服務
-
-
-
-
初始化zabbix的資料庫
-
note:
-
mysql口令:root abcD_123 zabbix口令:zabbix abcD_123
-
-
mysql> create database zabbix character set utf8 collate utf8_bin; 【修改字符集】
-
mysql> create user zabbix@localhost identified by 'password';【建立使用者zabbix和密碼】
-
mysql> grant all privileges on zabbix.* to zabbix@localhost;【授權登入】
-
mysql> quit;
-
$ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix 【匯入初始化的schema和資料】
-
-
zabbix server配置
-
$ vi /etc/zabbix/zabbix_server.conf DBPassword=password【將資料庫password填入】
-
-
zabbx前端php配置
-
$ vi /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf 【解開註釋】 # listen 80; # server_name example.com;
-
$ vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 【修改為】 listen.acl_users = apache,nginx 【解開註釋】 php_value[date.timezone] = Asia/Shanghai
-
-
啟動zabbix server and agent 程序
-
$ 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
-
-
登入zabbix
- 官方quick start:https://www.zabbix.com/documentation/5.0/manual/quickstart/login
- 預設密碼是Admin/zabbix
-
安裝完成後遇到的問題
-
問題描述:登入zabbix前端,發現介面下方一直有報錯,報錯釋義”zabbix server啟動失敗“
-
檢視日誌:/var/log/zabbix/zabbix_server.log , 發現無法繫結socket到zabbix_server_alerter.sock,訪問被拒絕
-
原因:selinux問題
-
解決方法:關閉selunx
-
$ sestatus【檢視selinux狀態】 $ vi /etc/selinux/config 【配置修改如下】 ... SELINUX=disabled ... SELINUXTYPE=targeted $ reboot 【修改配置檔案,重啟永久關閉】 或者 $ setenforce 0【臨時關閉】
-
-