NO.B.0003——zabbix_zabbix-server.yum源安装_V.201027

一、硬件环境准备:

ZABBIX Server端 : 192.168.1.59
ZABBIX Agent端:   192.168.1.60
Linux 系统版本:CentOS linux release 7.6.1810(Core)
zabbix版本:zabbix 4.0.6 LTS (截止2019年4月1日最新版本)

二、安装zabbix:

//1、 首先添加zabbix仓库:
[root@localhost ~]# 
> rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
// 把zabbix.repo里面的文件内容替换为以下内容:
[root@localhost ~]# cat>/etc/yum.repos.d/zabbix.repo<<EOF
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/zabbix/RPM-GPG-KEY-ZABBIX
gpgcheck=1
EOF

#、(可选项)zabbix前端基本安装中不提供其他软件包,需要在运行zabbix前端的系统中启用可选rpm的存储库
[root@localhost ~]# yum-config-manager --enable rhel-7-server-optional-rpms
//2、安装Zabbix-server:
[root@localhost ~]# yum -y install zabbix-server-mysql
#、安装zabbix-Proxy(代理服务器,半分布式的,若不需要,可暂时不安装)
[root@localhost ~]# yum -y install zabbix-proxy-mysql
//3、安装zabbix-front-web
[root@localhost ~]# yum -y install zabbix-web-mysql

安装和配置数据库

//4、安装Mariadb database
[root@localhost ~]# yum -y install mariadb-server
[root@localhost ~]# systemctl start mariadb.service         //启动数据库
[root@localhost ~]# msyql_secure_installation               //设置Mariadbroot初始化密码
[root@localhost ~]# mysql -uroot -p123456
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;  
                                    //创建数据库,名称为zabbix并且字符为utf8
MariaDB [(none)]> create user 'zabbix'@'localhost' identified by '123456'; 
                                    //创建zabbix用户并设置密码
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost'; 
                                    //授权zabbix用户从localhost访问,对zabbix数据库有完全控制权限
MariaDB [(none)]> flush privileges;         //刷新权限
MariaDB [(none)]> exit                      // 退出

// 使用MySQL导入服务器的出事架构和数据; zabbix = use zabbix;切换到zabbix数据库之下
[root@localhost ~]# 
> zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456 zabbix
MariaDB [zabbix]> show tables;              // 查看数据导入是否成功

// 针对zabbix-server配置数据库:
[root@localhost ~]# vi /etc/zabbix/zabbix_server.conf
# LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost        // 数据库主机
DBName=zabbix           // 数据库名称
DBUser=zabbix           // 数据库用户名
DBPassword=<password>   // 数据库密码
# DBSocket=/var/lib/mysql/mysql.sock

//5、启动zabbix-server
[root@localhost ~]# systemctl restart zabbix-server.service

设置front-web服务
//6、设置zabbix-front-web

[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
# php_value date.timezone Europe/Riga
  php_value date.timezone Asia/Shanghai

重启所有服务:

//7、启动zabbix-server、mariadb-server、httpd服务,并设置开机自启动。
[root@localhost ~]# systemctl restart zabbix-server.service
[root@localhost ~]# systemctl enable zabbix-server.service
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl enable mariadb.service
[root@localhost ~]# systemctl start httpd.service
[root@localhost ~]# systemctl enable httpd.service

注意事项:关闭selinux和firewalld.service

效验我们所安装的是否正常:

通过如下命令进行效验:
[root@localhost ~]# ss -tunlp
    zabbix-server 监听端口为tcp 10051
    zabbix-agent 监听端口为tcp 10050

三、Zabbix WEB GUI安装配置:
通过浏览器Zabbix_WEB验证,过浏览器访问http://server_ip/zabbix
默认用户名:Admin 密码:zabbix
在这里插入图片描述

单击Next step,如果有错误提示,需要把错误依赖解决完,方可进行Next step操作。
在这里插入图片描述

如上异常错误解决方法代码如下,安装缺失的软包,并修改php.ini对应参数的值即可,

yum  install  php-mbstring  php-bcmath  php-gd  php-xml  -y
yum  install  gd  gd-devel  -y
sed   -i '/post_max_size/s/8/16/g;/max_execution_time/s/30/300/g;/max_input_time/s/60/300/g;s
>  /\;date.timezone.*/date.timezone \= PRC/g;s/\;always_populate_raw_post_data/
>  always_populate_raw_post_data/g'  /etc/php.ini

service  httpd  restart

在这里插入图片描述

单击Next step,配置数据库连接,输入数据库名、用户、密码,单击Test connection,显示OK,单击Next step即可。
在这里插入图片描述

继续单击Next step出现如图所示,填写Zabbix Title显示,可以为空,可以输入自定义的名称。

在这里插入图片描述

单击下一步,需修创建zabbix.conf.php文件,执行如下命令,或者单击“Download the configuration file”下载zabbix.conf.php文件,并将该文件上传至/var/www/html/conf/,并设置可写权限,刷新WEB页面,zabbix.conf.php内容代码如下,最后单击Finish即可:

<?php
// Zabbix GUI configuration file.
global $DB;

$DB['TYPE']     = 'MYSQL';
$DB['SERVER']   = 'localhost';
$DB['PORT']     = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER']     = 'zabbix';
$DB['PASSWORD'] = '123456';

// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';

$ZBX_SERVER      = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = 'ZABBIX监控系统';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;

在这里插入图片描述

安装前摘要,若一切正常,直接单击Next step
在这里插入图片描述

恭喜你!你已安装ZABBIX前端;单击Finish
在这里插入图片描述

登录Zabbix WEB界面,默认用户名和密码为:Admin/zabbix,
在这里插入图片描述

ZABBIX WEB后台管理界面

在这里插入图片描述

猜你喜欢

转载自blog.51cto.com/15005403/2552371