方法一、写入rc.local

在/etc/rc.local文件中编辑需要执行的脚本或者命令,我个人习惯用这个,因人而异,有的项目可能需要热加载配置文件,用服务会更好

#普罗米修斯启动,需要后面接config配置文件路径选项
nohup /root/linux_jiankong/prometheus/prometheus --config.file=/root/linux_jiankong/prometheus/prometheus.yml & #node_exporte启动
nohup /root/linux_jiankong/node_exporter/node_exporter --web.listen-address=:9100 & #启动influxdb数据库
influxd -config influxdb.conf #启动grafana
systemctl start grafana-server.service

方法二、设置为服务,使用systemctl来管理

prometheus

  • 创建node_exporter组和用户,用于运行node_exporter和prometheus(也可以不创建,不影响的)
  • 创建一个node_exporter.service文件
  • 启动,并配置开机启动

创建Prometheus组和用户(非必须步骤)

sudo groupadd -r prometheus
sudo useradd -r -g prometheus -s /sbin/nologin -M -c "prometheus Daemons" prometheus

创建services服务文件

如果没创建prometheus组合用户,则Service的User就不用写

cat > /etc/systemd/system/prometheus.service <<EOF
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=自己本地路径/prometheus --config.file=/自己本地路径/prometheus.yml --storage.tsdb.path=自己本地路径声明的data目录/data
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF

启动Prometheus,将服务设置为开机自启动

systemctl daemon-reload
systemctl start prometheus.service
systemctl status prometheus.service
systemctl enable prometheus.service

node_exporter

换种方式啊,其实一样的

vim /etc/systemd/system/node_exporter.service

[Unit]
Description=node_exporter Monitoring System
Documentation=node_exporter Monitoring System [Service]
ExecStart=自己本地路径/node_exporter --web.listen-address=:9100 [Install]
WantedBy=multi-user.target #设置开机自启
systemctl daemon-reload
systemctl start node_exporter.service
systemctl status node_exporter.service
systemctl enable node_exporter.service

prometheus、node_exporter设置开机自启动的更多相关文章

  1. Fedora 16设置开机自启动程序与Ubuntu的区别

    Ubuntu设置开机自启动脚本的方法是:修改/etc/init.d/rc.local这个文件,添加需要启动的程序即可,相关函数如下: void SetSysAutoBoot() { ] = {}; ; ...

  2. linux_设置开机自启动程序脚本

    设置开机自启动

  3. Linux服务器,服务管理--systemctl命令详解,设置开机自启动

    Linux服务器,服务管理--systemctl命令详解,设置开机自启动 syetemclt就是service和chkconfig这两个命令的整合,在CentOS 7就开始被使用了. 摘要: syst ...

  4. CentOS 6下 Oracle11gR2 设置开机自启动

    [1] 更改/etc/oratab # This file is used by ORACLE utilities. It is created by root.sh # and updated by ...

  5. Ubuntu14.04设置开机自启动脚本

    方法一.编辑rc.loacl脚本  Ubuntu开机之后会执行/etc/rc.local文件中的脚本,所以我们可以直接在/etc/rc.local中添加启动脚本.在 exit 0 前面添加好脚本代码, ...

  6. 设置开机自启动VirtualBox虚拟机系统

    如果常用VirtualBox虚拟机系统的话,设置个随开机启动也是很方便的.不需要打开VirtualBox窗口,直接就是系统启动了. 又继续上网搜索学习了.(设置开机自启动VirtualBox虚拟机系统 ...

  7. CentOS7设置开机自启动命令大全

    任务 旧指令 新指令 使某服务自动启动 chkconfig --level 3 httpd  on              systemctl enable httpd.service 使某服务不自 ...

  8. ntp服务设置开机自启动失败

    设置了ntpd开机自启动,重启服务器ntpd没有自启动 1.需要禁掉chronyd.service: systemctl disable chronyd.service 2.手动启动ntpd: sys ...

  9. CentOS7设置开机自启动方式

    方式一: # 在/etc/rc.d/rc.local文件中追加启动命令,该文件追加后,会随着机器自动后,自动运行文件中的命令 # vim /etc/rc.d/rc.local # 权限问题:在cent ...

随机推荐

  1. linux 磁盘IO速度测试

    写入速度测试命令:time dd oflag=direct if=/dev/zero of=/data2/test bs=2k count=1000000 //if表示从哪里读取 of表示写入到哪里 ...

  2. 北航OO第四单元——UML图解析

    北航OO第四单元--UML图解析 作业要求简析 刚接触本次作业可能需要花上一会才能搞清楚到底是要我们写个啥,在这里简单说一下: UML图的保存格式.mdj文件是以json文件的形式存储的,将每一个Um ...

  3. DVWA(六):XSS-Reflected 反射型XSS全等级详解

    XSS 概念: 由于web应用程序对用户的输入过滤不严,通过html注入篡改网页,插入恶意脚本,从而在用户浏览网页时,控制用户浏览器的一种攻击. XSS类型: Reflected(反射型):只是简单的 ...

  4. SwiftUI图片处理(缩放、拼图)

    采用SwiftUI Core Graphics技术,与C#的GDI+绘图类似,具体概念不多说,毕竟我也是新手,本文主要展示效果图及代码,本文示例代码需要请拉到文末自取. 1.图片缩放 完全填充,变形压 ...

  5. NOIP 模拟 $15\; \text{夜莺与玫瑰}$

    题解 一道很妙的题,让求对于一个矩阵中,两点相连成线,有多少条直线,他们的交集是有限集. 转化一下题目,发现水平和竖直的只有 \(n+m\) 条,而左斜和右斜的条数是相同的,所以我们只需求出左或右中的 ...

  6. 在Asp .net core 中通过属性映射实现动态排序和数据塑形

    目录 属性映射服务实现 动态排序 数据塑形 属性映射服务实现 public class PropertyMappingValue { public IEnumerable<string> ...

  7. 小程序iphone蒙层滚动穿透

    如图,这个弹出层在滚动列表的时候,在iPhone上是会穿透导致页面也跟着滚动,所以这时不能用普通的view标签加scroll属性实现,看了下文档发现有专门的scroll-view组件,用该组件替换就可 ...

  8. mysql 局域网连接

    下面分别简述操作: 配置虚拟机网络 默认方式是NAT,但为了让宿主机之外的其它计算机也能访问虚拟机,NAT方式配置起来有些复杂,这里推荐用桥接模式,关于VM的几种网络方式的区别,可以参考这篇文章配置好 ...

  9. 【OpenLayers】入门教程地址

    [OpenLayers]入门教程地址:  点击进入   http://anzhihun.coding.me/ol3-primer/index.html 简书地址 :  http://www.jians ...

  10. Spring Boot 入门系列(二十三)整合Mybatis,实现多数据源配置!

    d之前介绍了Spring Boot 整合mybatis 使用注解方式配置的方式实现增删改查以及一些复杂自定义的sql 语句 .想必大家对spring boot 项目中,如何使用mybatis 有了一定 ...