今天是安装 Time-series DB,我们要安装的 DB 是我们先前示范过的 InfluxDB 和 Prometheus
InfluxDB 因为有提供 deb 所以安装起来比较简单,但 Prometheus 安装就稍微复杂了点,因为要手动复制档案进系统
我们一样拿之前写好的 Terraform 和 Ansible 档案来改,目录结构大概如下
.
├── ansible.cfg
├── deploy.yml
├── lxc.tf
├── main.tf
├── roles
│ ├── apt_upgrade
│ │ └── tasks
│ │ └── main.yml
│ ├── install_influxdb
│ │ └── tasks
│ │ └── main.yml
│ └── install_prometheus
│ ├── files
│ │ ├── prometheus
│ │ │ ├── console_libraries
│ │ │ │ ├── menu.lib
│ │ │ │ └── prom.lib
│ │ │ ├── consoles
│ │ │ │ ├── index.html.example
│ │ │ │ ├── node-cpu.html
│ │ │ │ ├── node-disk.html
│ │ │ │ ├── node.html
│ │ │ │ ├── node-overview.html
│ │ │ │ ├── prometheus.html
│ │ │ │ └── prometheus-overview.html
│ │ │ ├── LICENSE
│ │ │ ├── NOTICE
│ │ │ ├── prometheus
│ │ │ ├── prometheus.yml
│ │ │ └── promtool
│ │ └── prometheus.service
│ └── tasks
│ └── main.yml
└── terraform.tfvars
11 directories, 26 files
这里我们用的方式是在 Ansible 里放好 Prometheus 的档案,然後再透过 Ansible 复制进系统
此外我们在安装 InfluxDB 时也开了一个 Database,让 Telegraf 等等能写进 InfluxDB
# roles/install_influxdb/tasks/main.yml
---
- name: Install InfluxDB
apt:
deb: https://dl.influxdata.com/influxdb/releases/influxdb_1.8.2_amd64.deb
tags:
- influxdb
- name: Enable and start InfluxDB
systemd:
name: influxdb
enabled: yes
state: started
tags:
- influxdb
- name: Create database telegraf
command: influx -execute 'CREATE DATABASE telegraf'
tags:
- influxdb
# roles/install_prometheus/tasks/main.yml
---
- name: Copy prometheus to /usr/local/bin
copy:
src: prometheus/prometheus
dest: /usr/local/bin/prometheus
owner: root
group: root
mode: '0755'
tags:
- prometheus
- name: Copy promtool to /usr/local/bin
copy:
src: prometheus/promtool
dest: /usr/local/bin/promtool
owner: root
group: root
mode: '0755'
tags:
- prometheus
- name: Create folder /etc/prometheus
file:
path: /etc/prometheus
owner: root
group: root
mode: '0755'
state: directory
tags:
- prometheus
- name: Copy console_libraries to /etc/prometheus
copy:
src: prometheus/console_libraries
dest: /etc/prometheus
owner: root
group: root
tags:
- prometheus
- name: Copy consoles to /etc/prometheus
copy:
src: prometheus/consoles
dest: /etc/prometheus
owner: root
group: root
tags:
- prometheus
- name: Copy prometheus.yml to /etc/prometheus
copy:
src: prometheus/prometheus.yml
dest: /etc/prometheus
owner: root
group: root
tags:
- prometheus
- name: Copy prometheus.service
copy:
src: prometheus.service
dest: /etc/systemd/system/prometheus.service
owner: root
group: root
mode: '0644'
tags:
- prometheus
- name: Systemd daemon-reload
systemd:
daemon_reload: yes
tags:
- prometheus
- name: Enable and start prometheus
systemd:
name: prometheus
enabled: yes
state: started
tags:
- prometheus
大概像这样,接下来一样是 terraform apply
装到现在,我们总共有三个容器
明天,我们要把 Agent 塞进 app,让 TSDB 能吃到系统数据
对 React.js 有基本的概念後,我们就可以继续往下学习该如何建置和使用它罗! 开始环境建置 ...
在这系列文的第二篇有提到,SEO 做得越好,平均排名是下降的,很多人都很惊讶,所以我就文章稍作解释:...
Go mod 是 go 1.11 version 之後出的管理套件的工具,并且Go 1.13 ver...
v-if 条件式渲染 :true -> 渲染 可使用於template标签中 可进行断判断: ...
本日作品: https://codepen.io/linchinhsuan/pen/KKMpBZb ...