背景:在入职很多家公司,存在一个现象就是维护服务器比较少而没有运维,而是开发兼职,所以在很多运维方面的工具缺失。作为刚入职的新员工,一作为自己练手的运维项目,二也是想推进运维工作。也曾问过运维的同事,当下主流的运维工具有哪些,故而选择比较有针对性的工具练手:zabbix、Prometheus等。

1.安装go 语言环境,yum install go , go version 检测

2.在监控服务器上安装prometheushttps://prometheus.io/download/安装其他监控程序

修改prometheus.yml配置文件:

- job_name: 'node_exporter' #监听插件服务

static_configs:

- targets: ['127.0.0.1:9100'] #配置监听服务器ip:端口

nohup ./prometheus --config.file=prometheus.yml &Linux部署prometheus监控系统-作为运维Demo参考

3.在被监控环境上安装export

下载node_exporter,作为系统层监控,其他例如mysql_exporter数据库监控、可以在prometheus官网下载如下监控插件Linux部署prometheus监控系统-作为运维Demo参考

下载的是二进制包,直接tar -zxf解压,进入目录nohup ./node_exporter &运行即可。

tips:systemctl添加服务列表,例如将node_exporter插件创建servier,在目录下/etc/systemd/system/新建node_exporter.service:

[Unit]

Description=Prometheus node_exporter #描述

[Service]

User=nobody

ExecStart=/data/node_exporter/node_exporter --log.level=error

ExecStop=/usr/bin/killall node_exporter

MemoryLimit=300M #........300M

CPUQuota=100% #..CPU.......

[Install]

WantedBy=default.target

然后需要刷新配置: systemctl daemon-reload

systemctl enable mysql_exporter

 

 

列出所有服务“systemctl list-unit-files --type=service”

列出开启服务" systemctl list-unit-files|grep enabled"

列出失败服务“ systemctl --failed”

tips:下载mysql_exporter,linux下wget 下载,tar -zxf 解压 -C指定必须存在的目录

解压目录下./mysql_exporter可以得到启动的服务端口,好在Prometheus的配置文件中配置,在此之前需要在/root目录下创建.my.cnf文件,与/etc/my.cnf文件很相似注意那一点,内容如下:

[[email protected] prometheus]# cat /root/.my.cnf

[client]

user=root

password=Hcp_dev_0326

port=3306

bind-address=127.0.0.1

[[email protected] prometheus]#

 

4.安装grafana

wget https://dl.grafana.com/oss/release/grafana-6.3.5-1.x86_64.rpm

sudo yum localinstall grafana-6.3.5-1.x86_64.rpm

不修改配置文件,配置路径:/etc/grafana/,默认端口3000,可以直接web访问,添加prometheus数据源下载对应的dashboards面板。在点击左下角的疑问号,进入documentation,选择DashBoards,刷选实际情况所需要的模版,负载idLinux部署prometheus监控系统-作为运维Demo参考

 

在grafana导入模版id,选择对应的数据源,然后就可以愉快的监控了。Linux部署prometheus监控系统-作为运维Demo参考

 

https://blog.csdn.net/csolo/article/details/82460539Linux部署prometheus监控系统-作为运维Demo参考

 

tips:w命令可以,查看当前linux服务器连接用户数与top看到的users数一致,pkill -kill -t可以踢人(退出终端)

Linux部署prometheus监控系统-作为运维Demo参考

 

相关文章:

  • 2021-07-21
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
猜你喜欢
  • 2021-12-29
  • 2021-12-03
  • 2021-06-12
  • 2021-11-16
  • 2022-12-23
  • 2021-06-14
  • 2021-11-17
相关资源
相似解决方案