node_exporter服务安装并启动

📅 2026/8/21 15:09:52
node_exporter服务安装并启动
node_exporter服务安装并启动1、介绍2、下载node_exporter3、解压缩文件4、新增配置文件5、启动node_exporter服务6、配置开机自启动1、介绍node_exporter是一个开源的指标收集器主要用于收集和暴露主机的各种系统指标这些指标可以被Prometheus监控系统使用。2、下载node_exporter下载地址https://prometheus.io/download/下载node_exporter-1.9.0.linux-amd64.tar.gz3、解压缩文件执行命令tar -xvf node_exporter-1.9.0.linux-amd64.tar.gz4、新增配置文件如果有安全问题需要认证则需要新增认证配置文件安装工具yum install -y httpd-tools生成密码echo your-password | htpasswd -i -n -B prometheus创建配置文件cat web.yml EOF basic_auth_users: prometheus: $2y$05$WRpK4YpXzWycOd61p6KPieq.1fJbPOZCsQWYx4U0VVXComBeTS2qC EOF5、启动node_exporter服务nohup ./node_exporter --web.listen-address:9100 --web.config.fileweb.yml nohup.log 21 默认端口91006、配置开机自启动vi /etc/systemd/system/node_exporter.service编辑配置文件[Unit] DescriptionNode Exporter Afternetwork.target Documentationhttps://prometheus.io/docs/guides/node-exporter/ [Service] Userroot Grouproot #工作目录关键切换到你的目录以便读取 web.yml WorkingDirectory/home/lwlk/apps/node_exporter #启动命令使用绝对路径更稳妥 ExecStart/home/lwlk/apps/node_exporter/node_exporter --web.listen-address:9100 --web.config.fileweb.yml #自动重启策略 Restarton-failure RestartSec5s #日志输出推荐让 systemd 接管日志方便查看 StandardOutputjournal StandardErrorjournal [Install] WantedBymulti-user.target重新加载systemd配置systemctl daemon-reload设置开机自启systemctl enable node_exporter启动node_exporterr服务systemctl start node_exporter停止node_exporter服务systemctl stop node_exporter重启服务systemctl restart node_exporter检查服务状态systemctl status node_exporter