关于grafana:Grafana部署方案

38次阅读

共计 2906 个字符,预计需要花费 8 分钟才能阅读完成。

筹备工作

1、创立用户和配置环境参数

(1)、创立用户和创立所需目录

[root@centos ~]# groupadd prometheus
[root@centos ~]# useradd -d /home/prometheus -g prometheus -m prometheus
[root@centos ~]# chmod 755 /home/prometheus
[root@centos ~]# mkdir -p /home/prometheus/software
[root@centos ~]# mkdir -p /home/prometheus/yunwei
[root@centos ~]# chown -R prometheus:prometheus /home/prometheus
[root@centos ~]# mkdir -p /data/grafana
[root@centos ~]# chown -R prometheus:prometheus /data/grafana

(2)、下载

https://dl.grafana.com/oss/release/grafana-9.3.6.linux-amd64….

部署计划

1、部署

(1)、敞开防火墙

[root@centos ~]# systemctl stop firewalld
[root@centos ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@centos ~]# setenforce 0
[root@centos ~]# getenforce 
Permissive
[root@centos ~]# vi /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

(2)、解压安装包并备份配置文件

[prometheus@centos ~]$ tar zxf $HOME/software/grafana-9.3.6.linux-amd64.tar.gz -C $HOME
[prometheus@centos ~]$ cp $HOME/grafana-9.3.6/conf/defaults.ini $HOME/grafana-9.3.6/conf/grafana.ini

(3)、创立所需目录

[prometheus@centos ~]$ mkdir -p /data/grafana/grafana-9.3.6/logs
[prometheus@centos ~]$ mkdir -p /data/grafana/grafana-9.3.6/data/plugins

2、调整配置文件

[prometheus@centos ~]$ vi $HOME/grafana-9.3.6/conf/grafana.ini
# 批改配置地位如下
#################################### Paths ###############################
[paths]
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
data = /data/grafana/grafana-9.3.6/data
# Directory where grafana can store logs
logs = /data/grafana/grafana-9.3.6/logs
# Directory where grafana will automatically scan and look for plugins
plugins = /data/grafana/grafana-9.3.6/data/plugins

#################################### Server ##############################
[server]
# The http port to use
http_port = 8666

# the path relative working path
static_root_path = public

#################################### Security ############################
[security]
# default admin user, created on startup
admin_user = admin

# default admin password, can be changed before first start of grafana, or in profile settings
admin_password = "*******"

3、启停服务与创立脚本

(1)、查看 grafana 版本信息

[prometheus@centos ~]$ $HOME/grafana-9.3.6/bin/grafana-server -v
Version 9.3.6 (commit: 978237e7cb, branch: HEAD)

(2)、启动脚本配置

[prometheus@centos ~]$ vi $HOME/yunwei/grafana-9.3.6_start.sh
#!/bin/bash
#
cd $HOME/grafana-9.3.6/bin
./grafana-server -config=/home/prometheus/grafana-9.3.6/conf/grafana.ini 2&>1 &

(3)、进行脚本配置

[prometheus@centos ~]$ vi $HOME/yunwei/grafana-9.3.6_stop.sh
#!/bin/bash
#
grafa_pid=`ps -ef|grep grafana-server|grep grafana.ini|awk '{print $2}'`
kill -9 $grafa_pid

正文完
 0