更多好文章見做者電子書集《Linux運維入門指南:生產運維須要掌握的技能》php
隨着大數據的爆發,系統數量也是直線上升,監控系統,收集系統運行狀態成了保障業務正常運行中的重要一個環節。web
針對這種產生頻率快、帶時間標籤、測點多、信息量大的數據,時序數據庫(Time Series Database,簡稱TSDB)應運而生。而其中InfluxDB是比較應用普遍的其中一個。數據庫
InfluxDB是用Go語言寫的,專爲時間序列數據持久化所開發的,因爲使用Go語言,因此各平臺基本都支持。相似的時間序列數據庫還有OpenTSDB,Prometheus等。
轉載本站文章請註明出處:黃海兵haibing.orgvim
InfluxDB的Cluster功能收費,單機功能無償使用。less
一、安裝
能夠直接rpm安裝
到http://repos.influxdata.com下載相應的版本運維
1
2
|
#wget https:
//repos.influxdata.com/rhel/6Server/x86_64/stable/influxdb-1.2.0.x86_64.rpm
#rpm -ivh influxdb-1.2.0.x86_64.rpm
|
或者
添加yum 源安裝ide
1
2
3
4
5
6
7
8
|
#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
|
1
2
3
4
5
6
7
8
|
# cat 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
#yum install influxdb -y
|
二、配置
InfluxDB 1.1開始WEB管理默認是禁用的,因此裝完並無啓用8083端口了,須要到配置文件裏啓用。
轉載本站文章請註明出處:黃海兵haibing.org大數據
1
2
3
|
vim /etc/influxdb/influxdb.conf
[admin]
enabled = true
|
InfluxDB 1.3以及以後的版本已經取消在InfluxDB中啓用web管理了,取而代之的是使用Chronograf。
官方說明:
In version 1.3, the web admin interface is no longer available in InfluxDB. The interface does not run on port 8083 and InfluxDB ignores the [admin] section in the configuration file if that section is present. Chronograf replaces the web admin interface with improved tooling for querying data, writing data, and database management. See Chronograf’s transition guide for more information.ui
三、啓動 InfluxDB
# service influxdb starturl
啓動後打開 web 管理界面 http://本機IP:8083/
InfluxDB 的 Web 管理界面端口是 8083,HTTP API 監聽端口是 8086,若是須要更改這些默認設定,修改 InfluxDB 的配置文件 /etc/influxdb/influxdb.conf 後重啓 InfluxDB 就能夠了
四、基本用法
1
2
3
4
5
6
7
|
#influx
>help #查看基本用法
>show databases
name: databases
name
----
_internal
|
新舊版本要注意的事項:
一、是否啓用web管理
1.1版本開始是默認沒有啓用web管理的,因此新版裝完以後,啓動服務,8083端口是沒有的。要麼經過命令直接管理,要麼經過API管理。
不過仍是能夠手動開起來的。
1
2
3
|
vim /etc/influxdb/influxdb.conf
[admin]
enabled = true
|
官網說明
The built-in web administration GUI is deprecated in InfluxDB 1.1 and is disabled by default. We recommend using the HTTP API or the Command Line Interface to interact with InfluxDB.
InfluxDB 1.3以及以後的版本已經取消在InfluxDB中啓用web管理了,取而代之的是使用Chronograf。
轉載本站文章請註明出處:黃海兵haibing.org
二、默認管理帳號
0.8及之前版本安裝完後,是有一個帳號爲root、密碼爲root的管理帳號。可做爲一個默認管理權限的帳號。
0.9版本及之後版本是沒有默認帳號的,都要本身建立。
三、HTTP API接口的不一樣
0.9開始跟之前的版本徹底不同,因此若是是從老版本升級到0.9或者更高版本,要注意了,接口文件要徹底從新寫過。
0.8之前是相似這樣的請求:
http://localhost:8086/db/mydb/
而新版的是這樣的:
http://localhost:8086/query?db=test&pretty=true
新版基本上都是用/query來執行,而舊版是沒有的。
網上不少都是舊版代碼,若是用來查詢新版的,是得不到數據的。
轉載本站文章請註明出處:黃海兵haibing.org
這是官網的一段說明,說明0.8跟0.9版本的不一樣
InfluxDB 0.8 has multiple endpoints for the API, often encoding concepts such as the database and shard space in the HTTP endpoint. InfluxDB 0.9 simplifies the common API interactions, using a common endpoint /query for all queries, and /write for all writes, regardless of database or retention policy. The database and retention policy are passed as query string parameters in InfluxDB 0.9. This makes the API easier to incorporate into libraries and other code, as it does not require any knowledge of the data structure to make valid calls to the API endpoints.
還有其它不少不一樣的地方,慢慢更新吧