Zabbix4.0入門到實戰:Zabbix的安裝 ------ 第1章

1. 安裝版本說明

       官方有標準版和長期支持版,因爲官方對於長期支持版本支持的時間相對會長很多,所以我們會選擇長期支持版本。Zabbix的4.0版本爲當前日期最新的長期支持版本,所以接下來就安裝這個版本。如果使用源碼包安裝,可能有些包沒有啓用。後期想用,它是不支持額外添加模塊的,只能重新編譯安裝一次。所以,此外建議使用二進制包來安裝,官方已經把該需要的功能都編譯好了。

2. 安裝repo源
# 安裝zabbix的repo源:
[root@localhost ~]# rpm -ivh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
# 替換爲清華源的地址:
[root@localhost ~]# vim /etc/yum.repos.d/zabbix.repo
:%s#repo.zabbix.com#mirror.tuna.tsinghua.edu.cn/zabbix#g
3. 安裝zabbix-server-mysql
[root@localhost ~]# yum install zabbix-server-mysql -y
4. 安裝zabbix-web-mysql
[root@localhost ~]# yum install zabbix-web-mysql -y
5. 安裝與配置數據庫mariadb-server
# 安裝mariadb-server
[root@localhost ~]# yum install mariadb-server -y

# 設置開機自啓
root@localhost ~]# systemctl enable mariadb
[root@localhost ~]# systemctl is-enabled mariadb
enabled

# 數據庫安全初始化(/etc/mysq.cnf的[mysqld]下添加skip-grant-tables,設置密碼部分爲n,其他爲y)
[root@localhost ~]# mysql_secure_installation

# 創建數據庫
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;

# 數據庫授權
MariaDB [(none)]> grant all on zabbix.* to zabbix@'%' identified by '123456';
MariaDB [(none)]> flush privileges;

# 查找zabbix的sql文件
[root@localhost ~]# rpm -ql zabbix-server-mysql
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-4.0.20/
[root@localhost zabbix-server-mysql-4.0.20]# ls
AUTHORS  ChangeLog  COPYING  create.sql.gz  NEWS  README
[root@localhost zabbix-server-mysql-4.0.20]# file create.sql.gz 
create.sql.gz: gzip compressed data, was "create.sql", from Unix, last modified: Mon Apr 27 09:04:32 2020
[root@localhost zabbix-server-mysql-4.0.20]# gzip -d create.sql.gz 

# 將sql文件導入到數據庫中
[root@localhost zabbix-server-mysql-4.0.20]# mysql -uzabbix -p123456 zabbix <create.sql
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |
| autoreg_host               |
| conditions                 |
| config                     |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |
| corr_condition_tagvalue    |
| corr_operation             |
……
6. 修改zabbix-server配置文件
# 需要補充下密碼,打開DBHost
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
如果mysql也是在本機上面,但是不是通過yum安裝的,而是通過二進制或者編譯安裝可能需要配置socket路徑,否則可能連接不上mysql

# 過濾需要修改的配置文件,進行檢查
[root@localhost ~]# grep -Ev '^$|#' /etc/zabbix/zabbix_server.conf 
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

# 設置zabbix開機自啓
[root@localhost ~]# systemctl enable zabbix-server

# 啓動zabbix
[root@localhost ~]# systemctl start zabbix-server

# 檢查是否正常啓動,默認端口是10051
[root@localhost ~]# netstat -nlp|grep 10051

# 如果沒有權限則關閉selinux
[root@localhost ~]# setenforce 0

# setenforce 0是臨時關閉防火牆,這裏是永久關閉
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

# 如果沒有啓動可以檢查下啓動日誌
[root@localhost ~]# tailf /var/log/zabbix/zabbix_server.log
7. 修改zabbix-web配置文件
# 裝好zabbix後就會在httpd的conf下就會多一個zabbix配置文件,啓動httpd
oot@localhost ~]# systemctl start httpd

# 查看是否啓動並用本地及其測試端口能否通
[root@localhost ~]# netstat -tunlp|grep 80

# 如果不通,關閉iptable防火牆
[root@localhost ~]# systemctl stop firewalld

這個時候就可以通過本機訪問這臺服務器了:
在這裏插入圖片描述

8. 配置時區

可以發現時區是未知的:
在這裏插入圖片描述
配置時區:

# 編輯時區默認是註釋
[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
# 通過apache來調整php的參數,重啓httpd服務
[root@localhost ~]# systemctl restart httpd

成功配置時區:
在這裏插入圖片描述

9. 配置數據庫連接

在這裏插入圖片描述

10. 配置Zabbix Server

填寫zabbix server的名字,這個名字將作爲標題:
在這裏插入圖片描述
沒有什麼問題,下一步就可以:在這裏插入圖片描述
直接Finish:
在這裏插入圖片描述

11. Zabbix登錄

默認的用戶名是:Admin,密碼是:zabbix
在這裏插入圖片描述
正常登錄則Zabbix安裝成功:
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章