方法一、写入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. FirstGradle

    一.导入依赖 二.build.gradle 整合SpringBoot plugins { id 'java' } group 'com.qiang' version '1.0.0-SNAPSHOT' ...

  2. springboot整合zookeeper实现分布式锁

    目录 01 安装并允许zookeeper 02 springboot应用配置CuratorFramework 03 使用zookeeper实现集群只一个应用实例执行定时任务 04 使用zookeepe ...

  3. DLL-使用DLL

    动态链接库的使用 fangyukuan 2010.6.21 应用程序可以调用的DLL函数,在DLL中叫做导出函数,而在应用程序中叫做导入函数.应用程序中的导入函数与DLL文件中的导出函数进行链接有两种 ...

  4. 2018秋招C/C++面试题总结

    一.C和C++的区别是什么? C是面向过程的语言,C++是在C语言的基础上开发的一种面向对象编程语言,应用广泛.C中函数不能进行重载,C++函数可以重载C++在C的基础上增添类,C是一个结构化语言,它 ...

  5. ASP net core面试题汇总及答案

    在dot net core中,我们不需要关心如何释放这些服务, 因为系统会帮我们释放掉.有三种服务的生命周期. 单实例服务, 通过add singleton方法来添加.在注册时即创建服务, 在随后的请 ...

  6. C# Monitor.TryEnter 源码跟踪

    source: Monitor 获取指定对象的独占锁. [MethodImpl(MethodImplOptions.InternalCall), SecuritySafeCritical, __Dyn ...

  7. DeltaLake数据湖解决方案

    Delta Lake 是DataBricks公司推出的一种数据湖解决方案,Delta为该方案的核心组件.围绕数据流走向(数据入湖从流入数据湖.数据组织管理.数据查询到流出数据湖)推出了一系列功能特性, ...

  8. jwt《token》

    payload与claims只能存在一个这部分是jwt源码:依赖如下:官方文档的依赖 <dependency> <groupId>io.jsonwebtoken</gro ...

  9. linux多次登录失败锁定账户

    2021-07-22 1.配置对系统进行失败的ssh登录尝试后锁定用户帐户 # 配置登录访问的限制 vi /etc/pam.d/system-auth 或者 vi etc/pam.d/password ...

  10. cmd(命令行 )的命令

    cmd是command的缩写.即命令行 CMD命令锦集 1. gpedit.msc-----组策略 2. sndrec32-------录音机 3. Nslookup-------IP地址侦测器 ,是 ...