• CentOS 7.8 x64 安装zabbix 5.0 LTS


    CentOS 7.8 x64 安装zabbix 5.0 LTS

    官网教程

    • https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=nginx
      

    手把手安装

    1. 安装zabbix库

      • $ rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm	
        $ yum clean all	【清除yum缓存】
        
    2. 安装zabbix server 和 agent

      • $ yum install zabbix-server-mysql zabbix-agent
        【后面出现的交互确认 全部选择Y】
        
    3. 安装zabbix前端

      • $ yum install centos-release-scl	【安装前端release】
        
      • $ vi /etc/yum.repos.d/zabbix.repo
        【修改配置】
        	...
        	enabled=1
        	...
        
    4. 安装mysql数据库

      • 本次mysql安装我们选择rpm安装方式,安装的mysql版本为5.7.30
      1. 下载mysql 5.7.30 rpm包

      2. 解压

        • tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
      3. 查看系统里是否已经有安装过mysql,有则卸载

        • rpm -qa|grep mariadb 【查看】
        • rpm -e --nodeps mariadb-libs-5.5.65-1.el7.x86_64【卸载】
      4. 安装mysql5.7所需要的依赖

        • yum install libaio
        • yum install perl
        • yum install net-tools
      5. 安装mysql

        • rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm
        • rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm
        • rpm -ivh mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm
        • rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm
        • rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
      6. 配置mysql数据库

        • 启动mysql

          • systemctl start mysqld.service
        • 查看mysql运行状态

          • systemctl status mysqld.service
        • 找到root初始密码

          • grep "password" /var/log/mysqld.log
        • 修改root密码

          • ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
        • 开启mysql的远程访问【下面命令开启的IP是 192.168.0.1,如要开启所有的,用%代替IP】

          • grant all privileges on . to 'root'@'192.168.0.1' identified by 'password' with grant option;
          • flush privileges;
          • exit
        • 为firewalld添加开放端口【添加mysql端口3306和Tomcat端口8080】

          • firewall-cmd --zone=public --add-port=3306/tcp --permanent
          • firewall-cmd --zone=public --add-port=8080/tcp --permanent
          • 或者选择吧firewalld服务临时关闭【service firewalld stop】
        • 修改字符集

          • 描述【重新登录mysql,然后输入status,经过观察,不难发现里面有两个不是utf-8】

          • 改为utf-8方法:

            • vi /etc/my.cnf

            • 新增下列四行
              [client]
              default-character-set=utf8
              
              character-set-server=utf8
              collation-server=utf8_general_ci
              
            • 实现的效果如下所示:
              ​```
              [client]
              default-character-set=utf8
              # For advice on how to change settings please see
              # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
               
              [mysqld]
              #
              # Remove leading # and set to the amount of RAM for the most important data
              # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
              # innodb_buffer_pool_size = 128M
              #
              # Remove leading # to turn on a very important data integrity option: logging
              # changes to the binary log between backups.
              # log_bin
              #
              # Remove leading # to set options mainly useful for reporting servers.
              # The server defaults are faster for transactions and fast SELECTs.
              # Adjust sizes as needed, experiment to find the optimal values.
              # join_buffer_size = 128M
              # sort_buffer_size = 2M
              # read_rnd_buffer_size = 2M
              datadir=/var/lib/mysql
              socket=/var/lib/mysql/mysql.sock
              character-set-server=utf8
              collation-server=utf8_general_ci
              # Disabling symbolic-links is recommended to prevent assorted security risks
              symbolic-links=0
               
              log-error=/var/log/mysqld.log
              pid-file=/var/run/mysqld/mysqld.pid
              ​```
              
            • 重启mysqld 服务

    5. 初始化zabbix的数据库

      • note:

        • mysql口令:root abcD_123
          zabbix口令:zabbix abcD_123
          
      • mysql> create database zabbix character set utf8 collate utf8_bin; 【修改字符集】

      • mysql> create user zabbix@localhost identified by 'password';【创建用户zabbix和密码】

      • mysql> grant all privileges on zabbix.* to zabbix@localhost;【授权登录】

      • mysql> quit;

      • $ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix 【导入初始化的schema和数据】
        
    6. zabbix server配置

      • $ vi /etc/zabbix/zabbix_server.conf
        DBPassword=password【将数据库password填入】
        
    7. zabbx前端php配置

      • $ vi /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
        【解开注释】
        # listen 80;
        # server_name example.com;
        
      • $ vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
        【修改为】
        listen.acl_users = apache,nginx
        
        【解开注释】
        php_value[date.timezone] = Asia/Shanghai
        
        
    8. 启动zabbix server and agent 进程

      • $ systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
        $ systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
        
    9. 登录zabbix

    10. 安装完成后遇到的问题

      • 问题描述:登录zabbix前端,发现界面下方一直有报错,报错释义”zabbix server启动失败“

      • 查看日志:/var/log/zabbix/zabbix_server.log , 发现无法绑定socket到zabbix_server_alerter.sock,访问被拒绝

      • 原因:selinux问题

      • 解决方法:关闭selunx

        • $ sestatus【查看selinux状态】
          $ vi /etc/selinux/config
          【配置修改如下】
          ...
          SELINUX=disabled
          ...
          SELINUXTYPE=targeted 
          
          $ reboot 【修改配置文件,重启永久关闭】
          或者 $ setenforce 0【临时关闭】
          
  • 相关阅读:
    强大的mono.cecil
    关于svn不能cleanup的问题
    SVN项目,快速查看项目的当前版本号
    jQuery选择器总结
    将Excel数据导入mysql数据库的几种方法
    SpringMVC表单标签简介
    mybatis动态SQL语句
    mysql时间格式化,按时间段查询MYSQL语句
    深入了解ios系统机制
    Eclipse 官方简体中文语言包下载地址及安装方法
  • 原文地址:https://www.cnblogs.com/lich1x/p/14302486.html
Copyright © 2020-2023  润新知