首页 > 其他 > 详细

个人笔记:腾讯云安装ZABBIX4+Grafana6监控系统的安装配置

时间:2020-05-12 17:32:44      阅读:74      评论:0      收藏:0      [点我收藏+]
试验环境:腾讯云主机1C2G
试验日期:20200508

第一章 配置ZABBIX服务端
[root@VM_0_3_centos install_zabbix]# yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
[root@VM_0_3_centos install_zabbix]# vi /etc/httpd/conf/httpd.conf
ServerName VM_0_3_centos //修改为主机名
DirectoryIndex index.html index.php //修改
:wq

[root@VM_0_3_centos install_zabbix]# vi /etc/php.ini
date.timezone = PRC //修改为中国时区
:wq

[root@VM_0_3_centos install_zabbix]# systemctl stop firewalld.service
[root@VM_0_3_centos install_zabbix]# setenforce 0
[root@VM_0_3_centos install_zabbix]# systemctl start httpd.service //启动httpd服务
[root@VM_0_3_centos install_zabbix]# systemctl start mariadb.service //启动mariadb服务

[root@VM_0_3_centos install_zabbix]# netstat -anpt|grep 80
tcp6 0 0 :::80 :::* LISTEN 6436/httpd
[root@VM_0_3_centos install_zabbix]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
……忽略N行
All done! If you‘ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@VM_0_3_centos install_zabbix]# vi /var/www/html/index.php
[root@VM_0_3_centos install_zabbix]# vi /var/www/html/index.php
[root@VM_0_3_centos install_zabbix]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT all ON zabbix.* TO ‘zabbix‘@‘%‘ IDENTIFIED BY ‘admin123‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye

[root@VM_0_3_centos install_zabbix]# vi /var/www/html/index.php
<?php

$link=mysql_connect(‘172.17.x.x‘,‘zabbix‘,‘admin123‘);
if($link) echo "<h1>Success!!</h1>";
else echo "Fail!!";
mysql_close();
?>

访问http:// 172.17.x.x/

[root@VM_0_3_centos ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.4BUdMY: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-4.0-1.el7 ################################# [100%]
[root@VM_0_3_centos ~]#

[root@VM_0_3_centos install_zabbix]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile

  • remi-safe: mirrors.tuna.tsinghua.edu.cn
    zabbix
    Dependency Installed:
    ……忽略N行
    OpenIPMI.x86_64 0:2.0.27-1.el7 OpenIPMI-libs.x86_64 0:2.0.27-1.el7 OpenIPMI-modalias.x86_64 0:2.0.27-1.el7 fping.x86_64 0:3.10-4.el7 gnutls.x86_64 0:3.3.29-9.el7_6 iksemel.x86_64 0:1.4-2.el7.centos
    nettle.x86_64 0:2.7.1-8.el7 php-bcmath.x86_64 0:5.4.16-48.el7 trousers.x86_64 0:0.3.14-2.el7 zabbix-web.noarch 0:4.0.20-1.el7

Complete!

[root@VM_0_3_centos ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbix -p -h 172.17.x.x zabbix
Enter password:
用户是zabbix登陆密码admin123
[root@VM_0_3_centos ~]#

vi /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=admin123
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

vi /etc/httpd/conf.d/zabbix.conf //修改时区
php_value date.timezone Asia/Shanghai

[root@VM_0_3_centos install_zabbix]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@VM_0_3_centos install_zabbix]# systemctl start zabbix-server
[root@VM_0_3_centos install_zabbix]# netstat -anpt | grep zabbix
[root@VM_0_3_centos install_zabbix]# systemctl restart httpd.service
[root@VM_0_3_centos install_zabbix]#
技术分享图片
技术分享图片
技术分享图片
技术分享图片
技术分享图片

设置中文环境:Administrator-Users-点击用户Admin-语言中设置:

技术分享图片

第二章 配置ZABBIX代理端
(即被控服务器,如服务器要被自己监控也需安装)
wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.3-1.el7.x86_64.rpm
技术分享图片
yum -y install zabbix-agent
技术分享图片

vi /etc/zabbix/zabbix_agentd.conf //配置zabbix agent,修改为如下代码行
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=172.17.x.x
ServerActive=172.17.x.x
Hostname=VM_0_3_centos
Include=/etc/zabbix/zabbix_agentd.d/*.conf

#关闭防火墙
[root@VM_0_3_centos ~]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service
[root@VM_0_3_centos ~]# setenforce 0
setenforce: SELinux is disabled

#启动、停止、检查 zabbix_ agentd
systemctl start zabbix-agent.service
systemctl stop zabbix-agent.service
systemctl status zabbix-agent.service
技术分享图片

常使用的文件(配置、进程、pid、日志)如路径如下
/etc/zabbix/zabbix_agentd.conf
/etc/zabbix/zabbix_agentd.d
/var/run/zabbix/zabbix_agentd.pid
/var/log/zabbix/zabbix_agentd.log

设置开机自启动
systemctl enable zabbix-agent.service

增加被控主机
配置-主机-创建主机:
技术分享图片

常见操作
#查看日志
tail -100 /var/log/zabbix/zabbix_server.log
tail -100 /var/log/zabbix/zabbixagentd.log
#httpd服务
systemctl start httpd.service
systemctl restart httpd.service
#启动mariadb服务(MariaDB数据库管理系统是MySQL的一个分支)
systemctl stop mariadb.service
systemctl start mariadb.service
#zabbix服务
systemctl stop zabbix-server
systemctl start zabbix-server
#启动、停止、检查 zabbix
agentd
systemctl start zabbix-agent.service
systemctl stop zabbix-agent.service
systemctl status zabbix-agent.service

第三章 Grafana安装

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-6.3.6-1.x86_64.rpm
技术分享图片
yum install initscripts fontconfig
rpm -Uvh grafana-6.3.6-1.x86_64.rpm
技术分享图片
注:此前误装过老版本(grafana-4.3.1-1.x86_64.rpm),故截图有removing操作

Grafana配置文件
systemd服务和daemon服务在后台运行时,都使用文件/etc/sysconfig/grafana-server来设置环境变量,可通过修改garfana-server文件来设置日志目录等其他变量。
#默认日志文件:/var/log/grafana
#数据库设置
#缺省配置指定一sqlite3数据库位于/var/lib/grafana/grafana.db。请在升级前备份这个数据库。还可以使用MySQL或Postgres Grafana数据库。
访问测试ip:3000
缺省用户/密码 admin/admin(注意正式使用务必改密码强度)

第四章 Grafana Zabbix插件安装
使用grafana-cli工具安装
获取可用插件列表
#grafana-cli plugins list-remote
技术分享图片

安装zabbix插件
#grafana-cli plugins install
alexanderzobnin-zabbix-app
技术分享图片

安装插件完成之后重启garfana服务
#service grafana-server restart
#使用grafana-zabbix-app源,其中包含最新版本的插件
cd /var/lib/grafana/plugins/
#克隆grafana-zabbix-app插件项目
git clone https://github.com/alexanderzobnin/grafana-zabbix-app
#注:如果没有git,请先安装git
技术分享图片

yum –y install git
#插件安装完成重启garfana服务
技术分享图片

service grafana-server restart
#注:通过这种方式,可以很容器升级插件
技术分享图片

cd /var/lib/grafana/plugins/grafana-zabbix-app
git pull
技术分享图片

service grafana-server restart
修改图形为饼状,需要下载另一个grafana-piechart-panel
https://grafana.com/plugins/grafana-piechart-panel
grafana-cli plugins install grafana-piechart-panel

技术分享图片

安装其他图形插件
grafana-cli plugins install grafana-clock-panel
技术分享图片
#钟表形展示
grafana-cli plugins install briangann-gauge-panel
技术分享图片
#字符型展示
grafana-cli plugins install natel-discrete-panel
技术分享图片
#服务器状态
grafana-cli plugins install vonage-status-panel
技术分享图片
3)访问grafana,http://localhost:3000,默认用户名和密码:admin/admin

第五章 Grafana配置Zabbix数据源
激活zabbix插件
技术分享图片

技术分享图片

add data source
Name:自定义一个名称
URL:http://172.17.x.x/zabbix/api_jsonrpc.php #zabbixAPI接口地址
Access: 默认Server(Default)
Username:填写你zabbix的用户名(Admin)
Password: 填写你zabbix的密码
Trends:勾选
技术分享图片

New dashboard
技术分享图片
Add query
技术分享图片
注:
1、 选定Query、Group(zabbix上配置的)、Host(zabbix上配置的);
2、 Application和item可以自动带出;
技术分享图片

?

常见错误排查(可选)
一、版本过旧
技术分享图片
处置方法:重新安装对应版本的grafana
[root@VM_0_3_centos ~]# rpm -qa | grep grafana
grafana-4.3.1-1.x86_64

二、依赖包问题
问题现象:
[root@VM_0_3_centos ~]# rpm -Uvh grafana-6.3.6-1.x86_64.rpm
warning: grafana-6.3.6-1.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 24098cb6: NOKEY
error: Failed dependencies:
urw-fonts is needed by grafana-6.3.6-1.x86_64

处置方法:
yum install -y urw-fonts

三、链接ZABBIX异常
技术分享图片
处置方法:核对如下参数
URL:http://172.17.x.x/zabbix/api_jsonrpc.php #zabbixAPI接口地址
Access: 默认Server(Default)
Username:填写zabbix的用户名
Password: 填写zabbix的密码
Trends:勾选

个人笔记:腾讯云安装ZABBIX4+Grafana6监控系统的安装配置

原文:https://blog.51cto.com/yunlongzheng/2494530

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!