1. Create user and bin/config directories
useradd --no-create-home --shell /bin/false prometheus
cat /etc/passwd | grep prometheus
prometheus:x:1001:1001::/home/prometheus:/bin/false
grep prometheus /etc/group
prometheus:x:1001:
mkdir -p /etc/prometheus
mkdir -p /var/lib/prometheus
2. Copy binaries and config files
cd <prometheus install dir>
cp ./prometheus /usr/local/bin/
cp ./promtool /usr/local/bin/
cp ./prometheus.yml /etc/prometheus/
cp -r ./consoles /etc/prometheus/
cp -r ./console_libraries /etc/prometheus
- check
ls /usr/local/bin
prometheus promtool
ls /etc/prometheus
console_libraries consoles prometheus.yml
3. Change ownership
chown prometheus:prometheus /etc/prometheus
chown -R prometheus:prometheus /etc/prometheus/consoles
chown -R prometheus:prometheus /etc/prometheus/console_libraries
chown prometheus:prometheus /var/lib/prometheus
chown prometheus:prometheus /usr/local/bin/prometheus
chown prometheus:prometheus /usr/local/bin/promtool
4. Create service config file
sudo vi /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.target
5. Reload / enable / start service
systemctl daemon-reload
systemctl enable promethues
systemctl start promethues
systemctl status promethues
# systemctl status prometheus
● prometheus.service - Prometheus
Loaded: loaded (/etc/systemd/system/prometheus.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2023-06-29 14:32:49 KST; 3s ago
Main PID: 3733 (prometheus)
Tasks: 9 (limit: 50220)
Memory: 16.8M
CGroup: /system.slice/prometheus.service
└─3733 /usr/local/bin/prometheus --config.file /etc/prometheus/prometheus.yml --storage.tsdb.path /var/lib/prometheus/ --web.console.templates=/etc/prometheus/consoles --web.con>
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.575Z caller=head.go:676 level=info component=tsdb msg="On-disk memory mappable chunks replay completed" duration=1.782µs
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.575Z caller=head.go:684 level=info component=tsdb msg="Replaying WAL, this may take a while"
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.576Z caller=head.go:755 level=info component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.576Z caller=head.go:792 level=info component=tsdb msg="WAL replay completed" checkpoint_replay_duration=21.898µs wal_rep>
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.577Z caller=main.go:1040 level=info fs_type=XFS_SUPER_MAGIC
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.577Z caller=main.go:1043 level=info msg="TSDB started"
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.577Z caller=main.go:1224 level=info msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.581Z caller=main.go:1261 level=info msg="Completed loading of configuration file" filename=/etc/prometheus/prometheus.ym>
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.581Z caller=main.go:1004 level=info msg="Server is ready to receive web requests."
Jun 29 14:32:49 prometheus prometheus[3733]: ts=2023-06-29T05:32:49.581Z caller=manager.go:995 level=info component="rule manager" msg="Starting rule manager..."
'IT > opensource' 카테고리의 다른 글
Prometheus/node_exporter : install & configure systemd (0) | 2023.06.30 |
---|---|
Grafana install on redhat / centos (0) | 2023.06.29 |