准备工作

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

iM唐小龙
1 声望0 粉丝