天天看點

Zabbix server 5.0 LTS版本 搭建

作者:特立獨行的兔子y

zabbix5.0版本和4.0還是有很大的差别,今天更新一下zabbix的5.0搭建過程。

一、準備

主機 IP 配置 系統
zabbix-server 10.30.59.242 2vcpu/4G記憶體/40G硬碟 centos7-1511

二、安裝步驟

安裝聲明: 本次安裝是安裝rpm包、web使用nginx

1、關閉防火牆

[root@localhost ~]# systemctl stop firewalld

[root@localhost ~]# systemctl disable firewalld

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

[root@localhost ~]# setenforce 0

[root@localhost ~]# vi /etc/selinux/config

[root@localhost ~]# iptables -F

[root@localhost ~]# iptables -X

[root@localhost ~]# iptables -Z

[root@localhost ~]# iptables-save

# Generated by iptables-save v1.4.21 on Tue Jun 22 01:32:04 2021

*filter

:INPUT ACCEPT [18:1204]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [10:1048]

COMMIT

# Completed on Tue Jun 22 01:32:04 2021           

2、下載下傳zabbix

rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm           

官網的yum源是國外的,為了提高速度,這裡改為國内的。

[root@localhost ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo

[root@localhost ~]# yum clean all

# 下載下傳zabbix-server zabbix-agent

[root@localhost ~]# yum install zabbix-server-mysql zabbix-agent -y           

3、安裝Software Collections。

SCL可以讓你在同一個作業系統上安裝和使用多個版本的軟體,而不會影響整個系統的安裝包,軟體包會安裝在/opt/rh目錄下。

[root@localhost ~]# yum install -y centos-release-scl           

4、安裝web環境

# 修改yum源,開啟frontend

[root@localhost ~]# vi /etc/yum.repos.d/zabbix.repo

[zabbix-frontend]

name=Zabbix Official Repository frontend - $basearch

baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/$basearch/frontend

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[root@localhost ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y           

5、MySQL配置

# 安裝MySQL

[root@localhost ~]# yum install -y mariadb-server

# 啟動服務

[root@localhost ~]# systemctl start mariadb

# 初始化

[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user. If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

Set root password? [Y/n] y # 修改使用者密碼

New password: 000000 # 輸入新的使用者密碼

Re-enter new password:000000 # 重新輸入

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y # 移除匿名使用者

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n 是否關閉遠端登陸

... skipping.

By default, MariaDB comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y # 删除test資料庫

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y # 是否重新整理授權表

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

[root@localhost ~]# mysql -uroot -p000000

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 9

Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;

Query OK, 1 row affected (0.00 sec) # 建立zabbix資料庫 指定字元編碼utf8

MariaDB [(none)]> create user zabbix@localhost identified by '000000';

Query OK, 0 rows affected (0.00 sec) # 建立本地使用者zabbix 密碼000000

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;

Query OK, 0 rows affected (0.00 sec) # 讓zabbix使用者有zabbix資料庫的所有權限。

MariaDB [(none)]> flush privileges; # 重新整理權限

Query OK, 0 rows affected (0.00 sec)

# 導入初始架構和資料,

[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p000000

# 如果報錯第一行沒有資料,在配置檔案第一行加 use zabbix;           

6、配置zabbix

配置zabbix server資料庫

[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf

DBPassword=000000

[root@localhost ~]# vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf

# 取消這兩行注釋

# 這裡要改為自己虛拟機的IP,大坑 !

# listen 80;

# server_name 10.30.59.242;

[root@localhost ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

listen.acl_users = apache,nginx

php_value[date.timezone] = Asia/Shanghai

# 重新開機服務

[root@localhost ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

# 開機自啟

[root@localhost ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.

Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.

Created symlink from /etc/systemd/system/multi-user.target.wants/rh-nginx116-nginx.service to /usr/lib/systemd/system/rh-nginx116-nginx.service.

Created symlink from /etc/systemd/system/multi-user.target.wants/rh-php72-php-fpm.service to /usr/lib/systemd/system/rh-php72-php-fpm.service.           

7、搭建完成

Zabbix server 5.0 LTS版本 搭建

搭建完成

配置語言

Zabbix server 5.0 LTS版本 搭建

編輯語言

解決亂碼

可以看到這裡是有一些沒有加載出來的,需要我們解決一下。

Zabbix server 5.0 LTS版本 搭建

字元亂碼

zabbix的原來字型是這個/usr/share/fonts/dejavu/DejaVuSans.ttf,然後直接在自己電腦C:\Windows\Fonts字型裡找到一款喜歡的中文字型上傳到這個目錄中,替換掉原來的字型。

[root@localhost dejavu]# cd /usr/share/fonts/dejavu/

[root@localhost dejavu]# ls

DejaVuSans-BoldOblique.ttf DejaVuSansCondensed-Bold.ttf DejaVuSans-ExtraLight.ttf STFANGSO.TTF

DejaVuSans-Bold.ttf DejaVuSansCondensed-Oblique.ttf DejaVuSans-Oblique.ttf

DejaVuSansCondensed-BoldOblique.ttf DejaVuSansCondensed.ttf DejaVuSans.ttf

[root@localhost dejavu]# mv DejaVuSans.ttf DejaVuSans.ttf.bak

[root@localhost dejavu]# mv STFANGSO.TTF DejaVuSans.ttf           
Zabbix server 5.0 LTS版本 搭建

問題解決

繼續閱讀