zoukankan      html  css  js  c++  java
  • zabbix 3.2.2 server端(源码包)安装部署 (一)【转】

    环境准备:

    操作系统 CentOS 6.8 2.6.32-642.11.1.el6.x86_64
    zabbix server 172.16.10.150
    zabbix agent 172.16.10.152

    一、zabbix server 端安装部署

    1、快速部署lamp环境:

    yum -y install httpd httpd-devel mysql mysql-server mysql-devel php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml php-bcmath

    2、lamp安装完成检查

    # rpm -qa php httpd mysql 
    php-5.3.3-48.el6_8.x86_64
    mysql-5.1.73-7.el6.x86_64
    httpd-2.2.15-55.el6.centos.2.x86_64

    注:安装zabbix3.0以上版本php需要使用5.4以上版本,因此,如果lamp环境使用yum安装的话,需要将php升级到5.4版本以上。

    3、将php 5.3 升级到 php 5.4步骤

    3.1 安装(epel、remi) yum源:

    复制代码

    # wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

    # rpm -ivh epel-release-6-8.noarch.rpm
    warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
    ...                ########################################### [100%]
       1:epel-release           warning: /etc/yum.repos.d/epel.repo created as /etc/yum.repos.d/epel.repo.rpmnew
    ########################################### [100%]

    # wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

    # rpm -ivh remi-release-6.rpm                                                  
    warning: remi-release-6.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
    Preparing...                ########################################### [100%]
       1:remi-release           ########################################### [100%]

    复制代码

    3.2 修改 (/etc/yum.repos.d/remi.repo) yum 配置文件,将enabled选项设置为1

    复制代码
    [remi]
    name=Remi's RPM repository for Enterprise Linux 6 - $basearch
    #baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
    mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror
    enabled=1                 # 此选项默认值为0,需要修改为1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
    复制代码

    yum 源安装完成,接下来我们就可以进行升级php了。

    3.3 升级php5.3到5.4版本

    #
    yum update php*

    4.3 升级完成检查php版本

    # rpm -qa php
    php-
    5.4.45-12
    .el6.remi.x86_64

    升级后发现php版本已经是5.4了,这样就可以安装zabbix 3.0以上版本了,接下我来们启动http、mysql服务,验证下我们的lamp环境吧。

    4、验证LAMP环境是否可以正常运行

    4.1 启动apache、mysql服务

    # /etc/init.d/httpd start
    # /etc/init.d/mysqld start

    4.2 创建php测试文件

    在/var/www/html/目录下创建index.php测试文件,验证LAMP环境是否正常。
    <?php
    phpinfo();
    ?>

    4.3 通过浏览器访问测试 http://172.16.10.150/index.php

            image

    通过测试结果来看,我们的LAMP环境已经准备好了,接下来我们就要开始zabbix service的安装了。

    5、zabbix server 端安装

    5.1 创建zabbix用户和组

    # groupadd zabbix
    # useradd -g zabbix zabbix -s /sbin/nologin

    5.2 创建zabbix数据库及zabbix帐号

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

    mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zbpass';
    Query OK, 0 rows affected (0.00 sec)

    5.3 解压zabbix-3.2.2安装包,并导入sql

    复制代码
    # tar -xf zabbix-3.2.2.tar.gz 
    # cd zabbix-3.2.2
    # cd database/mysql/
    # ls
    data.sqlimages.sqlschema.sql

    # mysql -uzabbix -pzbpass zabbix < schema.sql
    # mysql -uzabbix -pzbpass zabbix < images.sql
    # mysql -uzabbix -pzbpass zabbix < data.sql
    以上3个sql导入时顺序不能颠倒,否则会报错。

    复制代码

    5.4 安装zabbix所需依赖的软件包

    yum install -y net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel

    5.5 安装zabbix

    复制代码
    # cd /usr/local/src/zabbix-3.2.2
    # ./configure --enable-server --enable-agent --with-mysql --enable-java --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
    # make && make install
    编译过程中报错:
    checking for net-snmp-config... /usr/bin/net-snmp-config
    checking for main in -lnetsnmp... yes
    checking for localname in struct snmp_session... yes
    checking for javac... no
    configure: error: Unable to find "javac" executable in path
    解决方法:
    因为编译安装zabbix服务器没有安装java环境,根据错误提示,无法的到javac中的可执行文件的路径,所以问题很快就可以定位了,我们安装下java环境就ok了。由于安装系统时所选择的包不同,在编译的时候可能还会有其它的报错提示,大家可以根据错误提示,来定位自己的问题。

    可以去掉--enable-java
    复制代码

    5.6 创建zabbix日志目录,并设置相应权限,便于排查问题

    mkdir /var/log/zabbix
    chown -R zabbix.zabbix /var/log/zabbix

    5.7 编辑zabbix_server配置文件(/usr/local/etc/zabbix_server.conf)修改如下内容

    复制代码

    # egrep -v "^#|^$" /usr/local/etc/zabbix_server.conf 
    LogFile=/var/log/zabbix/zabbix_server.log
    DBHost=localhost
    DBName=zabbix
    DBUser=zabbix
    DBPassword=zbpass
    AlertScriptsPath=/usr/local/etc/zabbix/alertscripts

    复制代码

    5.8 创建自定义脚本目录,设置权限,目录下的脚本,可以被zabbix调用

    # mkdir /usr/local/etc/zabbix/alertscripts -pv
    # chown zabbix.zabbix -R /usr/local/etc/zabbix

    5.9 编辑zabbix_agentd配置文件(/usr/local/etc/zabbix_agentd.conf)修改如下内容

    # egrep -v "^$|^#" /usr/local/etc/zabbix_agentd.conf
    LogFile=/var/log/zabbix/zabbix_agentd.log
    Server=127.0.0.1
    ServerActive=127.0.0.1
    Hostname=Zabbix server

    5.10 修改php.ini文件(/etc/php.ini)

    sed -i 's/post_max_size = 8M/post_max_size = 32M/g' /etc/php.ini
    sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php.ini
    sed -i 's/;date.timezone =/date.timezone =PRC/' /etc/php.ini
    sed -i 's/max_execution_time = 30/max_execution_time = 600/g' /etc/php.ini
    sed -i 's/max_input_time = 60/max_input_time = 600/g' /etc/php.ini
    sed -i 's/memory_limit = 128M/memory_limit = 256M/g' /etc/php.ini

    5.11 拷贝zabbix服务端、客户端启动脚本到/etc/init.d目录下

    # cd /usr/local/src/zabbix-3.2.2/misc/
    # cp init.d/tru64/zabbix_server /etc/init.d/
    # cp init.d/tru64/zabbix_agentd /etc/init.d/
    # chmod +x /etc/init.d/zabbix_*

    5.12 修改zabbix_server,zabbix_agentd启动脚本,使其支持chkconfig配置服务

    复制代码
    vim /etc/init.d/zabbix_server
    #!/bin/sh下面一行添加
    #chkconfig: 345 95 95
    #description: Zabbix_Server
    
    vim /etc/init.d/zabbix_agentd
    #!/bin/sh下面一行添加
    #chkconfig: 345 95 95
    #description: Zabbix_agentd
    复制代码

    5.13 添加到系统服务

    chkconfig zabbix_server on

    chkconfig zabbix_agentd on

    5.14 启动zabbix服务

    /etc/init.d/zabbix_server start
    /etc/init.d/zabbix_agentd start

    启动报错

    [root@localhost lib]# /etc/init.d/zabbix_server start
    Starting zabbix_server:  /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
                                                              [FAILED]

    解决方法

    [root@localhost ~]# locate libmysqlclient.so.18
    /usr/local/mysql/lib/libmysqlclient.so.18
    /usr/local/mysql/lib/libmysqlclient.so.18.0.0
    /usr/src/mysql-5.6.10/libmysql/libmysqlclient.so.18
    /usr/src/mysql-5.6.10/libmysql/libmysqlclient.so.18.0.0

    [root@localhost ~]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf

    [root@localhost ~]# ldconfig

    5.15 检查zabbix服务状态

    复制代码
    # netstat -nltp | grep 1005
    tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      16479/zabbix_agentd
    tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      16421/zabbix_server
    tcp        0      0 :::10050                    :::*                        LISTEN      16479/zabbix_agentd
    tcp        0      0 :::10051                    :::*                        LISTEN      16421/zabbix_server
    # netstat -nltp | grep zabbix
    tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      16479/zabbix_agentd
    tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      16421/zabbix_server
    tcp        0      0 :::10050                    :::*                        LISTEN      16479/zabbix_agentd
    tcp        0      0 :::10051                    :::*                        LISTEN      16421/zabbix_server
    复制代码

    5.16 拷贝zabbix web程序到 WEB 服务目录下

    # mkdir /var/www/html/zabbix
    # cp –rf /usr/local/src/zabbix-3.2.2/frontends/php/* /var/www/html/zabbix/

    5.17、重启apache服务

    /etc/init.d/httpd restart

    5.18 通过http://IP/zabbix 进行图形化安装zabbix

            zabbix_install_01

            zabbix_install_02

            zabbix_install_03

    zabbix Error connecting to database: Can't connect to local MySQL server through so

    zabbix到安装界面报错" Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock" - CSDN博客

    https://blog.csdn.net/wzqzhq/article/details/56280720

            zabbix_install_04

            zabbix_install_05

            zabbix_install_06

    下载zabbix.conf.php,上传至/var/www/html/zabbix/conf

            zabbix_install_07

            zabbix_install_09

            zabbix_install_10

    zabbix server 服务端已经安装好了,下面我们再看看,如何安装zabbix agent 客户端吧!

    转自

    zabbix 3.2.2 server端(源码包)安装部署 (一) - miclesvic - 博客园

    https://www.cnblogs.com/miclesvic/p/6144562.html

  • 相关阅读:
    Servlet的数据库访问
    Servlet 网页重定向
    Intellij idea创建javaWeb以及Servlet简单实现
    Tomcat
    QQ简易版
    单例
    centos7 jdk安装
    centos7 allure安装
    centos中执行apt-get命令提示apt-get command not found
    centos mysql使用踩过的坑
  • 原文地址:https://www.cnblogs.com/paul8339/p/8883294.html
Copyright © 2011-2022 走看看