본문 바로가기
클라우드/prometheus

ubuntu Prometheus 설치

by "뭉치" 2021. 9. 27.
728x90
환경
Oracle VM VirtualBox v6.1.6 r137129
Ubuntu 18.04.4 LTS

(network - NAT 네트워크)
vm 접속 IP : 192.168.56.1
vm 내부 IP : 10.0.2.5
계정생성
apt-get update, upgrade

 

pigohno@server01:~$ sudo apt-get update
Hit:2 http://kr.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://kr.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Hit:1 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Get:5 http://kr.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:3 https://packages.gitlab.com/gitlab/gitlab-ee/ubuntu bionic InRelease [23.3 kB]
Get:6 http://kr.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:7 http://kr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [969 kB]
Get:8 https://packages.gitlab.com/gitlab/gitlab-ee/ubuntu bionic/main amd64 Packages [38.2 kB]
Get:9 http://kr.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [329 kB]
Get:10 http://kr.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,081 kB]
Get:11 http://kr.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [336 kB]
Get:12 http://kr.archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [748 kB]
Get:13 http://kr.archive.ubuntu.com/ubuntu bionic-security/main Translation-en [237 kB]
Get:14 http://kr.archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [673 kB]
Get:15 http://kr.archive.ubuntu.com/ubuntu bionic-security/universe Translation-en [223 kB]
Fetched 4,910 kB in 19s (263 kB/s)
Reading package lists... Done

pigohno@server01:~$ sudo apt-get upgrade
dashboard 사용자 계정 생성
pigohno@server01:~$ sudo adduser dashboard
Adding user `dashboard' ...
Adding new group `dashboard' (1001) ...
Adding new user `dashboard' (1001) with group `dashboard' ...
Creating home directory `/home/dashboard' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for dashboard
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y
설치 디렉토리 생성
pigohno@server01:/$ sudo mkdir apps
pigohno@server01:/$ cd apps
pigohno@server01:/apps$ sudo mkdir prometheus grafana
pigohno@server01:/apps$ sudo chown dashboard:dashboard prometheus grafana
Prometheus 설치 및 실행

https://prometheus.io/docs/prometheus/latest/installation/
https://prometheus.io/download/
# 파일 다운
pigohno@server01:/apps/prometheus$ sudo wget https://github.com/prometheus/prometheus/releases/download/v2.18.1/prometheus-2.18.1.linux-amd64.tar.gz
--2020-06-17 02:29:58--  https://github.com/prometheus/prometheus/releases/download/v2.18.1/prometheus-2.18.1.linux-amd64.tar.gz
Resolving github.com (github.com)... 52.78.231.108
Connecting to github.com (github.com)|52.78.231.108|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/6838921/2f454700-90ae-11ea-89e1-3aeb351fdfa5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200617%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200617T022855Z&X-Amz-Expires=300&X-Amz-Signature=976b526d23c49ee2ab6875a7f00d345bd607f0d6cb8ba9982f303757bd881f35&X-Amz-SignedHeaders=host&actor_id=0&repo_id=6838921&response-content-disposition=attachment%3B%20filename%3Dprometheus-2.18.1.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2020-06-17 02:29:58--  https://github-production-release-asset-2e65be.s3.amazonaws.com/6838921/2f454700-90ae-11ea-89e1-3aeb351fdfa5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200617%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200617T022855Z&X-Amz-Expires=300&X-Amz-Signature=976b526d23c49ee2ab6875a7f00d345bd607f0d6cb8ba9982f303757bd881f35&X-Amz-SignedHeaders=host&actor_id=0&repo_id=6838921&response-content-disposition=attachment%3B%20filename%3Dprometheus-2.18.1.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.10.147
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.10.147|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 63373350 (60M) [application/octet-stream]
Saving to: ‘prometheus-2.18.1.linux-amd64.tar.gz’

prometheus-2.18.1.linux-amd64.tar.gz        100%[===========================================================================================>]  60.44M  5.06MB/s    in 20s

2020-06-17 02:30:18 (3.09 MB/s) - ‘prometheus-2.18.1.linux-amd64.tar.gz’ saved [63373350/63373350]
압축해제
root@server01:/apps/prometheus# tar xvzf prometheus-2.19.0.linux-amd64.tar.gz
prometheus-2.19.0.linux-amd64/
prometheus-2.19.0.linux-amd64/consoles/
prometheus-2.19.0.linux-amd64/consoles/prometheus.html
prometheus-2.19.0.linux-amd64/consoles/node-overview.html
prometheus-2.19.0.linux-amd64/consoles/node-disk.html
prometheus-2.19.0.linux-amd64/consoles/index.html.example
prometheus-2.19.0.linux-amd64/consoles/prometheus-overview.html
prometheus-2.19.0.linux-amd64/consoles/node.html
prometheus-2.19.0.linux-amd64/consoles/node-cpu.html
prometheus-2.19.0.linux-amd64/tsdb
prometheus-2.19.0.linux-amd64/NOTICE
prometheus-2.19.0.linux-amd64/prometheus
prometheus-2.19.0.linux-amd64/LICENSE
prometheus-2.19.0.linux-amd64/prometheus.yml
prometheus-2.19.0.linux-amd64/console_libraries/
prometheus-2.19.0.linux-amd64/console_libraries/menu.lib
prometheus-2.19.0.linux-amd64/console_libraries/prom.lib
prometheus-2.19.0.linux-amd64/promtool


# 트러블슈팅
# wget으로 받은 파일이 깨져서 압축이 정상적으로 풀리지 않았다.
# 홈페이지(https://prometheus.io/download/)에서 직접 받은 후 ftp로 복사 후 압축해제를 했더니 정상적으로 풀림
prometheus 실행
root@server01:/apps/prometheus# cd prometheus-2.19.0.linux-amd64/
root@server01:/apps/prometheus/prometheus-2.19.0.linux-amd64# mv * ../
root@server01:/apps/prometheus# ./prometheus --config.file=prometheus.yml &
[1] 27380
root@server01:/apps/prometheus# level=info ts=2020-06-17T05:12:58.302Z caller=main.go:302 msg="No time or size retention was set so using the default time retention" duration=15d
level=info ts=2020-06-17T05:12:58.302Z caller=main.go:337 msg="Starting Prometheus" version="(version=2.19.0, branch=HEAD, revision=5d7e3e970602c755855340cb190a972cebdd2ebf)"
level=info ts=2020-06-17T05:12:58.302Z caller=main.go:338 build_context="(go=go1.14.4, user=root@d4cf5c7e268d, date=20200609-10:29:59)"
level=info ts=2020-06-17T05:12:58.302Z caller=main.go:339 host_details="(Linux 4.15.0-106-generic #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020 x86_64 server01 (none))"
level=info ts=2020-06-17T05:12:58.302Z caller=main.go:340 fd_limits="(soft=1024, hard=1048576)"
level=info ts=2020-06-17T05:12:58.302Z caller=main.go:341 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2020-06-17T05:12:58.303Z caller=main.go:678 msg="Starting TSDB ..."
level=info ts=2020-06-17T05:12:58.304Z caller=web.go:524 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2020-06-17T05:12:58.306Z caller=head.go:645 component=tsdb msg="Replaying WAL and on-disk memory mappable chunks if any, this may take a while"
level=info ts=2020-06-17T05:12:58.307Z caller=head.go:706 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
level=info ts=2020-06-17T05:12:58.307Z caller=head.go:709 component=tsdb msg="WAL replay completed" duration=911.508µs
level=info ts=2020-06-17T05:12:58.309Z caller=main.go:694 fs_type=EXT4_SUPER_MAGIC
level=info ts=2020-06-17T05:12:58.310Z caller=main.go:695 msg="TSDB started"
level=info ts=2020-06-17T05:12:58.312Z caller=main.go:799 msg="Loading configuration file" filename=prometheus.yml
level=info ts=2020-06-17T05:12:58.314Z caller=main.go:827 msg="Completed loading of configuration file" filename=prometheus.yml
level=info ts=2020-06-17T05:12:58.315Z caller=main.go:646 msg="Server is ready to receive web requests."
접속 확인
http://localhost:9090/graph
http://192.168.56.1:9090/graph

# 트러블슈팅
포트포워딩, ufw 등 방화벽 설정

728x90

댓글