ZabbixServer的安装步骤(-)步骤篇

1centos7.5 系统服务器3台、 一台作为监控服务器, 两台台作为被监控节点, 配置好yum源、 防火墙关闭、 各节点时钟服务同步、 各节点之间可以通过主机名互相通信。

1、所有机器关闭防火墙和 selinux
[root@yzh.com ~]# setenforce 0 (修改配置文件关闭)
[root@yzh.com ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 
[root@yzh.com ~]# systemctl stop firewalld.service

----安装zabbix----

1、下载 yum 仓库
[root@yzh.com ~]# yum -y install wget
[root@yzh.com ~]# wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

# 安装zabbix源(官方)
[root@yzh.com ~]# rpm -ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
2、安装 yum 仓库
[root@yzhvvv.com ~]# rpm -ivh zabbix-release-4.2-1.el7.noarch.rpm
3、更新 yum 仓库
[root@yzh.com ~]# yum repolist 
Loaded plugins: fastestmirror, langpacks  
Loading mirror speeds from cached hostfile
zabbix-non-supported                                                      4/4
repo id                     repo name                                   status
base                        base                                         9,363
epel                        epel                                        11,349
zabbix/x86_64               Zabbix Official Repository - x86_64             80
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported -       4
repolist: 20,796	~~删除线格式~~ 

4、安装 Zabbix
[root@yzh.com~]# yum -y install epel-release.noarch
[root@yzh.com~]# yum -y install zabbix-agent zabbix-get zabbix-sender zabbix-server-mysql zabbix-web zabbix-web-mysql
或者(官方)
[root@yzh.com~]# yum-config-manager --enable rhel-7-server-optional-rpms
2)安装设置数据库:
1、创建 mariadb.repo
[root@yzh.com ~]# vim /etc/yum.repos.d/mariadb.repo
写入以下内容:
[mariadb]
name = MariaDB 
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.4/centos7-amd64 
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB 
gpgcheck=1
2、yum 安装最新版本 mariadb
[root@yzh.com ~]# yum install -y MariaDB-server MariaDB-client
3、修改配置文件
[root@yzh.com ~]# vim /etc/my.cnf.d/server.cnf
    [mysqld]
    skip_name_resolve = ON          # 跳过主机名解析
    innodb_file_per_table = ON      # 开启独立表空间
    innodb_buffer_pool_size = 256M  # 缓存池大小
    max_connections = 2000          # 最大连接数
    log-bin = master-log            # 开启二进制日志

4、重启数据库服务

[root@yzh.com~]# systemctl restart mariadb
[root@yzh.com~]# mysql_secure_installation  # 初始化mariadb

5、创建数据库并授权账号

MariaDB [(none)]> create database zabbix character set 'utf8';  # 创建zabbix数据库
MariaDB [(none)]> grant all on zabbix.* to 'zbxuser'@'192.168.37.%' identified by 'keer';										# 注意授权网段
MariaDB [(none)]> flush privileges;           # 刷新授权

6、导入 Zabbix 服务表
查看 zabbix-server-mysql 这个包提供了什么

[root@yzh.com~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.2.6
/usr/share/doc/zabbix-server-mysql-3.2.6/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.2.6/COPYING
/usr/share/doc/zabbix-server-mysql-3.2.6/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.2.6/NEWS
/usr/share/doc/zabbix-server-mysql-3.2.6/README
/usr/share/doc/zabbix-server-mysql-3.2.6/create.sql.gz      # 生成表的各种脚本
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix

使用 create.sql.gz 生成所需要的表

[root@yzh.com~]# gzip -d create.sql.gz
[root@yzh.com~]# head  create.sql           #查看一下表头
CREATE TABLE `users` (
    `userid`                 bigint unsigned                           NOT NULL,
    `alias`                  varchar(100)    DEFAULT ''                NOT NULL,
    `name`                   varchar(100)    DEFAULT ''                NOT NULL,
    `surname`                varchar(100)    DEFAULT ''                NOT NULL,
    `passwd`                 char(32)        DEFAULT ''                NOT NULL,
    `url`                    varchar(255)    DEFAULT ''                NOT NULL,
    `autologin`              integer         DEFAULT '0'               NOT NULL,
    `autologout`             integer         DEFAULT '900'             NOT NULL,
    `lang`                   varchar(5)      DEFAULT 'en_GB'           NOT NULL,

查看表头发现没有创建数据库的命令,这正是手动创建数据库的原因。把所需表导入数据库即可:

[root@yzh.com ~]# mysql -uzbxuser -h192.168.37.111 -p zabbix < create.sql 
Enter password:

导入以后,我们进去数据库查看一下:

[root@yzh.com ~]# mysql -uzbxuser -h192.168.37.111 -p
Enter password:
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| zabbix             |
+--------------------+
MariaDB [(none)]> use zabbix;
Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
……
| usrgrp                     |
| valuemaps                  |
+----------------------------+
127 rows in set (0.00 sec)

可以看出来,我们的数据已经导入成功了。

3、配置 server 端

数据库准备好了以后,我们要去修改 server 端的配置文件。

[root@yzh.com ~]# cd /etc/zabbix/
[root@yzh.com zabbix]# ls
web  zabbix_agentd.conf  zabbix_agentd.d  zabbix_server.conf
#为了方便我们以后恢复,我们把配置文件备份一下
[root@yzh.com zabbix]# cp zabbix_server.conf{,.bak}
[root@yzh.com zabbix]# vim zabbix_server.conf
ListenPort=10051            # 默认监听端口
SourceIP=192.168.37.111     # 发采样数据请求的 IP
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值