InfluxDB安装和使用

本文详细介绍了InfluxDB的安装步骤,包括通过官方YUM源进行安装,解决启动失败的问题,以及如何修改配置文件避免端口冲突。此外,还演示了InfluxDB的基本操作,如创建数据库、插入和查询数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天来点简单的

InfluxDB安装

首先老规矩,官网

[root@hadoop004 software]# 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@hadoop004 software]# yum install influxdb

安装成功!!!

InfluxDB使用

启动InfluxDB 

[root@hadoop004 bin]# systemctl start influxdb

这里会发生一个诡异的现象,程序启动不久,马上又挂掉了。 

解决方案

启动之前先修改配置文件

[root@hadoop004 bin]# vim /etc/influxdb/influxdb.conf

bind-address = "127.0.0.1:8009"

默认是绑定的8088端口,但是我的8088端口已经被占用了,不然当InfluxDB启动之后,很快就又宕掉了。

启动 influx command line interface (CLI)

[root@hadoop004 app]# influx -precision rfc3339
Connected to http://localhost:8086 version 1.7.7
InfluxDB shell version: 1.7.7

相关名词解释

创建数据库

> CREATE DATABASE hello

> SHOW DATABASES
name: databases
name
----
_internal
hello

 

 

> INSERT cpu,host=serverA,region=us_west value=0.64

> SELECT "host", "region", "value" FROM "cpu"
name: cpu
time                           host    region  value
----                           ----    ------  -----
2019-07-08T07:23:50.876862275Z serverA us_west 0.64

> INSERT temperature,machine=unit42,type=assembly external=25,internal=37

> SELECT * FROM "temperature"
name: temperature
time                          external internal machine type
----                          -------- -------- ------- ----
2019-07-08T07:27:08.33463649Z 25       37       unit42  assembly

至此,InfluxDB的安装和使用就完成了,下一步就是InfluxDB和Grafana的整合使用,敬请期待!!!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值