安装zabbix监控服务

一、架构设计

1.服务器准备

主机 IP1 作用 备注
zabbix-server 192.168.16.173 监控端+被监控+mysql(主)
zabbix-mysql从服务器 192.168.17.173 监控端+被监控+mysql(从)
agent 192.168.17.174 被监控节点
agent 192.168.17.175 被监控节点

二、数据库准备

zabbix的工作主要是采集、存储、报警、展示
这里用mysql数据库提供存储

1.主服务器安装配置mariadb-server

yum -y install mariadb-server 
vim   /etc/my.cnf
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    symbolic-links=0
    server_id=163
    innodb_file_per_table=ON
    innodb_buffer_pool_size=256M
    max_connections=2000
    log_bin=/var/log/mariadb/log_bin
    skip_name_resolve
    [mysqld_safe]
    log-error=/var/log/mariadb/mariadb.log
    pid-file=/var/run/mariadb/mariadb.pid
    !includedir /etc/my.cnf.d
systemctl start mariadb
mysql_secure_installation

2.mariadb从服务器安装配置

在主服务器上创建从服务器要使用的用户

grant replication slave,replication client on *.* to  slave@'192.168.17.173' identified by 'slave';

#查看当前二进制日志事务位置
show master status;
            log_bin.000001 |      418

从服务器安装配置

yum -y install mariadb-server 
vim   /etc/my.cnf
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    symbolic-links=0
    server_id=173
    relay_log=/var/log/mariadb/log_relog
    log_bin=/var/log/mariadb/log_bin
    log_slave_updates=1
    [mysqld_safe]
    log-error=/var/log/mariadb/mariadb.log
    pid-file=/var/run/mariadb/mariadb.pid
    !includedir /etc/my.cnf.d
systemctl start mariadb
mysql_secure_installation

从服务器使用授权用户与主服务器同步

change master to master_host='192.168.16.173', master_user='slave', master_password='slave', master_log_file='log_bin.000001',master_log_pos=418;

start slave;

3.sql语句创建zabbix的数据库和用户

MariaDB [(none)]> create database zabbixdb character set 'utf8';

MariaDB [(none)]> grant all on zabbixdb.* to zabbix@'192.168.17.%' identified by 'zabbix';
或grant all on zabbixdb.* to zabbix@'localhost' identified by 'zabbix'; 

二、zabbix-server安装并初始化数据库

1..安装zabbix-server

1.yum源安装

1.下载安装epel源程序包,会自动生成对应的epel源
http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
rpm -ih  zabbix-release-3.4-2.el7.noarch.rpm
2.安装相应zabbix程序包
yum clean all
yum repolist

yum install
    zabbix-server-mysql-3.2.6-1.el7.x86_64.rpm
    zabbix-web-3.2.6-1.el7.noarch.rpm
    zabbix-web-mysql-3.2.6-1.el7.noarch.rpm
    zabbix-agent-3.2.6-1.el7.x86_64.rpm
    zabbix-get-3.2.6-1.el7.x86_64.rpm
    zabbix-sender-3.2.6-1.el7.x86_64.rpm 

2.本地安装
链接:https://pan.baidu.com/s/1dFaYbyL 密码:cg0g

yum install
    zabbix-server-mysql-3.2.6-1.el7.x86_64.rpm
    zabbix-web-3.2.6-1.el7.noarch.rpm
    zabbix-web-mysql-3.2.6-1.el7.noarch.rpm
    zabbix-agent-3.2.6-1.el7.x86_64.rpm
    zabbix-get-3.2.6-1.el7.x86_64.rpm
    zabbix-sender-3.2.6-1.el7.x86_64.rpm 

2.初始化数据库

数据库初始化sql脚本

rpm -ql zabbix-server-mysql
cp /usr/share/doc/zabbix-server-mysql-3.2.6/create.sql.gz .
gzip -d create.sql.gz 

指定数据库名,初始化数据库

mysql -uzabbix -pzabbix zabbixdb <create.sql 

3.配置zabbix-server

vim  /etc/zabbix/zabbix_server.conf
修改
    ListenPort=10051
    SourceIP=192.168.16.173
    LogFile=/var/log/zabbix/zabbix_server.log
    LogFileSize=1
    DebugLevel=3
    PidFile=/var/run/zabbix/zabbix_server.pid
    DBHost=localhost
    DBName=zabbixdb
    DBUser=zabbix
    DBPassword=zabbix
    #mysql为localhost或127.0.0.1的话,需要设置DBSocket
    DBSocket=/var/lib/mysql/mysql.sock
    DBPort=3306

4.启动zabbix-server

systemctl  start zabbix-server

三、配置web界面

配置httpd相关

vim   /etc/httpd/conf.d/zabbix.conf

#映射 URL /zabbix 到  /usr/share/zabbix
Alias /zabbix /usr/share/zabbix
<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 always_populate_raw_post_data -1
        #时区;在此设置对zabbbix有效;在/etc/php.ini下全部php有效
        php_value date.timezone Asia/Shanghai
    </IfModule>
</Directory>

<Directory "/usr/share/zabbix/conf">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/app">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/include">
    Require all denied
</Directory>

<Directory "/usr/share/zabbix/local">
    Require all denied
</Directory>
systemctl  start httpd

访问http://192.168.16.173/zabbix/setup.php

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tete2csdn/article/details/78669390
文章标签: zabbix mysql
个人分类: linux-自动运维
上一篇企业级分布式存储应用-mogilefs
下一篇ansible自动部署网站
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭