CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装

1、Zabbix安装
下载zabbix server源码包

wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.4/zabbix-4.4.4.tar.gz

安装依赖

yum install wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC libevent-devel mysql-devel libxml2-devel libssh2-devel OpenIPMI-devel java-1.8.0-openjdk-devel openldap-devel curl-devel unixODBC-devel

解压并编译安装

tar -zxvf zabbix-4.4.1.tar.gz
cd zabbix-4.4.1/

建立编译安装目录

mkdir -p /data/zabbix
./configure --prefix=/data/zabbix --enable-server --enable-agent --enable-java --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-ldap --with-libcurl --with-iconv
make
make install

查看安装版本

/data/zabbix/sbin/zabbix_server -V

CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装_第1张图片
数据库安装

yum install mariadb-server
systemctl start mariadb.service
systemctl status mariadb.service
mysql_secure_installation

CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装_第2张图片
创建数据库

mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'abc123456.';
flush privileges;

导入数据结构

mysql -uzabbix -pabc123456. zabbix < /root/zabbix-4.4.4/database/mysql/schema.sql
mysql -uzabbix -pabc123456. zabbix < /root/zabbix-4.4.4/database/mysql/images.sql
mysql -uzabbix -pabc123456. zabbix < /root/zabbix-4.4.4/database/mysql/data.sql

CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装_第3张图片
修改zabbix server配置

vim /data/zabbix/etc/zabbix_server.conf
ListenPort=10051
DBHost=localhost
DBPassword=zabbix
DBPort=3306
ListenIP=127.0.0.1

增加用户

groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix System" zabbix

启动服务

/data/zabbix/sbin/zabbix_server -c /data/zabbix/etc/zabbix_server.conf
/data/zabbix/sbin/zabbix_agentd -c /data/zabbix/etc/zabbix_agentd.conf
tailf /tmp/zabbix_server.log
tailf /tmp/zabbix_agentd.log
ps aux | grep zabbix

CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装_第4张图片
CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装_第5张图片
CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装_第6张图片
解决办法 :

增加Zabbix镜像源

rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm

安装Zabbix Frontend

yum install zabbix-web-mysql

配置Zabbix frontend

vim /etc/php.ini

max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
max_input_vars = 10000
always_populate_raw_post_data = -1
date.timezone = Asia/Shanghai

启动httpd

systemctl start httpd.service
systemctl status httpd.service

cd zabbix-4.4.4
cp misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix-server

cp misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix-agent

chmod +x /etc/rc.d/init.d/zabbix-server
chmod +x /etc/rc.d/init.d/zabbix-agent
chkconfig --add zabbix-server
chkconfig --add zabbix-agent
chkconfig zabbix-server on
chkconfig zabbix-agent on

vi /etc/rc.d/init.d/zabbix-agent 和zabbix-server

编辑客户端配置文件

BASEDIR=/data/zabbix/

zabbix安装目录

PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid #pid文件路径
(可以使用默认)

:wq! #保存退出

http://ip/zabbix/setup.php

Admin
zabbix

2、grafana安装

wget https://dl.grafana.com/oss/release/grafana-6.4.4-1.x86_64.rpm
yum localinstall grafana-6.4.4-1.x86_64.rpm

systemctl daemon-reload
systemctl start grafana-server
systemctl status grafana-server

配置支持zabbix

安装 zabbix 插件(grafana-zabbix)

grafana-cli plugins install alexanderzobnin-zabbix-app
systemctl restart grafana-server

启用插件

进入 Plugins 界面,选择 “Zabbix”
开始面板(左上角图标) -> Plugins -> Apps -> Zabbix

添加 zabbix 数据源

进入 “添加数据源” 界面
开始面板(左上角图标) -> Data Sources -> Add data source

配置 Zabbix 数据源

配置完后,保存退出,配置的内容如下:
重要参数有:
Type: Zabbix
Url: http://zabbix服务器/zabbix/api_jsonrpc.php
Access: direct
(Zabbix API details)
Username: Admin(默认)
Password: zabbix(默认)

验证
之后,我们从 开始面板 -> Zabbix 中,便可看到 Zabbix 相关的监控数据。

监控客户端

安装Zabbix Agent

yum install zabbix-agent

systemctl start zabbix-agent.service

常见问题:
1、[root@localhost zabbix-4.4.4]# rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
Error downloading packages:
zabbix-web-4.4.4-1.el7.noarch: [Errno 256] No more mirrors to try
CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装_第7张图片
2、

[root@localhost ~]# tailf /tmp/zabbix_agentd.log
 47516:20200108:112823.326 TLS support:            NO
 47516:20200108:112823.326 **************************
 47516:20200108:112823.326 using configuration file: /data/zabbix/etc/zabbix_agentd.conf
 47516:20200108:112823.327 agent #0 started [main process]
 47518:20200108:112823.331 agent #2 started [listener #1]
 47519:20200108:112823.331 agent #3 started [listener #2]
 47520:20200108:112823.332 agent #4 started [listener #3]
 47521:20200108:112823.332 agent #5 started [active checks #1]
 47517:20200108:112823.335 agent #1 started [collector]
 47521:20200108:112823.337 active check configuration update from [127.0.0.1:10051] started to fail (cannot connect to [[127.0.0.1]:10051]: [111] Connection refused)

^C
[root@localhost ~]# !48
tailf /tmp/zabbix_server.log
zabbix_server [48713]: Is this process already running? Could not lock PID file [/tmp/zabbix_server.pid]: [11] Resource temporarily unavailable
zabbix_server [48716]: Is this process already running? Could not lock PID file [/tmp/zabbix_server.pid]: [11] Resource temporarily unavailable
 47511:20200108:132306.061 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO)
 47511:20200108:132306.061 database is down: reconnecting in 10 seconds
 47511:20200108:132316.063 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO)
 47511:20200108:132316.063 database is down: reconnecting in 10 seconds
 47511:20200108:132326.064 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO)
 47511:20200108:132326.064 database is down: reconnecting in 10 seconds
 47511:20200108:132336.066 [Z3001] connection to database 'zabbix' failed: [1045] Access denied for user 'zabbix'@'localhost' (using password: NO)
 47511:20200108:132336.066 database is down: reconnecting in 10 seconds

CentOS 7.5 安装Zabbix4.4.4和Grafana6.4.4监控系统安装_第8张图片

扩展

1、如果是rpm包安装的Grafana,如何删除。

查看安装

rpm -qa | grep grafana
find / -name grafana

清除(卸载)

rpm -e grafana-5.3.2-1.x86_64
find / -name grafana -exec rm -rf {} \

参考连接 :

Grafana 安装及 Windows 应用程序服务配置工具 NSSM使用 : https://blog.csdn.net/kk185800961/article/details/83515382

你可能感兴趣的:(centos,监控)