太原制作手机网站,网站建设策划公司地址,西安庆典公司,个人网站做贷款广告0. 介绍
用tar包的方式安装 Prometheus 和 Grafana
Prometheus:开源的监控方案Grafana:将Prometheus的数据可视化平台
1. Prometheus
1. 下载 与 解压
官网下载: https://prometheus.io/download/#prometheus上传至机器解压命令:tar -xzf prometheus-*.tar.gz
2. 启动与暂…0. 介绍
用tar包的方式安装 Prometheus 和 Grafana
Prometheus:开源的监控方案Grafana:将Prometheus的数据可视化平台
1. Prometheus
1. 下载 与 解压
官网下载: https://prometheus.io/download/#prometheus上传至机器解压命令:tar -xzf prometheus-*.tar.gz
2. 启动与暂停
进入解压后的文件夹:cd prometheus-* ll命令可以发现可执行文件 prometheus 和 prometheus.yml ,分别是启动文件和配置文件
启动prometheus我们可以编写systemd unit 服务,也可以直接nohup 直接挂起
2.1 挂起后台启动: nohup ./prometheus --config.fileprometheus.yml --web.enable-admin-api --web.enable-lifecycle nohup.out 21 –web.enable-admin-api: 开启API服务,为下个参数动态加载配置打基础–web.enable-lifecycle : 这个配置后,可以动态加载配置文件而无需重启prometheus,具体命令是 curl -X POST Prometheus所在机器ip:Prometheus监控的端口/-/reload21 :标准错误输出重定向标准输出, filename 可以实现也是一样的效果.21 是旧shell写法兼容性更高点nohup …: 只是将命令置于后台但是命令仍与终端窗口关联.导致默认情况下命令的标准输出和标准错误输出仍然连接到终端;nohup 将命令放入后台运行并且它会将命令的标准输出和标准错误输出重定向到一个名为 nohup.out 的文件中这样即使你关闭终端命令也会继续运行并且输出会写入到 nohup.out 文件中。看起来nohup拥有了 的效果,为什么还用?一方面是 比nohup更兼容 另一方面是 单独nohup后,你需要手动 ctrlz 将命令挂起, 配合 可以马上放入后台运行~ ps -ef|grep prometheus 命令可以查看prometheus进程信息 2.2 systemd service 启动
创建prometheus.service 文件
[Unit]
DescriptionPrometheus
Afternetwork.target
[Service]
Typesimple
ExecStart/opt/prometheus/prometheus --config.file/opt/prometheus.yml --web.enable-admin-api --web.enable-lifecycle
Restarton-failure
[Install]
WantedBymulti-user.target将上述文件保存到 /etc/systemd/system 目录后,输入下列命令 #1.加载系统服务 sudo systemctl daemon-reload #2.启动服务 sudo systemctl start prometheus.service #3.设置为系统自启动 sudo systemctl enable prometheus.service #4 .查看状态 sudo systemctl status prometheus.service Typesimple:该服务是个简单基本的服务,一旦启动命令被执行systemd 将认为服务已经启动完成不会监视服务进程的运行状态或退出。对于启动后会一直运行的服务如守护进程非常适用因为它们会在后台运行而不会立即退出。Restart指定服务在失败或退出后是否自动重启.no/always/on-failure(非零退出代码失败退出时)/on-abnormal(服务以异常退出时如由信号终止)
3. web查看
浏览器 打开 Prometheus所在机器ip:9090 (默认端口9090)
4. 修改配置文件yml
2. Grafana