0
点赞
收藏
分享

微信扫一扫

Centos8安装 Prometheus2.31.1监控Go1.17.5\Python3.8.10\Mysql8.0.27\Node\Grafana8.3.3(亲测有效)

尤克乔乔 2022-02-24 阅读 48

一、更换华为源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo
yum clean all 
yum makecache
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.b

二、更新套件、库

yum  update -y
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install libffi-devel -y
yum install -y gcc gcc-c++ openssl-devel zlib-devel
yum -y install  gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel firewalld autoconf automake

三、安装软件

1、go安装

下载:wget https://dl.google.com/go/go1.17.5.linux-amd64.tar.gz
压缩到/usr/local目录下:tar -C /usr/local -xzf go1.17.5.linux-amd64.tar.gz

配置go

vi /etc/profile
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/root/go
export PATH=$PATH:$GOPATH/BIN

source /etc/profile

vi /etc/profile.d/golang.sh
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/root/go
export PATH=$PATH:$GOPATH/BIN

执行 source /etc/profile.d/golang.sh

测试golang执行文件:vim Hello.go

package main
import "fmt"
 
func main() {
 
    fmt.Println("hello world")
    var str string = "hello agin"
    fmt.Println(str)
 
}

保存并执行:go run ./Hello.go

2、安装Prometheus2.31.1监控

下载:wget https://github.com/prometheus/prometheus/releases/download/v2.31.1/prometheus-2.31.1.linux-amd64.tar.gz
解压到/usr/local/目录下:tar xf prometheus-2.31.1.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv prometheus-2.31.1.linux-amd64/ prometheus
useradd -M -s /sbin/nologin prometheus
mkdir -p /data/prometheus
chown -R prometheus.prometheus /usr/local/prometheus /data/prometheus

配置service文件:vim /usr/lib/systemd/system/prometheus.service

[Unit]
Description=The Prometheus Server
After=network.target

[Service]
Restart=on-failure

Type=simple
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml
RestartSec=15s

[Install]
WantedBy=multi-user.target

保存并执行:systemctl daemon-reload

启动参数介绍
--config.file             #加载prometheus的配置文件
--web.listen-address   #监听prometheus的web地址和端口
--web.enable-lifecycle #热启动参数,可以在不中断服务的情况下重启加载配置文件
--storage.tsdb.retention   #数据持久化的时间                         
--storage.tsdb.path        #数据持久化的保存路径

设置开机启动:systemctl enable prometheus
启动服务:systemctl start prometheus
重启服务:systemctl restart prometheus

访问:IP地址+9090端口号进行访问

未完待续

 

举报

相关推荐

0 条评论