一、Linux 时间同步 1、时间同步一次:ntpdate ntp1.aliyun.com 2、定时任务同步 (1)crontab -e (2)按i 写入*/10 * * * * ntpdate ntp1.aliyun.com 说明放入定时任务中每隔10分钟执行一次 crontab -l 查看定时任务
|
tar -zxf prometheus-2.22.0.linux-amd64.tar.gz
mkdir /opt/monitor mv prometheus-2.22.0.linux-amd64 /opt/monitor/prometheus
vi /usr/lib/systemd/system/prometheus.service [Unit] Description=prometheus [Service] ExecStart=/opt/monitor/prometheus/prometheus --config.file=/opt/monitor/prometheus/prometheus.yml ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target
systemctl daemon-reload systemctl start prometheus systemctl enable prometheus
tar -zxf grafana-7.2.2.linux-amd64.tar.gz mv grafana-7.2.2 /opt/monitor/grafana
vi /usr/lib/systemd/system/grafana.service [Unit] Description=grafana [Service] ExecStart=/opt/monitor/grafana/bin/grafana-server -homepath=/opt/monitor/grafana ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target
systemctl daemon-reload systemctl start grafana systemctl enable grafana
vim /opt/monitor/prometheus/prometheus.yml: scrape_configs: - job_name: 'linux server' basic_auth: username: prometheus password: 123.com static_configs: - targets: ['192.168.0.13:9100'] -------------------------------------------------------------------
cd /opt/monitor/prometheus ./promtool check config ./prometheus.yml
ps -ef |grep prometheus kill -HUP 62291
|
tar -zxf node_exporter-1.0.1.linux-amd64.tar.gz mv node_exporter-1.0.1.linux-amd64 /usr/local/node_exporter
cd /usr/local/node_exporter vi config.yml basic_auth_users: prometheus: $2y$12$F8D.zKZEh9SRCLD4D6YnK.hNRWwWJQjD5guti5N846lTDsY.ToHMq 用户名 :密码 -----------------------------------------------------------------
yum install httpd-tools –y htpasswd -nBC 12 '' | tr -d ':\n'
vi /usr/lib/systemd/system/node_exporter.service [Unit] Description=node_exporter [Service] ExecStart=/usr/local/node_exporter/node_exporter --web.config=/usr/local/node_exporter/config.yml ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target
systemctl daemon-reload systemctl start node_exporter systemctl enable node_exporter
cat /usr/lib/systemd/system/node_exporter.service [Unit] Description=node_exporter [Service] ExecStart=/usr/local/node_exporter/node_exporter --web.config=/usr/local/node_exporter/config.yml --collector.systemd --collector.systemd.unit-whitelist=(docker|sshd|nginx).service ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target ------------------------------------------------------------ --collector.systemd --collector.systemd.unit-whitelist=(docker|sshd|nginx).service
|
学习:
https://www.cnblogs.com/chenqionghe/p/10494868.html