美文网首页
1.zabbix+agent安装配置

1.zabbix+agent安装配置

作者: 像飞翔一样去飞翔 | 来源:发表于2017-01-03 16:15 被阅读0次

一、 环境准备

hosts解析文件

192.168.99.241 server www.server.com
192.168.99.242 client www.client.com

服务端

[root@server ~]# uname -r
3.10.0-327.el7.x86_64
[root@server ~]# ifconfig |awk '/broadcast/{print $2}'
192.168.99.241

客户端

[root@vm2 ~]# uname  -r
3.10.0-327.el7.x86_64
[root@vm2 ~]# ifconfig |awk '/broadcast/{print $2}'
192.168.99.242

配置yum源

[root@server ~]# yum install epel-release
[root@server ~]# cat /etc/yum.repos.d/zabbix.repo 
[ZABBIX]
name=zabbix
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/3.2/rhel/7/x86_64/
gpgcheck=0

时间同步

[root@server ~]# ntpdate 0.centos.pool.ntp.org
[root@client ~]# ntpdate 0.centos.pool.ntp.org

二、服务端安装

1.数据库配置安装配置

zabbix依赖数据库,为解决依赖关系,我们需要创建出一个zabbix数据库,并授权服务端能够登陆数据库

[root@server ~]# rpm -q mariadb-server
mariadb-server-5.5.52-1.el7.x86_64
[root@server ~]# vim /etc/my.cnf
[root@server ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip_name_resolve = ON      #增加此配置
innodb_file_per_table = ON  # 增加此配置
# Disabling symbolic-links is recommended to prevent assorted security risks

启动服务并授权(一般而言我们只要授权一个账号就行了)

[root@server ~]# systemctl start mariadb.service
[root@server ~]# mysql
MariaDB [(none)]> create database zabbix charset 'utf8';
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabuser@'127.0.0.1' identified by 'zbxpass';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabuser@'localhost' identified by 'zbxpass';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabuser@'192.168.99.%' identified by 'zbxpass';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit

验证是否授权成功

[root@server ~]# mysql -uzabuser -hlocalhost -p"zbxpass"
[root@server ~]# mysql -uzabuser -h127.0.0.1 -p"zbxpass"
[root@server ~]# mysql -uzabuser -h192.168.99.241 -p"zbxpass"

2.ZABBIX服务端安装配置

[root@server ~]# yum install  zabbix-server-mysql zabbix-get 

导入数据库脚本,以生成数据库环境

[root@server ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.3/
[root@server zabbix-server-mysql-3.2.3]# gzip  -d create.sql.gz 
[root@server zabbix-server-mysql-3.2.3]# mysql -uzabuser -h192.168.99.241 -pzbxpass zabbix <create.sql 

3.验证是否成功导入

[root@server zabbix-server-mysql-3.2.3]# mysql -uzabuser -p'zbxpass'
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> show tables;

4.zabbix server配置并启动

[root@server ~]# grep -v "^#" /etc/zabbix/zabbix_server.conf|sed '/^$/d'
ListenPort=10051  #
SourceIP=192.168.99.241  # 
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=192.168.99.241  # 
DBName=zabbix   # 
DBUser=zabuser  # 
DBPassword=zbxpass  # 
DBSocket=/var/lib/mysql/mysql.sock  # 
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

[root@server ~]# systemctl  start zabbix-server.service 
[root@server ~]# ss -tnl|grep 10051
LISTEN 0  128  *:10051*:*  
LISTEN 0  128 :::10051   :::*   

3.ZABBIX WEB配置

解决依赖关系

[root@server ~]# yum install -y httpd php php-mysql php-mbstring php-gd php-bcmath php-ldap php-xml

安装web GUI

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

配置php时区参数

[root@server ~]# vim /etc/httpd/conf.d/zabbix.conf 

<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
        php_value date.timezone Asia/Shanghai
    </IfModule>
</Directory>

启动web服务

[root@server ~]# systemctl  start httpd

访问地址:http://192.168.99.241/zabbix

Paste_Image.png

三、agent客户端安装配置

解决依赖关系

[root@client ~]# yum install -y epel-release
[root@server ~]# scp /etc/yum.repos.d/zabbix.repo  root@192.168.99.242:/etc/yum.repos.d/

安装相应的包

[root@client ~]# yum install zabbix-agent zabbix-sender

配置并启动agent端口

[root@client ~]# vim /etc/zabbix/zabbix_agentd.conf
[root@client ~]# grep -v ^# /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.99.241   # 指明服务端
ListenPort=10050
ServerActive=127.0.0.1
Hostname=client
Include=/etc/zabbix/zabbix_agentd.d/

启动服务

[root@client ~]# systemctl start zabbix-agent.service  
[root@client ~]# ss -tnl|grep 10050
LISTEN     0      128          *:10050                    *:*                  
LISTEN     0      128         :::10050                   :::*                  
[root@client ~]#

相关文章

网友评论

      本文标题:1.zabbix+agent安装配置

      本文链接:https://www.haomeiwen.com/subject/pzknvttx.html