postgresql数据库监控实验01-influxDB安装

postgresql数据库监控实验01-influxDB安装

前言

最近在研究数据库的监控软件,之前一直使用的是Prometheus+grafana。这套监控需要在数据库端安装专用的exporter,并需要自己编写一些自定义查询语句来获得数据库信息。在git上看到了这么一套influxDB+telegraf+grafana的组合,这几天研究下,做个记录。

测试环境

操作系统:CentOS Linux release 7.7.1908 (Core)
InfluxDB版本:influxdb-1.7.9.x86_64

下载安装

官方文档地址:Get started with InfluxDB

安装要求:

1.权限要求:

软件包安装需要管理员权限

2.网络端口:

默认情况下,InfluxDB使用以下网络端口:

TCP端口8086,可用于使用InfluxDB API进行客户端-服务器通信。
TCP端口8088,可用于RPC服务执行备份和还原操作。
除了上述端口外,InfluxDB还提供了多个插件,这些插件可能需要自定义端口。可以通过配置文件修改所有端口映射,该文件位于/etc/influxdb/influxdb.conf默认安装位置。

3.网络时间协议(NTP):

InfluxDB使用UTC中主机的本地时间为数据分配时间戳并用于协调目的。使用网络时间协议(NTP)在主机之间同步时间;如果主机的时钟未与NTP同步,则写入InfluxDB的数据的时间戳可能不准确。

安装

安装influxdb一般有2种方式,如需安装最新稳定版本,可直接创建influxdb的repo,使用yum安装:

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)
[root@localhost ~]# cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
> [influxdb]
> name = InfluxDB Repository - RHEL \$releasever
> baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
> enabled = 1
> gpgcheck = 1
> gpgkey = https://repos.influxdata.com/influxdb.key
> EOF
[influxdb]
name = InfluxDB Repository - RHEL $releasever
baseurl = https://repos.influxdata.com/rhel/$releasever/$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key

[root@localhost ~]# yum install influxdb

如果想安装指定版本,可自行寻找合适的版本,使用wget下载rpm包,再在本地安装:

可在https://repos.influxdata.com/centos/7/x86_64/stable下去寻找所需版本

[root@localhost opt]# wget https://repos.influxdata.com/centos/7/x86_64/stable/influxdb-1.7.9.x86_64.rpm
[root@localhost opt]# yum install ./influxdb-1.7.9.x86_64.rpm

验证

安装完成后会生成下面这些文件夹:

[root@localhost opt]# ls /usr/bin/influx* -lh
-rwxr-xr-x 1 root root 54M Oct 28 06:44 /usr/bin/influx   # influxdb命令行客户端
-rwxr-xr-x 1 root root 66M Oct 28 06:44 /usr/bin/influxd   # influxdb服务器
-rwxr-xr-x 1 root root 19M Oct 28 06:44 /usr/bin/influx_inspect   # 查看工具
-rwxr-xr-x 1 root root 12M Oct 28 06:44 /usr/bin/influx_stress   # 压力测试工具
-rwxr-xr-x 1 root root 21M Oct 28 06:44 /usr/bin/influx_tsm   # 数据库转换工具(将数据库从b1或bz1格式转换为tsm1格式)

启动influxdb:

[root@localhost opt]# systemctl status influxd
● influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.influxdata.com/influxdb/
[root@localhost opt]# systemctl start influxd
[root@localhost opt]# systemctl status influxd
● influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-11-22 02:10:34 CST; 2s ago
     Docs: https://docs.influxdata.com/influxdb/
 Main PID: 24076 (influxd)
   CGroup: /system.slice/influxdb.service
           └─24076 /usr/bin/influxd -config /etc/influxdb/influxdb.conf

Nov 22 02:10:34 localhost.localdomain systemd[1]: Started InfluxDB is an open-source, distributed, time series database.

这将会生成influxdb的数据目录:

[root@localhost ~]# ls /var/lib/influxdb/ -lh
total 0
drwxr-xr-x 3 influxdb influxdb 23 Nov 22 01:45 data   # 存放最终存储的数据,文件以.tsm结尾
drwxr-xr-x 2 influxdb influxdb 21 Nov 22 01:45 meta   # 存放数据库元数据
drwx------ 3 influxdb influxdb 23 Nov 22 01:45 wal   # 存放预写日志文件

进入客户端:

[root@localhost ~]# influx
Connected to http://localhost:8086 version 1.7.9
InfluxDB shell version: 1.7.9
> 

确认安装完成!

发布了136 篇原创文章 · 获赞 58 · 访问量 36万+

猜你喜欢

转载自blog.csdn.net/sunbocong/article/details/103255376