溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Influxdb relay ubuntu

發(fā)布時(shí)間:2020-05-19 02:28:11 來(lái)源:網(wǎng)絡(luò) 閱讀:28065 作者:雨后的春筍 欄目:數(shù)據(jù)庫(kù)

文件版本:

V1.0

文件編號(hào):

R&D0031

發(fā)布日期:


編    制:


審    批:


 

 

Influxdb relay + grafana服務(wù)器

 

 

目錄

1.簡(jiǎn)介3

1.1 特點(diǎn)4

1.2 influxdb比較4

1.3 用途4

2.系統(tǒng)部署基礎(chǔ)4

2.1 安裝4

2.2 啟動(dòng)5

2.3 web界面展示5

2.3.1 無(wú)驗(yàn)證web登錄5

2.3.2 驗(yàn)證web登錄6

2.4 帶密碼登錄終端7

2.5 數(shù)據(jù)庫(kù)常規(guī)操作8

2.5.1 數(shù)據(jù)庫(kù)增8

2.5.2 數(shù)據(jù)庫(kù)刪除與修改8

2.5.3 數(shù)據(jù)庫(kù)查詢8

2.5.4 數(shù)據(jù)庫(kù)增與表操作9

2.5.5 數(shù)據(jù)庫(kù)保存策略(Retention Policies)10

2.5.6 數(shù)據(jù)庫(kù)連續(xù)查詢10

2.5.7 數(shù)據(jù)庫(kù)用戶管理10

3. 數(shù)據(jù)展示工具11

3.1 grafana介紹11

3.1 grafana安裝,運(yùn)行,啟動(dòng)11

3.2 grafana訪問(wèn)11

3.3創(chuàng)建Dashbord13

4. IfluxDB Relay13

4.1 簡(jiǎn)介13

4.2 拓?fù)浣榻B13

4.3 源碼包安裝測(cè)試14

4.4 influxdb-relay啟動(dòng)15

4.5 influxdb-relay數(shù)據(jù)寫入同步16

4.6 influxdb-relay節(jié)點(diǎn)故障數(shù)據(jù)寫入同步17

5. FAQ18


修訂記錄

版本號(hào)

發(fā)布日期

擬制人

修訂描述

V1.0

2017-01-17


首次發(fā)布

V1.1

2017-02-14


新增賬號(hào)和密碼













  

influxdb服務(wù)器

1.簡(jiǎn)介

    InfluxDBGo語(yǔ)言編寫的一個(gè)開(kāi)源分布式時(shí)序、事件和指標(biāo)數(shù)據(jù)庫(kù),和傳統(tǒng)是數(shù)據(jù)庫(kù)相比有不少不同的地方。類似的數(shù)據(jù)庫(kù)有ElasticsearchGraphite等。

1.1 特點(diǎn)

1.提供了Http接口的API來(lái)操作數(shù)據(jù)

2.提供了類似sql的數(shù)據(jù)庫(kù)語(yǔ)句

3.基于時(shí)間序列,支持與時(shí)間有關(guān)的相關(guān)函數(shù)(如最大,最小,求和等)

4.可度量性:你可以實(shí)時(shí)對(duì)大量數(shù)據(jù)進(jìn)行計(jì)算

5.基于事件:它支持任意的事件數(shù)據(jù)

6.無(wú)結(jié)構(gòu)(無(wú)模式):可以是任意數(shù)量的列

7.可拓展的支持min, max, sum, count, mean, median 等一系列函數(shù),方便統(tǒng)計(jì)

8.原生的HTTP支持,內(nèi)置HTTP API

9.強(qiáng)大的類SQL語(yǔ)法

10.自帶管理界面,方便使用

1.2 influxdb比較

庫(kù)、表等比較:

influxDB

傳統(tǒng)數(shù)據(jù)庫(kù)中的概念

database

數(shù)據(jù)庫(kù)

measurement

數(shù)據(jù)庫(kù)中的表

points

表里面的一行數(shù)據(jù)

influxdb數(shù)據(jù)的構(gòu)成:

Point由時(shí)間戳(time)、數(shù)據(jù)(field)、標(biāo)簽(tags)組成。

Point屬性

傳統(tǒng)數(shù)據(jù)庫(kù)中的概念

time

每個(gè)數(shù)據(jù)記錄時(shí)間,是數(shù)據(jù)庫(kù)中的主索引(會(huì)自動(dòng)生成)

fields

各種記錄值(沒(méi)有索引的屬性)也就是記錄的值:溫度, 濕度

tags

各種有索引的屬性:地區(qū),海拔

這里不得不提另一個(gè)名詞:series

    所有在數(shù)據(jù)庫(kù)中的數(shù)據(jù),都需要通過(guò)圖表來(lái)展示,而這個(gè)series表示這個(gè)表里面的數(shù)據(jù),可以在圖表上畫成幾條線:通過(guò)tags排列組合算出來(lái)。具體可以通過(guò)SHOW SERIES FROM "表名" 進(jìn)行查詢

1.3 用途

一般用來(lái)儲(chǔ)存實(shí)時(shí)數(shù)據(jù),配合一套UI界面來(lái)展示信息。

2.系統(tǒng)部署基礎(chǔ)

2.1 安裝

基本環(huán)境,準(zhǔn)備。

root@ubuntu:~# ls

grafana_4.1.1-1484211277_amd64.deb  influxdb_1.1.1_amd64.deb

root@ubuntu:~# cat /etc/issue

Ubuntu 14.04.5 LTS \n \l

 

root@ubuntu:~# uname -a

Linux ubuntu 3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:43:14 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

 

開(kāi)始安裝

root@ubuntu:~# dpkg -i influxdb_1.1.1_amd64.deb

Selecting previously unselected package influxdb.

(Reading database ... 90134 files and directories currently installed.)

Preparing to unpack influxdb_1.1.1_amd64.deb ...

Unpacking influxdb (1.1.1-1) ...

Setting up influxdb (1.1.1-1) ...

 Adding system startup for /etc/init.d/influxdb ...

   /etc/rc0.d/K20influxdb -> ../init.d/influxdb

   /etc/rc1.d/K20influxdb -> ../init.d/influxdb

   /etc/rc6.d/K20influxdb -> ../init.d/influxdb

   /etc/rc2.d/S20influxdb -> ../init.d/influxdb

   /etc/rc3.d/S20influxdb -> ../init.d/influxdb

   /etc/rc4.d/S20influxdb -> ../init.d/influxdb

   /etc/rc5.d/S20influxdb -> ../init.d/influxdb

Processing triggers for man-db (2.6.7.1-1ubuntu1) ...

2.2 啟動(dòng)

root@ubuntu:~# /etc/init.d/influxdb start

Starting the process influxdb [ OK ]

influxdb process was started [ OK ]

root@ubuntu:~# netstat -lnp|grep influ

tcp6       0      0 :::8083                 :::*                    LISTEN      5057/influxd    

tcp6       0      0 :::8086                 :::*                    LISTEN      5057/influxd    

tcp6       0      0 :::8088                 :::*                    LISTEN      5057/influxd    

8083  web管理端 http://ip:8083 用戶名和密碼都是admin, InfluxDB Web 管理界面端口是 8083

8086  HTTP API 監(jiān)聽(tīng)端口是 8086

8088  集群端口(目前還不是很清楚, 配置在全局的bind-address,默認(rèn)不配置就是開(kāi)啟的)

啟動(dòng)成功之后,我們就可以開(kāi)始使用influxdb啦!

2.3 web界面展示

2.3.1 無(wú)驗(yàn)證web登錄 

root@ubuntu:~# which influx

/usr/bin/influx

root@ubuntu:~# influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 0.13.0

InfluxDB shell version: 0.13.0

>

> show databases

name: databases

name

----

_internal

 

> CREATE DATABASE "testDB"   #創(chuàng)建數(shù)據(jù)庫(kù)

> show databases            #創(chuàng)建數(shù)據(jù)庫(kù)

name: databases

name

----

_internal

testDB

> use testDB                #使用testDB數(shù)據(jù)庫(kù)類mysql

Using database testDB

Web界面訪問(wèn)http://ip:8083,

注意:新版本默認(rèn)是關(guān)閉該web展示,詳見(jiàn)后面FAQ具體解決方法:

 

 Influxdb relay  ubuntu

 Influxdb relay  ubuntu

 

通過(guò)界面操作命令。

 Influxdb relay  ubuntu 

2.3.2 驗(yàn)證web登錄 

1. 先添加用戶

    設(shè)置TSauthorized,提高安全性,針對(duì)指定用戶擁有權(quán)限才能訪問(wèn)數(shù)據(jù)庫(kù)的數(shù)據(jù),TS默認(rèn)用戶分為普通用戶和管理員用戶,權(quán)限分為read,write,all privileges三種權(quán)限

root@ubuntu:/home/leco# influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 1.1.1

InfluxDB shell version: 1.1.1

> CREATE USER "influxdb" WITH PASSWORD 'influxdb' WITH ALL PRIVILEGES

先添加賬號(hào)和密碼,均為influxdb

 

Web界面數(shù)據(jù)庫(kù)的切換。此時(shí)登錄web的時(shí)候需要輸入賬號(hào)和密碼,驗(yàn)證通過(guò)后才可以正常進(jìn)入。配置如下:

 Influxdb relay  ubuntu 

2. 重啟influxdb

root@ubuntu:~# /etc/init.d/influxdb restart

Stopping influxdb...

influxdb process was stopped [ OK ]

Starting influxdb...

influxdb process was started [ OK ]

 Influxdb relay  ubuntu 

通過(guò)界面上輸入正確的IP,端口,用戶名和密碼點(diǎn)擊save進(jìn)入。

2.4 帶密碼登錄終端

若是設(shè)置了密碼驗(yàn)證的話必須就要輸入賬號(hào)和密碼才能正常登錄操作,否則報(bào)錯(cuò)如下

1. 錯(cuò)誤登錄

root@ubuntu:/home/leco# influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 1.1.1

InfluxDB shell version: 1.1.1

> show databases;

ERR: unable to parse authentication credentials   #說(shuō)明已經(jīng)添加了驗(yàn)證方式

Warning: It is possible this error is due to not setting a database.

Please set a database with the command "use <database>".

> quit

 

2. 正確登錄

root@ubuntu:/home/leco# influx  -host 'localhost' -port '8086' -username 'influxdb' -password 'influxdb'

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 1.1.1

InfluxDB shell version: 1.1.1

> show databases;

name: databases

name

----

_internal

cmz

#此時(shí)localhost是連接本機(jī),若是遠(yuǎn)程連接就換成對(duì)應(yīng)的IPPortinfluxdb默認(rèn)端口8086,username password就是授權(quán)的賬號(hào)和密碼。

2.5 數(shù)據(jù)庫(kù)常規(guī)操作

2.5.1 數(shù)據(jù)庫(kù)增

> use testDB

Using database testDB

> insert weather,altitude=1000,area=temperature=11,humidity=-4

或者通過(guò)HTTP接口增加

curl -i -XPOST 'http://localhost:8086/write?db=testDB' --data-binary 'weather,altitude=1000,area=temperature=11,humidity=-4'

Line Protocol格式

插入數(shù)據(jù)的格式似乎比較奇怪,這是因?yàn)?/span>influxDB儲(chǔ)存數(shù)據(jù)所采用的是Line Protocol格式。

在上面兩個(gè)插入數(shù)據(jù)的方法中,都有一樣的部分。

weather,altitude=1000,area=temperature=11,humidity=-4

其中:

  1. weather : 表名

  2. altitude=1000,area=北 : tag

  3. temperature=11,humidity=-4 field

參考官方文檔:

https://docs.influxdata.com/influxdb/v0.10/write_protocols/line/

2.5.2 數(shù)據(jù)庫(kù)刪除與修改

2.5.3 數(shù)據(jù)庫(kù)查詢

> use testDB

Using database testDB

> SELECT * FROM weather ORDER BY time

name: weather

timealtitudeareahumiditytemperature

-----------------------------------

14850746132673340411000-411

 

通過(guò)Http接口

curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=testDB" --data-urlencode "q=SELECT * FROM weather ORDER BY time DESC LIMIT 3"

InfluxDB是支持類SQL語(yǔ)句的,具體的查詢語(yǔ)法都差不多,就不再詳細(xì)描述了。詳見(jiàn)官方文檔

 

2.5.4 數(shù)據(jù)庫(kù)增與表操作

#創(chuàng)建數(shù)據(jù)庫(kù),庫(kù)名為db_name

> CREATE DATABASE "db_name"

 

#顯示所有數(shù)據(jù)庫(kù)

> SHOW DATABASES

name: databases

name

----

_internal

testDB

db_name

 

#刪除庫(kù)名字為db_name的庫(kù)

> DROP DATABASE "db_name"

 

#切換到testDB數(shù)據(jù)庫(kù)

> USE testDB

Using database testDB

 

#顯示該數(shù)據(jù)庫(kù)中的表

> SHOW MEASUREMENTS

name: measurements

name

----

weather

 

#創(chuàng)建表

#直接在插入數(shù)據(jù)的時(shí)候指定表名字(weather就是表名)

> insert weather,altitude=1000,area=temperature=11,humidity=-4

 

#刪除weather

> DROP MEASUREMENT "weather"

 

2.5.5 數(shù)據(jù)庫(kù)保存策略(Retention Policies)

    InfluxDB沒(méi)有提供直接刪除Points的方法,但是它提供了Retention Policies。主要用于指定數(shù)據(jù)的保留時(shí)間:當(dāng)數(shù)據(jù)超過(guò)了指定的時(shí)間之后,就會(huì)被刪除。

#1.查看當(dāng)前數(shù)據(jù)庫(kù)的Retention Policies

> SHOW RETENTION POLICIES ON "testDB"

namedurationshardGroupDurationreplicaNdefault

---------------------------------------------

autogen0s168h0m0s1true

 

#2.創(chuàng)建新的Retention Policies

> CREATE RETENTION POLICY "rp_name" ON "testDB" DURATION 30d REPLICATION 1 DEFAULT

說(shuō)明:

1. rp_name:策略名

2. testDB:具體的數(shù)據(jù)庫(kù)名

3. 30d:保存30天,30天之前的數(shù)據(jù)將被刪除

  它具有各種時(shí)間參數(shù),比如:h(小時(shí)),w(星期)

4. REPLICATION 1:副本個(gè)數(shù),這里填1就可以了

5. DEFAULT 設(shè)為默認(rèn)的策略

#2.修改Retention Policies

> ALTER RETENTION POLICY "rp_name" ON "testDB" DURATION 3w DEFAULT

 

#3.刪除Retention Policies

> DROP RETENTION POLICY "rp_name" ON "testDB"

 

2.5.6 數(shù)據(jù)庫(kù)連續(xù)查詢

當(dāng)數(shù)據(jù)超過(guò)保存策略里指定的時(shí)間之后,就會(huì)被刪除。如果我們不想完全刪除掉,比如做一個(gè)數(shù)據(jù)統(tǒng)計(jì)采樣:把原先每秒的數(shù)據(jù),存為每小時(shí)的數(shù)據(jù),讓數(shù)據(jù)占用的空間大大減少(以降低精度為代價(jià))。這就需要InfluxDB提供的:連續(xù)查詢(Continuous Queries)。

#1.當(dāng)前數(shù)據(jù)庫(kù)的continus Queries

> SHOW CONTINUOUS QUERIES

name: _internal

namequery

---------

name: testDB

namequery

---------

#2.創(chuàng)建新的continus Queries

 

2.5.7 數(shù)據(jù)庫(kù)用戶管理

#顯示用戶

> SHOW USERS

useradmin

---------

 

#創(chuàng)建用戶

> CREATE USER "realcloud" WITH PASSWORD '123456'

 

#創(chuàng)建管理員權(quán)限的用戶

> CREATE USER "cmz" WITH PASSWORD 'cmz' WITH ALL PRIVILEGES

 

#刪除用戶

> DROP USER "cmz"

 

 

 

3.數(shù)據(jù)展示工具

3.1 grafana介紹

    數(shù)據(jù)最終是需要一套UI來(lái)展示的,而這種實(shí)時(shí)數(shù)據(jù)的展示,已經(jīng)有不少項(xiàng)目了。 比如:

1. 官方的Chronograf

2. Grafana

3. 其它...

3.1 grafana安裝,運(yùn)行,啟動(dòng)

此時(shí)我選擇的使用Grafana

root@ubuntu:~# ls

grafana_4.1.1-1484211277_amd64.deb  influxdb_1.1.1_amd64.deb

#安裝

root@ubuntu:~# dpkg -i grafana_4.1.1-1484211277_amd64.deb

Selecting previously unselected package grafana.

(Reading database ... 61968 files and directories currently installed.)

Preparing to unpack grafana_4.1.1-1484211277_amd64.deb ...

Unpacking grafana (4.1.1-1484211277) ...

Setting up grafana (4.1.1-1484211277) ...

Adding system user `grafana' (UID 106) ...

Adding new user `grafana' (UID 106) with group `grafana' ...

Not creating home directory `/usr/share/grafana'.

### NOT starting grafana-server by default on bootup, please execute

 sudo update-rc.d grafana-server defaults 95 10

### In order to start grafana-server, execute

 sudo service grafana-server start

Processing triggers for ureadahead (0.100.0-16) ...

ureadahead will be reprofiled on next reboot

#啟動(dòng)

root@ubuntu:~# /etc/init.d/grafana-server start

 * Starting Grafana Server                                                                                                                               [ OK ]

安裝步驟參考:http://grafana.org/download/

3.2 grafana訪問(wèn)

1) Web登錄,直接訪問(wèn):http://your_ip:3000

默認(rèn)帳號(hào):admin
默認(rèn)密碼:admin

 

2) Data Sources中添加數(shù)據(jù)庫(kù)testDB

 

 

 Influxdb relay  ubuntu

 Influxdb relay  ubuntu

 Influxdb relay  ubuntu

 Influxdb relay  ubuntu

 Influxdb relay  ubuntu

 Influxdb relay  ubuntu

 

其中userpassword,如果沒(méi)有設(shè)置過(guò),可以隨便填下。
保存之后,可以通過(guò)Test Connection來(lái)測(cè)試,是否填寫正確。

3.3創(chuàng)建Dashbord

點(diǎn)擊New按鈕就可以了。

 Influxdb relay  ubuntu 

 

4.IfluxDB Relay

4.1 簡(jiǎn)介

該項(xiàng)目為influxdb添加了一個(gè)基本的高可用性層。通過(guò)正確的體系結(jié)構(gòu)和災(zāi)難恢復(fù)過(guò)程,實(shí)現(xiàn)了高度可用的設(shè)置。

提示: influxdb-relay must be built with Go 1.5+

參考鏈接:

https://github.com/influxdata/influxdb-relay/blob/master/README.md

4.2 拓?fù)浣榻B

    體系結(jié)構(gòu)相當(dāng)簡(jiǎn)單,包括負(fù)載平衡器、兩個(gè)或多個(gè)influxdb中繼進(jìn)程和兩個(gè)或多個(gè)influxdb進(jìn)程。負(fù)載平衡器應(yīng)使用路徑/寫入將UDP通信和http post請(qǐng)求指向兩個(gè)繼電器,同時(shí)將路徑/查詢指向兩個(gè)influxdb服務(wù)器。安裝程序應(yīng)該如下:

 Influxdb relay  ubuntu 

給我的感覺(jué),這個(gè) influxdb-relay是一個(gè)數(shù)據(jù)庫(kù)中間件的角色,起到了一個(gè)代理的作用

 

4.3 源碼包安裝測(cè)試

1.實(shí)驗(yàn)環(huán)境

IP

系統(tǒng)環(huán)境

安裝軟件

192.168.5.200

Ubuntu14.04 x64

influxdb

influxdb-relay

192.168.5.202

Ubuntu14.04 x64

influxdb


    此時(shí)上文只在200機(jī)器上安裝了influxdb,此時(shí)要在202上也要安裝influxdb。也可以只安裝在一個(gè)機(jī)器上,我分開(kāi)安裝了,更貼切實(shí)際生產(chǎn)情況。

2. 安裝golang環(huán)境

    influxdb releasedeb包本身是已經(jīng)編譯好的,并不需要golang的環(huán)境。而influxdb-relay目前還只是存放在github上,因此需要先安裝golang環(huán)境。 手動(dòng)下載更高版本的golang是需要的。

3. 下載并解壓1.6.2版本的golang壓縮包

root@ubuntu:~# apt-get install git

root@ubuntu:~# wget http://www.golangtc.com/static/go/1.6.2/go1.6.2.linux-amd64.tar.gz

root@ubuntu:~# ls go1.6.2.linux-amd64.tar.gz

go1.6.2.linux-amd64.tar.gz

root@ubuntu:~# tar -zxf go1.6.2.linux-amd64.tar.gz -C /usr/local/

 

4. 配置環(huán)境變量

root@ubuntu:~# tail -9  /etc/profile

#add by caimengzhi at 2017-01-23 for go. start

export GOROOT=/usr/local/go  

export GOBIN=$GOROOT/bin

export GOPKG=$GOROOT/pkg/tool/linux_amd64  

export GOARCH=amd64

export GOOS=linux

export GOPATH=$HOME

export PATH=$PATH:$GOBIN:$GOPKG:$GOPATH/bin

#add by caimengzhi at 2017-01-23 for go. End

root@ubuntu:~# source /etc/profile

root@ubuntu:~# go version

go version go1.6.2 linux/amd64

root@ubuntu:~# GOPATH=/root/go

root@ubuntu:~# go get github.com/influxdata/influxdb-relay

root@ubuntu:~# ls

go  go1.6.2.linux-amd64.tar.gz  grafana_4.1.1-1484211277_amd64.deb  influxdb_1.1.1_amd64.deb  src

#此時(shí)會(huì)在/root發(fā)現(xiàn)go文件

 

root@ubuntu:~# cp $GOPATH/src/github.com/influxdata/influxdb-relay/sample.toml ./relay.toml

root@ubuntu:~# vim relay.toml

-bash: /root/go/bin/influxdb-relay: No such file or directory

root@ubuntu:~# which influxdb-relay

/usr/local/go/bin/influxdb-relay

 

5. 配置文件解釋

root@ubuntu:~# cat relay.toml

 

 

`http`

name = "example-http"

bind-addr = "192.168.5.200:9096"

output = [

    { name="local1", location = "http://192.168.5.200:8086/write" },

    { name="local2", location = "http://192.168.5.202:8086/write" },

]

 

`udp`

name = "example-udp"

bind-addr = "192.168.5.200:9096"

read-buffer = 0 # default

output = [

    { name="local1", location="192.168.5.200:8089", mtu=512 },

    { name="local2", location="192.168.5.202:8089", mtu=1024 },

]

 

4.4 influxdb-relay啟動(dòng)

root@ubuntu:~# /usr/local/go/bin/influxdb-relay  -config relay.toml >/tmp/influxdb_relay.log 2>/dev/null &

[1] 10943

 

再指定之前influxdb-relay配置的端口9096,成功進(jìn)入其他的influxdb

root@ubuntu:~# influx -port 9096

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:9096 version relay

InfluxDB shell version: 1.1.1

 

4.5 influxdb-relay數(shù)據(jù)寫入同步

驗(yàn)證可以通過(guò)influxdb-relay寫數(shù)據(jù)

root@ubuntu:~#

curl -i -XPOST 'http://localhost:9096/write?db=testDB' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'

 

2017/01/23 17:53:43 Problem posting to relay "example-http" backend "local2": Post http://127.0.0.1:7086/write?db=testDB: dial tcp 127.0.0.1:7086: getsockopt: connection refused

HTTP/1.1 204 No Content

Date: Mon, 23 Jan 2017 09:53:43 GMT

 

1. 進(jìn)入節(jié)點(diǎn)1,influxdb驗(yàn)證數(shù)據(jù)寫入

root@ubuntu:~# influx

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:8086 version 1.1.1

InfluxDB shell version: 1.1.1

> use testDB

Using database testDB

> select * from cpu_load_short

name: cpu_load_short

timehostregionvalue

-------------------

1434055562000000000server01us-west0.64

 

2. 進(jìn)入節(jié)點(diǎn)2,influxdb驗(yàn)證數(shù)據(jù)寫入

> use testDB;

Using database testDB

> select * from cpu_load_short

name: cpu_load_short

timehostregionvalue

-------------------

1434055562000000000server01us-west0.64

從上可以看出通過(guò)調(diào)用relay的端口9096.寫入數(shù)據(jù),兩個(gè)節(jié)點(diǎn)都會(huì)有相對(duì)數(shù)據(jù)寫入。

注意點(diǎn):

### 缺陷,不知道是不是坑,反正在官網(wǎng)的github上沒(méi)看到這個(gè)注意點(diǎn)
# 手動(dòng)在所有節(jié)點(diǎn)上創(chuàng)建數(shù)據(jù)庫(kù)
write操作并不包含創(chuàng)建數(shù)據(jù)庫(kù),所以需要手動(dòng)在所有節(jié)點(diǎn)上提前創(chuàng)建數(shù)據(jù)庫(kù)

 

4.6 influxdb-relay節(jié)點(diǎn)故障數(shù)據(jù)寫入同步

# 故障節(jié)點(diǎn)操作

1.停止節(jié)點(diǎn)1influxdb

root@loocha15:~# /etc/init.d/influxdb stop

Stopping influxdb...

influxdb process was stopped [ OK ]

 

2.此時(shí)繼續(xù)寫入數(shù)據(jù)

curl -i -XPOST 'http://localhost:9096/write?db=cmz' --data-binary 'cpu_load_short,host=beijing,region=east value=2 2222222222'

2017/02/06 15:19:26 Problem posting to relay "example-http" backend "local1": Post http://192.168.3.35:8086/write?db=cmz: dial tcp 192.168.3.35:8086: getsockopt: connection refused

HTTP/1.1 204 No Content

Date: Mon, 06 Feb 2017 07:19:26 GMT

 

3.節(jié)點(diǎn)2 驗(yàn)證數(shù)據(jù)

> use cmz;

Using database cmz

> select * from cpu_load_short

name: cpu_load_short

timehostregionvalue

-------------------

1111111111nanjingeast123

2222222222beijingeast2  #這一條就是節(jié)點(diǎn)1故障后,寫入的數(shù)據(jù)

1434055562000000000server01us-west0.64

到此截止influxdbHA已經(jīng)測(cè)試完畢。


5. FAQ

1. WEB顯示404

root@ubuntu:~# curl localhost:8086 -I

HTTP/1.1 404 Not Found

Content-Type: text/plain; charset=utf-8

X-Content-Type-Options: nosniff

X-Influxdb-Version: 1.1.1

Date: Sun, 22 Jan 2017 09:36:48 GMT

Content-Length: 19

Influxdb新版本web界面不展示解決方法

1.新安裝influxdb web界面不展示

 Influxdb relay  ubuntu

訪問(wèn)的時(shí)候404.

 

解決方法:

一、問(wèn)題原因

InfluxDB0.13版本以后,就默認(rèn)關(guān)閉了web管理頁(yè)面,而國(guó)內(nèi)的文檔大多都以舊版的InfluxDB為標(biāo)準(zhǔn)寫的,所以下載安裝好最新版本以后,就會(huì)出現(xiàn)8083端口的web管理頁(yè)面訪問(wèn)不了的問(wèn)題。

二、解決方案

新版的InfluxDB雖然默認(rèn)關(guān)閉了web管理頁(yè)面,但我們可以通過(guò)很簡(jiǎn)單的方式進(jìn)行開(kāi)啟。

打開(kāi)配置文件vim /etc/influxdb/influxdb.conf 找到如下幾行:

 Influxdb relay  ubuntu

修改后如下:

 Influxdb relay  ubuntu 

重啟服務(wù)

root@ubuntu:~# /etc/init.d/influxdb restart

influxdb process already stopped [ OK ]

Starting influxdb...

influxdb process was started [ OK ]

查看端口號(hào)8083(之前是沒(méi)有的)

root@ubuntu:~# netstat -lnp|grep influ

tcp6       0      0 :::8083                 :::*                    LISTEN      5057/influxd    

tcp6       0      0 :::8086                 :::*                    LISTEN      5057/influxd    

tcp6       0      0 :::8088                 :::*                    LISTEN      5057/influxd    

Web界面訪問(wèn)展示:

http://ip:8083

 Influxdb relay  ubuntu 

OK.

 

2. command

root@ubuntu:~# go get -u github.com/influxdata/influxdb-relay

go: missing Git command. See https://golang.org/s/gogetcmd

package github.com/influxdata/influxdb-relay: exec: "git": executable file not found in $PATH

解決:

root@ubuntu:~# apt-get install git

 

3.relay命令行管理不了

root@ubuntu:~# !net

netstat -lnp|grep 9096

tcp        0      0 127.0.0.1:9096          0.0.0.0:*               LISTEN      3502/influxdb-relay

udp        0      0 127.0.0.1:9096          0.0.0.0:*                           3502/influxdb-relay

root@ubuntu:~# influx -port 9096

Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.

Connected to http://localhost:9096 version relay

InfluxDB shell version: 1.1.1

> show database;

ERR: invalid write endpoint

Warning: It is possible this error is due to not setting a database.

Please set a database with the command "use <database>".

 

6. 參考文章

http://dbspace.blog.51cto.com/6873717/1881705

http://grafana.org/features/

https://www.influxdata.com/

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI