• centos6安装zabbix4.0


    安装

    [root@localhost ~]#yum install httpd –y

    检查版本

    [root@localhost ~]#httd –v

    安装yum源

    [root@localhost ~]#rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

    [root@localhost ~]#rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

    [root@localhost ~]#rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/6/x86_64/zabbix-release-4.0-2.el6.noarch.rpm

    [root@localhost ~]#rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

    [root@localhost ~]#rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm

    [root@localhost ~]#yum clean all

    安装zabbix

    [root@localhost ~]#wget http://repo.zabbix.com/zabbix/4.0/rhel/6/x86_64/zabbix-release-4.0-1.el6.noarch.rpm

    [root@localhost ~]#rpm -ivh zabbix-release-4.0-1.el6.noarch.rpm

    查看php版本:

    [root@localhost ~]#yum list php7*

    安装php

    [root@localhost ~]#yum -y install `yum list|grep php70w|awk '{printf ("%s ",$1)}'` --skip-broken

    检查:

    [root@localhost ~]#rpm -ql zabbix-release

    安装:

    [root@localhost ~]#yum -y install zabbi x zabbix-server zabbix-server-mysql

    [root@localhost ~]#yum -y install zabbix-web zabbix-web-mysql

    [root@localhost ~]#yum -y install zabbix-agent

    安装mysql需要调整 vim /etc/yum.repos.d/mysql-community.repo 设置需要安装的版本

    [root@localhost ~]#yum -y install mysql-server mysql

    【mysql初始化设置:

    设置远程访问:

    mysql> SELECT User, Password, Host FROM user;

    mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.116.96.38' IDENTIFIED BY '123456' WITH GRANT OPTION;

    mysql> FLUSH PRIVILEGES;

    其中"*.*"代表所有资源所有权限, “'root'@%”其中root代表账户名,%代表所有的访问地址,也可以使用一个唯一的地址进行替换,只有一个地址能够访问。如果是某个网段的可以使用地址与%结合的方式,如10.0.42.%。IDENTIFIED BY 'root',这个root是指访问密码。WITH GRANT OPTION允许级联授权。】

    [root@localhost ~]#yum -y install zabbix-agent

    【出错:

    事务测试出错:

      file /etc/zabbix/zabbix_agentd.conf from install of zabbix-agent-4.0.9-3.el6.x86_64 conflicts with file from package zabbix22-2.2.23-1.el6.x86_64

    分析:安装zabbix-agent-4.0从package zabbix22-2.2中发生冲突,通过

             [root@localhost ~]#rpm –qa | grep zabbix确认后

    解决:

             移除发生冲突的版本

             [root@localhost ~]#yum -y remove zabbix22-2.2.23-1.el6.x86_64

    配置zabbix服务相关:

    配置mysql

    [root@localhost ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

    [root@localhost ~]# vim /etc/my.cnf

    在[mysqld](第26行)标签下增加如下三行后保存

    [mysqld]

    character-set-server = utf8

     init-connect = 'SET NAMES utf8'

     collation-server = utf8_general_ci

    启动mysql数据库,进行初始化:

    [root@localhost ~]# /etc/init.d/mysqld start

    [root@localhost ~]#mysql -uroot –p  [没有密码,直接敲回车]

    mysql>create database zabbix character set utf8 collate utf8_bin;

    mysql>grant all privileges on zabbix.* to zabbix@localhost identified by 'password';

    mysql>flush privileges;

    mysql>exit

    mysql -uzabbix –p  [使用刚才使用的password确认登录,后面会用到这个密码]

    导入表结构

    [root@localhost ~]#zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

    配置zabbix相关

    [root@localhost ~]#sed -i 's/^.*DBPassword=.*$/DBPassword=zabbix/' /etc/zabbix/zabbix_server.conf

    [root@localhost ~]#service zabbix-server start

    [root@localhost ~]#service zabbix-agent start

    [root@localhost ~]#sed -i 's/^.*date.timezone =.*$/date.timezone = Asia/Shanghai/g' /etc/php.ini

    [root@localhost ~]#sed -i 's/^.*post_max_size =.*$/post_max_size = 16M/g' /etc/php.ini

    [root@localhost ~]#sed -i 's/^.*max_execution_time =.*$/max_execution_time = 300/g' /etc/php.ini

    [root@localhost ~]#sed -i 's/^.*max_input_time =.*$/max_input_time = 300/g' /etc/php.ini

    [root@localhost ~]#cp -R /usr/share/zabbix /var/www/html/

    [root@localhost ~]#chown apache:apache -R /var/www/html/zabbix

    [root@localhost ~]#service httpd restart

    [root@localhost ~]#chkconfig mysqld on

    [root@localhost ~]#chkconfig zabbix-server on

    [root@localhost ~]#chkconfig zabbix-agent on

    [root@localhost ~]#chkconfig httpd on

    在防火墙内,插入以下策略

    [root@localhost ~]#vim /etc/sysconfig/iptables

    -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

    [root@localhost ~]#/etc/init.d/iptables restart

    通过这个地址访问http://Server_IP/zabbix/

     

     

    安装邮件服务

    [root@localhost ~]#yum install -y mailx

    在/etc/mail.rc最后加入一下内容

    [root@localhost ~]#vi /etc/mail.rc

    set from=2932826605@qq.com

    set smtp=smtp.qq.com

    set smtp-auth-user=2932826605@qq.com

    set smtp-auth-password="wyrsyywqabivdggi"

    #这个密码是QQ邮箱的独立密码,不是登录密码

    #set smtp-auth-password="plepncdsciaceafc"

    set smtp-auth=login

    [root@localhost ~]#vi /usr/lib/zabbix/alertscripts/mail.sh

    #!/bin/sh

    FILE=/tmp/mailtmp.txt

    echo "$3" > $FILE

    dos2unix -k $FILE ###解决了发送的邮件内容变成附件的问题。

    echo -e "$FILE" | mail -s "$2" $1 < $FILE

    rm -rf /tmp/mailtmp.txt

    ##$1 收件人地址  $2 邮件标题  $3邮件内容

    给文件赋予执行权限

    [root@localhost ~]#chmod +x mail.sh

    测试邮件是否正常发送

    [root@localhost ~]#./mail.sh 15775977551@163.com 邮箱主题 邮件内容

    Web页面配置

     

    名称自定义

    类型选择:脚本

    脚本名称是刚才在usr/lib/zabbix/alertscripts/下的mail.sh

    脚本参数请参考官方文档:

    https://www.zabbix.com/documentation/3.0/manual/appendix/macros/supported_by_location

    这里第一个参数为收件人,第二个参数为对象,即标题名称,第三个参数为内容

    测试是否正常发送邮件:

     

    专注
  • 相关阅读:
    Service Fabric 用 Powershell 部署应用到本地
    Redis 高可用之哨兵模式(二)
    Redis 高可用之哨兵模式
    微服务之Service Fabric 系列 (一):概览、环境安装
    Nginx 负载均衡
    Redis 总结
    微服务示例-Spring Cloud
    ASP.NET Core Linux 发布
    Windows RabbitMQ 安装
    Nancy 框架学习
  • 原文地址:https://www.cnblogs.com/jimmyTang-J/p/11175992.html
Copyright © 2020-2023  润新知