zabbix 安装(yum)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix 安装(yum)相关的知识,希望对你有一定的参考价值。

环境:

系统版本:CentOS Linux release 7.3.1611 (Core)_X86_64
软件版本:zabbix 3.4.1-1.el7

安装方式:

Source code:源码包,需要编译程序: 
编译好的程序包; 
        rpm: 
                epel repository 
                zabbix repository 
        ded 
官方长期维护版本: 
        2.2;2.4;3.0(带LTS标志)

rpm安装

安装环境要求: 
    Apache      1.3.12     or later 
    php            5.4.0 or later 
具体看官方文档 :
https://www.zabbix.com/documentation/3.4/manual/installation/requirements 

安装erel源:

# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm


安装zabbix-3.4-1.el7的yum源:

# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm

# rpm -q zabbix-release

zabbix-release-3.4-1.el7.centos.noarch


# yum repolist 
已加载插件:fastestmirror 
Loading mirror speeds from cached hostfile 
* base: mirrors.aliyun.com 
* epel: mirrors.aliyun.com 
* extras: mirrors.aliyun.com 
* updates: mirrors.aliyun.com 
源标识                                             源名称                                                                         状态 
!base/7/x86_64                             CentOS-7 - Base - mirrors.aliyun.com                         9,363 
!epel/x86_64                                 Extra Packages for Enterprise Linux 7 - x86_64         11,896 
!extras/7/x86_64                           CentOS-7 - Extras - mirrors.aliyun.com                         451 
!updates/7/x86_64                        CentOS-7 - Updates - mirrors.aliyun.com                  2,146 
!zabbix/x86_64                               Zabbix Official Repository - x86_64                                28 
!zabbix-non-supported/x86_64     Zabbix Official Repository non-supported - x86_64        4 
repolist: 23,888 
#


注意:CentOS 6 需单独安装安装: 
    yum install httpd 
    php>5.4

安装zabbix DB:

参考:https://www.zabbix.com/documentation/3.4/manual/appendix/install/db_scripts 
    # shell> yum install mariadb-server 
    # shell> systemctl start mariadb.service 
    # shell> mysql -uroot -p 
    # mysql> create database zabbix character set utf8 collate utf8_bin; 
    # mysql> grant all privileges on zabbix.* to [email protected] identified by ‘‘; 
    # mysql> quit;


参考:https://www.zabbix.com/documentation/3.4/manual/installation/install_from_packages/rhel_centos 

安装服务端:

    # yum install zabbix-server-mysql zabbix-get 
    注:zabbix-server服务包含在zabbix-server-mysql包里;

安装web GUI:

# yum install zabbix-web zabbix-web-mysql

安装agent端:

# yum install zabbix-agent zabbix-sender

zabbbix server初始化:

2.x:三个sql脚本
    # cd /usr/share/doc/zabbix-server-mysql-2.4.0/create
    # mysql -uroot zabbix < schema.sql
    # mysql -uroot zabbix < images.sql
    # mysql -uroot zabbix < data.sql
3.x:一个sql脚本
    # zcat /usr/share/doc/zabbix-server-mysql-3.0.*/create.sql.gz | mysql -uzabbix -p zabbix
    或
    # cd /usr/share/doc/zabbix-server-mysql-3.0.*/
    # gzip -d create.sql.gz
    # mysql [-h 127.0.0.1] -uzabbix -p zabbix < create.sql

启动zabbix-server进程

配置文件:/etc/zabbix/zabbix-server.conf
    # cd /etc/zabbix/
    # cp zabbix-server.conf{,.bak}
    # vim /etc/zabbix/zabbix_server.conf
        DBHost=localhost            # 81    数据库服务器地址    
        DBName=zabbix               # 101   数据库库名
        DBUser=zabbix               # 115   mysql普通用户
        DBPassword=<password>       # 125   mysql密码
    # egrep ‘^DBHost|^DBName|^DBUser|^DBPassword‘ /etc/zabbix/zabbix_server.conf
    指令有四类:
        ############ GENERAL PARAMETERS #################通用指令
        ############ ADVANCED PARAMETERS ################高级指令
        ####### LOADABLE MODULES #######加载模块
        ####### TLS-RELATED PARAMETERS #######和TLS有关的配置
    通用参数:
        ListenPort:默认端口:10051
        SourceIP:当zabbix_server有多个IP时,不是对方授权的,需启用具体服务端IP;
        LogType=file    # 日志类型,默认自我独立
        LogFile=/var/log/zabbix/zabbix_server.log   # 日志路径
        LogFileSize=0   #日志大小限制,建议改为1024;
        PidFile=/var/run/zabbix/zabbix_server.pid   # 服务端pid文件路径
        DBHost=localhost            # 91    数据库服务器地址    
        DBName=zabbix               # 101   数据库库名
        DBUser=zabbix               # 115   mysql普通用户
        DBPassword=<password>       # 125   mysql密码
        DBSocket=/tmp/mysql.sock    # 当数据库和zabbix——server在同一台主机时,改为mysql的sock路径;
        DBPort=3306                 # mysql的监听端口

CentOS 6:/etc/init.d/zabbix-server
    # server zabbix-server start
    # server zabbix-server status

CentOS 7:/usr/lib/systemd/system/zabbix-server.service
    # systemctl start zabbix-server.service
    # systemctl status zabbix-server.service

    # ss -tnl |grep :10051
    # iptables -vnL     #防火墙没有阻断10051端口;

    注意:CentOS为7.0或7.1时,请把trousers包更新到0.3.11以后;否则一启动,就挂掉;
    # rpm -q trousers
    # rpm -q php-mysql

配置zabbix-web

配置PHP的时区指定:
    (1):php全局(此文件不配置,只是说明,二者配置一个即可)
        php.ini
    (2):zabbix应用程序
        # vim /etc/httpd/conf.d/zabbix.conf
            # php_value date.timezone Europe/Riga   # 改为
            php_value date.timezone Asia/Shanghai
        或
        # sed -i ‘[email protected]# php_value date.timezone Europe/[email protected]_value date.timezone Asia/[email protected]‘ zabbix.conf、

启动httpd 
        CentOS 6: 
                # service httpd start 
        CentOS 7: 
                # systemctl start httpd.service 

        # ss -tnl |grep :80

通过web界面安装zabbix

参考:https://www.zabbix.com/documentation/3.4/manual/installation/install#installing_frontend 
        访问URL :httpd://IP/zabbix             # IP为zabbix-server所在服务器IP地址 

                主页面 
                         setup 
                依赖关系检测;各项都为OK 
                         Next step 
                KWallet钱包系统-基本设置 
                         取消(下一步) 
                连接数据库配置 
                        数据库类型 
                        host 
                        port # 0表示默认 
                        DB name: #库名称 
                        user 
                        password 
                连接测试: 
                        host: # 主机地址 
                        Port:10051 
                        Name 
                配置列表简要 
                install 
                        安装后生成的配置文件:/etc/zabbix/web/zabbix.conf.php 
                        选择:Finish 
                登录: 
                        username:Admin 
                password:zabbix 

接下来就是配置监控项了。

本文出自 “毛虫小臭臭” 博客,请务必保留此出处http://moerjinrong.blog.51cto.com/11124564/1964705

以上是关于zabbix 安装(yum)的主要内容,如果未能解决你的问题,请参考以下文章

yum安装zabbix

zabbix2.4 yum安装

CentOS 7 yum安装Zabbix

安装Zabbix到CentOS(YUM)

[原创] zabbix学习之旅二:yum安装

YUM安装Zabbix