在安装zabbix中,使用官网的下载源会出现一些下载不完的情况,因为zabbix的官网源是在国外的

现在我们安装zabbix3.4作为演示,安装其它版本可以选择对应的版本

安装前,需要关闭防火墙

[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]#setenforce 0

1、配置阿里云的zabbix yum 源

配置阿里云zabbix yum源

先找到zabbix rpm文件地址

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

[root@localhost ~]# rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm

备份下载repo文件并替换repo文件

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup
[root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost yum.repos.d]# mv Centos-7.repo CentOS-Base.repo

执行yum源更新命令

[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum makecache
[root@localhost yum.repos.d]# yum update -y

2、更换zabbix国内源

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

更改baseurl的地址为阿里云的地址

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

添加gpgkey

[root@localhost yum.repos.d]# curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591 -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[root@localhost yum.repos.d]# curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

添加之后即可使用,更新源

[root@localhost yum.repos.d]# yum makecache -y

3、安装zabbix

   安装相关软件

[root@localhost yum.repos.d]# yum install zabbix-server zabbix-web zabbix-server-mysql zabbix-web-mysql mariadb-server mariadb zabbix-agent -y

  修改PHP时区配置

[root@localhost yum.repos.d]# vi /etc/httpd/conf.d/zabbix.conf 
<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted

    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        # php_value date.timezone Europe/Riga
    </IfModule>
</Directory>

  # php_value date.timezone Europe/Riga 取消注释并修改时区为 Asia/Shanghai

php_value date.timezone Asia/Shanghai

  更改web端口(也可以不更改)

[root@localhost yum.repos.d]# vi /etc/httpd/conf/httpd.conf
    Listen 8088
    ServerName IP:8088

重启apache服务,systemctl restart httpd

  数据库配置

[root@localhost yum.repos.d]# systemctl start mariadb

  创建zabbix所有的数据库以及用户

[root@localhost yum.repos.d]# mysql

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit;
Bye

  导入zabbix数据

[root@localhost yum.repos.d]# cd /usr/share/doc/zabbix-server-mysql-3.4.15/
[root@localhost zabbix-server-mysql-3.4.15]# ll
total 2120
-rw-r--r--. 1 root root      98 Nov 12  2018 AUTHORS
-rw-r--r--. 1 root root  866545 Nov 12  2018 ChangeLog
-rw-r--r--. 1 root root   17990 Nov 12  2018 COPYING
-rw-r--r--. 1 root root 1267039 Nov 12  2018 create.sql.gz
-rw-r--r--. 1 root root      52 Nov 12  2018 NEWS
-rw-r--r--. 1 root root    1062 Nov 12  2018 README 
[root@localhost zabbix-server-mysql-3.4.15]# zcat create.sql.gz |mysql -uzabbix -p123456 zabbix

  修改zabbix配置文件

[root@localhost zabbix-server-mysql-3.4.15]#vi /etc/zabbix/zabbix_server.conf
DBHost=192.168.1.X      #数据库地址
DBName=zabbix   #数据库名
DBUser=zabbix   #数据库用户
DBPassword=123456   #数据库密码

  启动zabbix及httpd 

[root@localhost zabbix-server-mysql-3.4.15]#systemctl start httpd.service
[root@localhost zabbix-server-mysql-3.4.15]#systemctl start zabbix-server.service

  用浏览器访问

http://服务器ip:端口/zabbix/setup.php

默认超级管理员账号:Admin

       密码:zabbix

 

posted on 2020-05-19 14:56  草根920  阅读(3402)  评论(0编辑  收藏  举报