安装zabbix4.0+grafana
程序员文章站
2022-07-09 22:44:14
...
---------------------- 那些年我走过的坑们 ----------------------
准备环境
首先
- 官方建议数据库的安装要求
关闭防火墙
[aaa@qq.com ~]# systemctl stop firewalld
[aaa@qq.com ~]# systemctl disable firewalld
关闭selinux
[aaa@qq.com ~]# vim /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[aaa@qq.com ~]# setenforce 0
setenforce: SELinux is disabled
[aaa@qq.com ~]# getenforce
Disabled
升级软件
[aaa@qq.com ~]# yum -y update
Loaded plugins: fastestmirror, product-id, search-disabled-repos
Loading mirror speeds from cached hostfile
No packages marked for update
部署lnmp
# 安装依赖
[aaa@qq.com ~]# yum -y install gcc pcre-devel zlib-devel openssl-devel
# 将软件包上传到目录
[aaa@qq.com opt]# ls
nginx-1.18.0.tar.gz rh zabbix-4.0.9.tar.gz php-7.3.22.tar.gz
# 解压Nginx
[aaa@qq.com opt]# tar -xf nginx-1.18.0.tar.gz
[aaa@qq.com opt]# cd nginx-1.18.0/
[aaa@qq.com nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module
[aaa@qq.com nginx-1.18.0]# make && make install
# 下载mysql
[aaa@qq.com ~]# rpm -q mariadb # 查看mariadb是否安装过,如果安装过,将mariadb利用yum或者rpm卸载,并且将/var/lib/mysql下面的文件全部删除,mariadb会和mysql相冲突
package mariadb is not installed
[aaa@qq.com opt]# wget wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
[aaa@qq.com opt]# ls
mysql80-community-release-el7-2.noarch.rpm nginx-1.18.0.tar.gz rh zabbix-4.0.9.tar.gz
nginx-1.18.0 zabbix-4.0.9
[aaa@qq.com opt]# yum -y install mysql80-community-release-el7-2.noarch.rpm # 下载rpm包
[aaa@qq.com opt]# yum -y update # 更新一下yum源
[aaa@qq.com opt]# yum -y install mysql-community-server.x86_64 # 安装mysql服务器
[aaa@qq.com opt]# systemctl start mysqld # 起服务
[aaa@qq.com opt]# ss -nutlp | grep 3306
tcp LISTEN 0 70 [::]:33060 [::]:* users:(("mysqld",pid=13816,fd=31))
tcp LISTEN 0 128 [::]:3306 [::]:* users:(("mysqld",pid=13816,fd=33))
[aaa@qq.com ~]# grep "password" /var/log/mysqld.log # 查看进入mysql的初始密码
[aaa@qq.com ~]# mysql -uroot -p # 登录数据库
Enter password:
mysql> alter user aaa@qq.com"localhost" identified by "123tian.A"; # 修改用户密码
Query OK, 0 rows affected (0.01 sec)
#下载PHP以及依赖包
[aaa@qq.com ~]# tar -xf php-7.3.22.tar.gz # 解压
[aaa@qq.com ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel gcc-c++ # 下载依赖包
[aaa@qq.com ~]# groupadd www # 创建php组合用户
[aaa@qq.com ~]# useradd -g www www
[aaa@qq.com php-7.3.22]# ./configure --prefix=/usr/local/php --with-fpm-user=php --with-fpm-group=php --with-mysqli=mysqlnd --enable-embedded-mysqli --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql=mysqlnd --enable-mysqlnd --with-zlib --enable-fpm --with-openssl --enable-fpm --with-openssl --enable-debug --with-freetype-dir --with-png-dir --with-gd --enable-gd-jis-conv --with-jpeg-dir --enable-sockets --enable-mbstring --enable-bcmath --with-config-file-path=/usr/local --with-libxml-dir --with-curl --enable-ftp --enable-intl --with-mhash --enable-soap --enable-maintainer-zts --with-pear --disable-fileinfo --disable-rpath --with-gettext --enable-sysvsem --enable-cli --enable-phpdbg-readline=/usr/local
[aaa@qq.com php-7.3.22]# make && make install
[aaa@qq.com php-7.3.22]# /usr/local/php/bin/php -v
PHP 7.3.22 (cli) (built: Sep 19 2020 11:43:45) ( ZTS DEBUG )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies
[aaa@qq.com php-7.3.22]# vim /etc/profile # 添加到环境变量
PATH=$PATH:/usr/local/php/bin
export PATH
[aaa@qq.com ~]# source /etc/profile
[aaa@qq.com ~]# php -v # 更新环境变量
PHP 7.3.22 (cli) (built: Sep 19 2020 11:43:45) ( ZTS DEBUG )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies
# 配置php-fpm
[aaa@qq.com php-7.3.22]# cp php.ini-production /etc/php.ini
[aaa@qq.com php-7.3.22]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[aaa@qq.com php-7.3.22]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[aaa@qq.com php-7.3.22]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[aaa@qq.com php-7.3.22]# chmod +x /etc/init.d/php-fpm
[aaa@qq.com php-7.3.22]# /etc/init.d/php-fpm start # 起服务
Starting php-fpm done
[aaa@qq.com php-7.3.22]# ss -nutlp | grep 9000
tcp LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",pid=16269,fd=5),("php-fpm",pid=16268,fd=5),("php-fpm",pid=16267,fd=7))
# 配置Nginx使其支持PHP
[aaa@qq.com ~]# vim /usr/local/nginx/conf/nginx.conf
45 index index.html index.php index.htm;
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
70 include fastcgi.conf;
71 }
[aaa@qq.com ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[aaa@qq.com ~]# /usr/local/nginx/sbin/nginx
[aaa@qq.com ~]# ss -nutlp | grep :80
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=1518,fd=6),("nginx",pid=1517,fd=6))
[aaa@qq.com ~]# ss -nutlp | grep :9000
tcp LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",pid=13797,fd=0),("php-fpm",pid=13796,fd=0),("php-fpm",pid=13795,fd=0),("php-fpm",pid=13794,fd=0),("php-fpm",pid=13793,fd=0),("php-fpm",pid=13792,fd=6))
# 测试是否可以访问PHP页面
# 测试静态页面
[aaa@qq.com ~]# curl localhost
<h1>hello,Be happy!</h1>
[aaa@qq.com ~]# vim /usr/local/nginx/html/index.html
[aaa@qq.com ~]# curl localhost
<h1>hello,Be happy!
[aaa@qq.com ~]# curl -I localhost
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Thu, 20 Aug 2020 09:40:35 GMT
Content-Type: text/html
Content-Length: 20
Last-Modified: Thu, 20 Aug 2020 09:40:24 GMT
Connection: keep-alive
ETag: "5f3e4508-14"
Accept-Ranges: bytes
# 测试动态页面
</div></body></html>[aaa@qq.com ~]# curl -I localhost/test.php
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Fri, 21 Aug 2020 02:16:19 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/7.4.9
配置zabbix用户可以连接数据库
[aaa@qq.com ~]# mysql -uroot -p123tian.A -e "create database zabbix character set utf8 collate utf8_bin" # 命令行登录,创建zabbix库,使其支持中文
# mysql8.0授权用户登录不是像5.x版本样可以直接授权的同时创建用户,只能单独创建单独授权,并且授权用户时不可以加identified by!!!
mysql> create user 'zabbix'@'%' identified WITH mysql_native_password by '123qqq...A' ; # 创建用户
Query OK, 0 rows affected (0.02 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'%'; # 授权
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges; # 刷新
Query OK, 0 rows affected (0.02 sec)
[aaa@qq.com ~]# vim /etc/my.cnf
default_authentication_plugin=mysql_native_password
# 修改测试页的内容,测试zabbix用户能否登录数据库
[aaa@qq.com ~]# vim /usr/local/nginx/html/index.php
<?php
$dbhost = '106.54.95.242:3306'; // mysql服务器主机地址
$dbuser = 'zabbix'; // mysql用户名
$dbpass = '123qqq...A'; // mysql用户名密码
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysqli_error());
}
echo '数据库连接成功!';
mysqli_close($conn);
?>
[aaa@qq.com ~]# curl localhost/index.php
数据库连接成功!
安装并启动zabbix
# 安装依赖包
[aaa@qq.com ~]# yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel libevent-devel.x86_64 javacc.noarch javacc-javadoc.noarch javacc-maven-plugin.noarch javacc*
# 安装PHP支持zabbix组件
[aaa@qq.com ~]# yum install php-bcmath php-mbstring -y
# 安装zabbix
[aaa@qq.com ~]# mkdir /zabbix # 创建zabbix目录
[aaa@qq.com ~]# cd /zabbix/
[aaa@qq.com zabbix]# ls
zabbix40.tar.gz
[aaa@qq.com zabbix]# tar -xf zabbix40.tar.gz
[aaa@qq.com zabbix]# ls
apr-1.4.8-3.el7_4.1.x86_64.rpm perl-File-Temp-0.23.01-3.el7.noarch.rpm
apr-util-1.5.2-6.el7.x86_64.rpm perl-Filter-1.49-3.el7.x86_64.rpm
createrepo-0.9.9-28.el7.noarch.rpm perl-Getopt-Long-2.40-3.el7.noarch.rpm
dejavu-fonts-common-2.33-6.el7.noarch.rpm perl-HTTP-Tiny-0.033-3.el7.noarch.rpm
dejavu-sans-fonts-2.33-6.el7.noarch.rpm perl-IO-Compress-2.061-2.el7.noarch.rpm
deltarpm-3.6-3.el7.x86_64.rpm perl-libs-5.16.3-294.el7_6.x86_64.rpm
fontpackages-filesystem-1.44-8.el7.noarch.rpm perl-macros-5.16.3-294.el7_6.x86_64.rpm
fping-3.10-4.el7.x86_64.rpm perl-Net-Daemon-0.48-5.el7.noarch.rpm
httpd-2.4.6-89.el7.centos.x86_64.rpm perl-parent-0.225-244.el7.noarch.rpm
httpd-tools-2.4.6-89.el7.centos.x86_64.rpm perl-PathTools-3.40-5.el7.x86_64.rpm
iksemel-1.4-2.el7.centos.x86_64.rpm perl-PlRPC-0.2020-14.el7.noarch.rpm
libevent-2.0.21-4.el7.x86_64.rpm perl-Pod-Escapes-1.04-294.el7_6.noarch.rpm
libjpeg-turbo-1.2.90-6.el7.x86_64.rpm perl-podlators-2.5.1-3.el7.noarch.rpm
libpng-1.5.13-7.el7_2.x86_64.rpm perl-Pod-Perldoc-3.20-4.el7.noarch.rpm
libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm perl-Pod-Simple-3.28-4.el7.noarch.rpm
libX11-1.6.5-2.el7.x86_64.rpm perl-Pod-Usage-1.63-3.el7.noarch.rpm
libX11-common-1.6.5-2.el7.noarch.rpm perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm
libXau-1.0.8-2.1.el7.x86_64.rpm perl-Socket-2.010-4.el7.x86_64.rpm
libxcb-1.13-1.el7.x86_64.rpm perl-Storable-2.45-3.el7.x86_64.rpm
libxml2-2.9.1-6.el7_2.3.x86_64.rpm perl-Text-ParseWords-3.29-4.el7.noarch.rpm
libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm perl-threads-1.87-4.el7.x86_64.rpm
libXpm-3.5.12-1.el7.x86_64.rpm perl-threads-shared-1.43-6.el7.x86_64.rpm
libxslt-1.1.28-5.el7.x86_64.rpm perl-Time-HiRes-1.9725-3.el7.x86_64.rpm
libzip-0.10.1-8.el7.x86_64.rpm perl-Time-Local-1.2300-2.el7.noarch.rpm
lrzsz-0.12.20-36.el7.x86_64.rpm php-5.4.16-46.el7.x86_64.rpm
mailcap-2.1.41-2.el7.noarch.rpm php-bcmath-5.4.16-46.el7.x86_64.rpm
mariadb-5.5.60-1.el7_5.x86_64.rpm php-cli-5.4.16-46.el7.x86_64.rpm
mariadb-libs-5.5.60-1.el7_5.x86_64.rpm php-common-5.4.16-46.el7.x86_64.rpm
mariadb-server-5.5.60-1.el7_5.x86_64.rpm php-gd-5.4.16-46.el7.x86_64.rpm
net-snmp-libs-5.7.2-37.el7.x86_64.rpm php-ldap-5.4.16-46.el7.x86_64.rpm
OpenIPMI-libs-2.0.23-2.el7.x86_64.rpm php-mbstring-5.4.16-46.el7.x86_64.rpm
OpenIPMI-modalias-2.0.23-2.el7.x86_64.rpm php-mysql-5.4.16-46.el7.x86_64.rpm
openssl-1.0.2k-16.el7_6.1.x86_64.rpm php-pdo-5.4.16-46.el7.x86_64.rpm
openssl-libs-1.0.2k-16.el7_6.1.x86_64.rpm php-xml-5.4.16-46.el7.x86_64.rpm
perl-5.16.3-294.el7_6.x86_64.rpm python-deltarpm-3.6-3.el7.x86_64.rpm
perl-Carp-1.26-244.el7.noarch.rpm repodata
perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm t1lib-5.1.2-14.el7.x86_64.rpm
perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm unixODBC-2.3.1-11.el7.x86_64.rpm
perl-constant-1.27-2.el7.noarch.rpm zabbix40.tar.gz
perl-Data-Dumper-2.145-3.el7.x86_64.rpm zabbix-agent-4.0.7-1.el7.x86_64.rpm
perl-DBD-MySQL-4.023-6.el7.x86_64.rpm zabbix-get-4.0.7-1.el7.x86_64.rpm
perl-DBI-1.627-4.el7.x86_64.rpm zabbix-server-mysql-4.0.7-1.el7.x86_64.rpm
perl-Encode-2.51-7.el7.x86_64.rpm zabbix-web-4.0.7-1.el7.noarch.rpm
perl-Exporter-5.68-3.el7.noarch.rpm zabbix-web-mysql-4.0.7-1.el7.noarch.rpm
perl-File-Path-2.09-2.el7.noarch.rpm
# 将rpm包作为yum源
[aaa@qq.com zabbix]# yum -y install yum-utils # 下载软件,提供yum-config-manager服务
[aaa@qq.com zabbix]# yum-config-manager --add file:///zabbix
Loaded plugins: fastestmirror
adding repo from: file:///zabbix
[zabbix]
name=added from: file:///zabbix
baseurl=file:///zabbix
enabled=1
[aaa@qq.com zabbix]# vim /etc/yum.conf # 修改yum的配置,使其每次不检查签名
8 gpgcheck=0
[aaa@qq.com zabbix]# yum -y update # 更新yum源
[aaa@qq.com zabbix]# yum repolist
Loaded plugins: fastestmirror, product-id, search-disabled-repos
Loading mirror speeds from cached hostfile
repo id repo name status
base/7/x86_64 CentOS-7 - Base 10,070
extras/7/x86_64 CentOS-7 - Extras 413
mysql-connectors-community/x86_64 MySQL Connectors Community 165
mysql-tools-community/x86_64 MySQL Tools Community 115
mysql80-community/x86_64 MySQL 8.0 Community Server 193
updates/7/x86_64 CentOS-7 - Updates 1,112
zabbix_ added from: file:///zabbix/ 87
repolist: 12,155
# 安装zabbix组件
[aaa@qq.com zabbix]# yum install zabbix-server-mysql zabbix-web-mysql -y
# 导入数据
[aaa@qq.com zabbix]# zcat /usr/share/doc/zabbix-server-mysql-4.0.7/create.sql.gz | mysql -h106.54.95.242 -uzabbix -p123qqq...A zabbix # 导入数据到zabbix库中,-h后面接ip,-u用户名,-p密码
# 修改zabbix连接数据库的配置
[aaa@qq.com ~]# vim /etc/zabbix/zabbix_server.conf
38 LogFile=/tmp/zabbix_server.log
92 DBHost=localhost
100 DBName=zabbix
116 DBUser=zabbix
125 DBPassword=123qqq...A
# 修改时区
[aaa@qq.com ~]# vim /etc/php.ini
956 date.timezone = Asia/Shanghai
380 max_execution_time = 300
689 post_max_size = 32M
390 max_input_time = 300
# 修改Nginx页面的配置
[aaa@qq.com ~]# vim /usr/local/nginx/conf/nginx.conf
17 http {
18 include mime.types;
19 default_type application/octet-stream;
20 fastcgi_buffers 8 16k;
21 fastcgi_buffer_size 32k;
22 fastcgi_connect_timeout 300;
23 fastcgi_send_timeout 300;
24 fastcgi_read_timeout 300;
[aaa@qq.com ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[aaa@qq.com ~]# /usr/local/nginx/sbin/nginx -s reload
[aaa@qq.com ~]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
[aaa@qq.com ~]# zabbix_server
[aaa@qq.com ~]# netstat -nutlp | grep zabbix_server
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 31716/zabbix_server
tcp6 0 0 :::10051 :::* LISTEN 31716/zabbix_server
- 如果zabbix启动报错如下:
[aaa@qq.com ~]# zabbix_server
zabbix_server: error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory
# 解决方案:
[aaa@qq.com ~]# find / -name libmysqlclient.so.20
/usr/lib64/mysql/libmysqlclient.so.20
[aaa@qq.com ~]# ln -s /usr/lib64/mysql/libmysqlclient.so.20 /usr/lib64
[aaa@qq.com ~]# find / -name libmysqlclient.so.20
/usr/lib64/mysql/libmysqlclient.so.20
/usr/lib64/libmysqlclient.so.20
[aaa@qq.com ~]# echo "/usr/lib64" >> /etc/ld.so.conf
[aaa@qq.com ~]# ldconfig
将zabbix上线网页
[aaa@qq.com ~]# cd /usr/share/zabbix/
[aaa@qq.com ~]# ls
actionconf.php chart6.php images screenedit.php
adm.gui.php chart7.php img screen.import.php
adm.housekeeper.php chart.php imgstore.php screens.php
adm.iconmapping.php charts.php include search.php
adm.images.php conf index_http.php services.php
adm.macros.php conf.import.php index.php setup.php
adm.other.php correlation.php items.php slideconf.php
adm.regexps.php discoveryconf.php js slides.php
adm.triggerdisplayoptions.php disc_prototypes.php jsLoader.php srv_status.php
adm.triggerseverities.php favicon.ico jsrpc.php styles
adm.valuemapping.php fonts latest.php sysmap.php
adm.workingtime.php graphs.php local sysmaps.php
api_jsonrpc.php history.php locale templates.php
app host_discovery.php maintenance.php toptriggers.php
applications.php hostgroups.php map.import.php tr_events.php
audio hostinventoriesoverview.php map.php trigger_prototypes.php
auditacts.php hostinventories.php overview.php triggers.php
auditlogs.php host_prototypes.php profile.php usergrps.php
browserwarning.php host_screen.php queue.php users.php
chart2.php hosts.php report2.php zabbix.php
chart3.php httpconf.php report4.php
chart4.php httpdetails.php robots.txt
chart5.php image.php screenconf.php
[aaa@qq.com zabbix]# cp -a * /usr/local/nginx/html/
cp: overwrite ‘/usr/local/nginx/html/index.php’? y
[aaa@qq.com zabbix]# chmod +x /usr/local/nginx/html/*
[aaa@qq.com zabbix]# ls /usr/local/nginx/html/index.*
/usr/local/nginx/html/index.html /usr/local/nginx/html/index.php
- 如果出现报错如下,说明权限的设置出现问题
解决办法:
[aaa@qq.com ~]# ll /etc/zabbix/web/ # 查看当前页面的权限
total 4
-rw-r--r-- 1 root root 1036 Apr 18 2019 maintenance.inc.php
[aaa@qq.com ~]# chmod -R 755 /etc/zabbix/web/ # 修改权限
[aaa@qq.com ~]# ll /etc/zabbix/web/
total 4
-rwxr-xr-x 1 zabbix zabbix 1036 Apr 18 2019 maintenance.inc.php
[aaa@qq.com ~]# chown -R zabbix:zabbix /etc/zabbix
[aaa@qq.com ~]# chown -R zabbix:zabbix /usr/share/zabbix
[aaa@qq.com ~]# chown -R zabbix:zabbix /usr/lib/zabbix
将服务设置为开机自启
[aaa@qq.com ~]# vim /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
/usr/local/qcloud/irq/net_smp_affinity.sh >/tmp/net_affinity.log 2>&1
/usr/local/qcloud/rps/set_rps.sh >/tmp/setRps.log 2>&1
/usr/local/qcloud/irq/virtio_blk_smp_affinity.sh > /tmp/virtio_blk_affinity.log 2>&1
/usr/local/qcloud/gpu/nv_gpu_conf.sh >/tmp/nv_gpu_conf.log 2>&1
/usr/local/nginx/sbin/nginx
/etc/init.d/php-fpm 2>&1
/usr/sbin/zabbix_server
[aaa@qq.com ~]# systemctl enable mysqld
- 出现此种报错直接在相应的路径手动上传文件即可
- 默认用户名:Admin,默认密码:zabbix
下载grafana
[aaa@qq.com opt]# wget https://dl.grafana.com/oss/release/grafana-7.1.5-1.x86_64.rpm
[aaa@qq.com opt]# yum -y install grafana-7.1.5-1.x86_64.rpm
[aaa@qq.com opt]# systemctl start grafana-server
[aaa@qq.com opt]# systemctl enable grafana-server
Created symlink from /etc/systemd/system/multi-user.target.wants/grafana-server.service to /usr/lib/systemd/system/grafana-server.service.
安装zabbix-grafana插件
# 列出当前可用的插件
[aaa@qq.com opt]# grafana-cli plugins list-remote
# 安装zabbix插件
[aaa@qq.com ~]# grafana-cli plugins install alexanderzobnin-zabbix-app
[aaa@qq.com ~]# ll /var/lib/grafana/plugins/
total 4
drwxr-xr-x 8 root root 4096 Sep 19 18:04 alexanderzobnin-zabbix-app
[aaa@qq.com ~]# cd /var/lib/grafana/plugins/
[aaa@qq.com plugins]# git clone https://github.com/alexanderzobnin/grafana-zabbix-app
[aaa@qq.com plugins]# cd grafana-zabbix-app/
[aaa@qq.com grafana-zabbix-app]# git pull
# 重启服务
[aaa@qq.com ~]# systemctl restart grafana-server
[aaa@qq.com ~]# systemctl enable grafana-server
[aaa@qq.com ~]# ss -nutlp | grep 3000
tcp LISTEN 0 128 [::]:3000 [::]:* users:(("grafana-server",pid=21886,fd=10))
访问grafana
[aaa@qq.com ~]# curl -I localhost:3000 # curl 3000端口重定向
HTTP/1.1 302 Found
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
Expires: -1
Location: /login
Pragma: no-cache
Set-Cookie: redirect_to=%2F; Path=/; HttpOnly; SameSite=Lax
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-Xss-Protection: 1; mode=block
Date: Mon, 21 Sep 2020 01:51:50 GMT
- 登录grafana
-
设置密码
-
启用zabbix-grafana插件
- 添加数据源
- 在下拉菜单上面找到zabbix,如果找不到,可以进行如下操作:
- 自动跳转到grafana数据源
- 如果出现unsigned,未签名的不能使用,可以进行如下操作,在配置文件中修改:
[aaa@qq.com ~]# find / -name grafana.ini
/etc/grafana/grafana.ini
[aaa@qq.com ~]# vim /etc/grafana/grafana.ini
697 allow_loading_unsigned_plugins = alexanderzobnin-zabbix-datasource
[aaa@qq.com ~]# systemctl restart grafana-server
- 选择Add data source,进行添加数据源
[aaa@qq.com ~]# find / -name api_jsonrpc.php
/usr/share/zabbix/api_jsonrpc.php
/usr/local/nginx/html/api_jsonrpc.php
- 进入数据源,可以选择默认的dashboards
- 在zabbix中配置被监控主机
- 在grafana中查看数据
上一篇: C++中string类实现教程
下一篇: 安装grafana并展示zabbix监控
推荐阅读
-
php安装xdebug/php安装pear/phpunit详解步骤(图)
-
Eclipse的PHP插件PHPEclipse安装和使用
-
python安装numpy&安装matplotlib& scipy的教程
-
Python安装Numpy和matplotlib的方法(推荐)
-
windows7下安装php的php-ssh2扩展教程
-
ubuntu下安装程序的三种方法总结(推荐)
-
Windows下的PHP 5.3.x安装 Zend Guard Loader教程
-
vue的安装及element组件的安装方法
-
安装 VS2005 SP1 有关问题的解决办法
-
详解Python网络框架Django和Scrapy安装指南