Press "Enter" to skip to content

yum安装最新版Zabbix 3.4.X

主机环境:
[root@test ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core

[root@test ~]# uname -a
Linux test 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Zabbix官网:https://www.zabbix.com/

具体安装步骤:

[root@test ~]# rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm //配置zabbix源,其它版本的zabbix可在http://repo.zabbix.com/zabbix/中查找.
[root@test ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent //安装Zabbix server,web界面,Zabbix agent.此步骤会安装php,http,但是mariadb需要再单独安装
.
.
.(中间省略若干步骤)
Installed:
zabbix-agent.x86_64 0:3.4.9-1.el7 zabbix-server-mysql.x86_64 0:3.4.9-1.el7 zabbix-web-mysql.noarch 0:3.4.9-1.el7

Dependency Installed:
OpenIPMI-libs.x86_64 0:2.0.23-2.el7 OpenIPMI-modalias.x86_64 0:2.0.23-2.el7 dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 fping.x86_64 0:3.10-4.el7
httpd.x86_64 0:2.4.6-80.el7.centos httpd-tools.x86_64 0:2.4.6-80.el7.centos iksemel.x86_64 0:1.4-6.el7 mariadb-libs.x86_64 1:5.5.56-2.el7 php.x86_64 0:5.4.16-45.el7
php-bcmath.x86_64 0:5.4.16-45.el7 php-cli.x86_64 0:5.4.16-45.el7 php-common.x86_64 0:5.4.16-45.el7 php-gd.x86_64 0:5.4.16-45.el7 php-ldap.x86_64 0:5.4.16-45.el7
php-mbstring.x86_64 0:5.4.16-45.el7 php-mysql.x86_64 0:5.4.16-45.el7 php-pdo.x86_64 0:5.4.16-45.el7 php-xml.x86_64 0:5.4.16-45.el7 zabbix-web.noarch 0:3.4.9-1.el7

Complete! //说明安装成功
[root@test yum.repos.d]# yum install -y mariadb mariadb-server //安装mariadb,CentOS 7中,已经使用MariaDB替代了MySQL数据库
[root@test yum.repos.d]# systemctl start mariadb //启动mariadb
[root@test yum.repos.d]# mysql_secure_installation //为root账户设置密码

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): //直接回车,一开始默认root用户没设置密码
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 //是否立即设置root的密码,选择Y
New password: //输入密码,这个密码要记住,是mysql的root用户的密码
Re-enter new password: //再次输入一样的密码
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 //是否移除匿名用户,选择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] Y //是否禁止root用户远程登录mysql,选择是
... Success!

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 //是否移除测试库,选择Y
- 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 //是否重新加载权限,选择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@test yum.repos.d]# systemctl restart mariadb //重启mariadb
[root@test yum.repos.d]# mysql -u root -p //测试本地连接,并配置zabbix相关用户、密码等
Enter password: //输入刚刚创建的root密码
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

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

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

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.01 sec) 


MariaDB [(none)]> create database zabbix character set utf8; //创建数据库zabbix,并且数据库编码使用utf8
Query OK, 1 row affected (0.00 sec)


MariaDB [(none)]> insert into mysql.user(Host,User,Password) values('localhost','zabbix',password('123456')); //新建账户zabbix,密码123456,生产环境用复杂密码,我这里只是测试安装
Query OK, 1 row affected, 4 warnings (0.00 sec)


MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'localhost' identified by '123456' with grant option; //允许账户zabbix能从本机连接到数据库zabbix,并授予所有权限

MariaDB [(none)]> flush privileges; //刷新系统授权表
[root@test ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz |mysql -u zabbix -p zabbix //初始化数据,mysql -u zabbix(用户为zabbix) -p zabbix(这是刚刚创建的zabbix数据库)
Enter password: //数据zabbix用户的密码,就是上面刚刚创建的
[root@test doc]# vi /etc/zabbix/zabbix_server.conf //配置zabbix server的数据库,默认配置为/etc/zabbix/zabbix_server.conf
DBHost=localhost //数据库主机
DBName=zabbix //使用的数据库
DBUser=zabbix //数据库用户
DBPassword=123456 //zabbix库的密码
[root@test zabbix]# vi /etc/php.ini //修改PHP配置文件,设置时区,这步一定要弄,不然web页面设置的时候会报错
date.timezone = PRC #把前面的分号去掉,改为date.timezone = PRC,这步一定要弄,不然web页面设置的时候会报错
[root@test conf.d]# systemctl start httpd //启动httpd服务
[root@test conf.d]# systemctl start zabbix-server //启动zabbix server

浏览器输入IP/zabbix进行zabbix web配置:

配置mysql相关信息(密码就是上面创建的123456),如下:

Name随便填,将在浏览器的标签页显示,如下:

说明安装成功,如下:

点击上图的Finish按钮会跳到登录页面,默认的登录用户、密码分别为admin/zabbix,如下:

默认的初始dashboard页面,虽然我安装了zabbix agent但是没有配置和启动,所以页面都是空白,如下:

首次登录后可以修改默认语言和默认登陆密码(登录密码必须修改,默认登录密码为zabbix,知道的人都知道),点击右上角的“人型”图标,见下图标红处,我这里已经修改好了,所以为中文:

点击如下两个标红处分别修改密码和语言:

至此,安装成功.

总结:
yum安装还是比较方便的,但是不方便选择php和http的版本.若对php和httpd版本有要求的话,可以编译安装,编译安装可参考https://www.tracymc.cn/archives/218

One Comment

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注