安装prometheus并设置system启动程序

配置yum源

yum -y install wget
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
yum -y install lrzsz

配置prometheus

[root@localhost opt]# dir
prometheus-2.18.1.linux-amd64.tar.gz
[root@localhost opt]# tar -zxvf prometheus-2.18.1.linux-amd64.tar.gz
[root@localhost opt]# cp -r prometheus-2.18.1.linux-amd64 /usr/local/prometheus
[root@jgxxpt-nginx2 prometheus]# cat prometheus.yml 
# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - 192.168.145.11:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "rules/*_rules.yml"
  - "rules/*_alerts.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
    static_configs:
      - targets: ["localhost:9090"]
      - targets: ["localhost:9093"]
  - job_name: "node_exporter"
    file_sd_configs:
      - files: ['/usr/local/prometheus/sd_config/*.yml']
        # 每过5秒动态发现服务配置
        refresh_interval: 5s

设置systemd服务

[root@localhost ~]# cat /usr/lib/systemd/system/prometheus.service 
[Unit]
Description=Prometheus server daemon
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/prometheus/prometheus \
    --config.file=/usr/local/prometheus/prometheus.yml \
    --storage.tsdb.path="/usr/local/prometheus/data" \
    --storage.tsdb.retention=15d \
    --web.console.templates="/usr/local/prometheus/consoles" \
    --web.console.libraries="/usr/local/prometheus/console_libraries" \
    --web.max-connections=512 \
    --web.external-url "http://192.168.1.4:9090" \
    --web.listen-address=0.0.0.0:9090
Restart=on-failure

[Install]
WantedBy=multi-user.target

参数说明:
ExecStart=/usr/local/prometheus/prometheus #启动运行prometheus程序所在的路径
–config.file=/usr/local/prometheus/prometheus.yml #指定prometheus.yml配置文件路径
–storage.tsdb.path=”/usr/local/prometheus/data” #指定监控指标数据存储的路径
–storage.tsdb.retention=15d #历史数据最大保留时间,默认15天
–web.console.templates=”/usr/local/prometheus/consoles” #指定控制台模板目录路径
–web.console.libraries=”/usr/local/prometheus/console_libraries” #指定控制台库目录路径
–web.max-connections=512 #设置最大同时连接数
–web.external-url “http://192.168.1.4:9090” #用于生产返回prometheus相对的绝对链接地址,可以在后续告警通知内容中直接点击链接地址访问prometheus Web UI。其格式为:http://{ip或者域名}:9090
–web.listen-address=0.0.0.0:9090 #prometheus默认监控端口

systemctl命令介绍:
systemctl daemon-reload #通知systemctl重新加载配置文件
systemctl enable prometheus.service #设置为开机自启动
systemctl disable prometheus.service #如果不想设置为开机启动,可以关闭。关闭开机自启动
systemctl start prometheus.service #开启服务
systemctl status prometheus.service #查看服务状态
systemctl restart prometheus.service #重启服务
systemctl stop prometheus.service #关闭服务

安装prometheus并设置system启动程序
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇