深入理解InfluxDB——時序資料庫詳解與實踐

深入理解InfluxDB——時序資料庫詳解與實踐

《深入理解InfluxDB——時序資料庫詳解與實踐》是2023年4月1日清華大學出版社出版的圖書,作者:鄭強、張偉、劉爽。

基本介紹

  • 中文名:深入理解InfluxDB——時序資料庫詳解與實踐
  • 作者:鄭強、張偉、劉爽
  • 出版時間:2023年4月1日
  • 出版社:清華大學出版社
  • ISBN:9787302630012
  • 定價:65 元
  • 印次:1-1
  • 印刷日期:2023.04.03
內容簡介,圖書目錄,

內容簡介

時序資料庫是一種新型技術,主要用於工業網際網路軟體建設中。近年來,伴隨著物聯網技術在智慧型製造、交通、能源、智慧城市等領域的發展,時序資料庫也發展迅速,成為搭建套用的必備資料庫之一。《深入理解 InfluxDB》從 InfluxDB 的安裝開始,一步步詳細介紹 InfluxDB 的功能及原理,帶領讀者深入理解以 InfluxDB 為代表的時序資料庫。

圖書目錄

目錄
第1章 時序資料庫InfluxDB簡介
1.1 數據簡史 ······························································································2
1.1.1 什麼是時序數據 ··················································································3
1.1.2 時序資料庫的歷史 ···············································································3
1.2 InfluxDB簡介 ························································································4
1.2.1 什麼是InfluxDB ··················································································4
1.2.2 InfluxDB的歷史 ··················································································5
1.2.3 InfluxDB現狀及未來 ············································································6
1.3 InfluxDB的基本概念 ···············································································7
1.4 InfluxDB的設計理念 ···············································································7
1.5 InfluxDB的核心特性 ···············································································8
1.5.1 內置REST接口 ··················································································8
1.5.2 數據Tag標記 ·····················································································8
1.5.3 類SQL的查詢語句 ··············································································9
1.5.4 高性能 ······························································································9
1.5.5 開源 ·······························································································10
1.6 時序資料庫的套用場景 ··········································································10
1.6.1 在工業環境監控中的套用 ····································································10
1.6.2 在物聯網IoT設備採集存儲中的套用 ·····················································11
1.6.3 網際網路業務性能監控服務 ····································································11
1.6.4 在智慧型汽車中的套用 ··········································································12
1.7 小結 ··································································································12
第2章 InfluxDB的安裝、配置、啟動
2.1 在不同作業系統上安裝InfluxDB································································14
2.1.1 硬體要求 ·························································································14
2.1.2 在Ubuntu和Debian系統中安裝InfluxDB ···············································15
2.1.3 在RedHat和CentOS系統中安裝InfluxDB ··············································20
2.1.4 在Windows系統中安裝InfluxDB··························································21
2.1.5 在macOS系統中安裝InfluxDB ·····························································22
2.1.6 使用Docker安裝InfluxDB ···································································24
2.1.7 InfluxDB的連線埠設定 ··········································································25
2.1.8 InfluxDB 程式的使用 ··········································································25
2.1.9 InfluxDB的配置詳解 ··········································································31
2.2 小結 ··································································································37
第3章InfluxDB UI數據可視化
3.1 InfluxDB UI ·························································································39
3.1.1 安裝配置 ·························································································39
3.1.2 常用功能介紹 ···················································································41
3.2 Chronograf ·························································································47
3.2.1 安裝配置 ·························································································48
3.2.2 常用功能介紹 ···················································································50
3.3 小結 ··································································································57
第4章InfluxDB基本操作寫入與查詢
4.1 客戶端命令行方式 ················································································59
4.1.1 簡介·······························································································59
4.1.2 使用InfluxDB ···················································································59
4.1.3 Influx基本命令·················································································61
4.2 數據樣本 ····························································································62
4.2.1 空氣感測器樣本數據 ··········································································63
4.2.2 鳥類遷徙樣本數據 ·············································································64
4.2.3 NOAA樣本數據 ················································································64
4.2.4 美國地質勘探局地震數據 ····································································64
4.3 行協定 ·······························································································65
4.3.1 行協定案例 ······················································································65
4.3.2 行協定語法 ······················································································66
4.3.3 行協定要素分析 ················································································66
4.3.4 數據類型 ·························································································67
4.3.5 引號·······························································································68
4.3.6 特殊字元 ·························································································68
4.3.7 注釋·······························································································69
4.3.8 重複數據 ·························································································69
4.4 桶操作 ·······························································································70
目 錄
VII
4.5 寫入操作 ····························································································71
4.5.1 寫入數據 ·························································································71
4.5.2 檔案數據導入 ···················································································72
4.6 查詢操作 ····························································································73
4.6.1 select語句 ·······················································································74
4.6.2 類型轉換 ·························································································77
4.6.3 where子句 ·······················································································78
4.6.4 函式 ·······························································································80
4.6.5 group by子句 ···················································································82
4.6.6 into子句 ··························································································85
4.6.7 排序 ·······························································································86
4.6.8 limit和slimit子句 ·············································································86
4.6.9 offset和soffset子句 ···········································································86
4.6.10 Time Zone子句 ················································································87
4.6.11 時間語法 ························································································87
4.7 小結 ··································································································88
第5章 InfluxDB的函式與運算
5.1 樣本數據導入 ······················································································90
5.2 InfluxDB函式 ······················································································91
5.2.1 函式說明 ·························································································91
5.2.2 聚合類函式 ······················································································92
5.2.3 選擇類函式 ······················································································94
5.2.4 轉換類函式 ······················································································95
5.2.5 預測類函式 ······················································································98
5.3 數學運算 ····························································································99
5.3.1 常用運算符 ······················································································99
5.3.2 數學運算符的常見問題 ······································································101
5.4 小結 ································································································102
第6章 InfluxDB連續查詢
6.1 連續查詢 ··························································································104
6.2 樣本數據導入 ····················································································104
6.3 創建連續查詢 ····················································································106
6.3.1 <cq_query>語句 ···············································································106
6.3.2 連續查詢運行時刻及查詢的時間範圍 ····················································107
6.3.3 連續查詢舉例 ··················································································107
6.4 複雜連續查詢 ····················································································109
6.4.1 創建高級連續查詢 ············································································109
6.4.2 高級連續查詢的時間設定 ···································································109
6.4.3 GROUP BY time()、EVERY、FOR三者關係 ···········································111
6.4.4 高級連續查詢舉例 ············································································112
6.5 連續查詢的管理 ··················································································113
6.5.1 查詢所有連續查詢 ············································································113
6.5.2 刪除連續查詢 ··················································································114
6.5.3 修改連續查詢 ··················································································114
6.6 連續查詢案例分析 ···············································································114
6.6.1 數據預處理 ·····················································································115
6.6.2 降低數據採樣率 ···············································································115
6.6.3 HAVING功能 ··················································································116
6.6.4 替換嵌套函式 ··················································································116
6.7 小結 ·································································································117
第7章InfluxDB數據保留策略
7.1 保留策略 ···························································································119
7.2 創建保留策略 ·····················································································119
7.2.1 使用CREATE RETENTION POLICY創建保留策略 ························119
7.2.2 創建保留策略舉例 ············································································121
7.3 查詢保留策略 ····················································································121
7.4 修改保留策略 ····················································································122
7.5 刪除保留策略 ····················································································123
7.6 綜合實例 ··························································································123
7.6.1 樣本數據 ························································································123
7.6.2 實驗目標 ························································································124
7.6.3 實驗過程 ························································································124
7.6.4 結論······························································································126
7.7 小結 ································································································126
第8章InfluxDB數據安全策略
8.1 認證技術 ··························································································128
8.1.1 簡介······························································································128
8.1.2 認證方式 ························································································128
8.1.3 Token認證 ······················································································128
8.1.4 1.x版本兼容授權認證 ·······································································131
目 錄
8.1.5 授權使用 ························································································137
8.2 許可權類型 ··························································································142
8.3 用戶管理 ··························································································143
8.4 許可權控制實戰 ····················································································146
8.4.1 創建與授權 ·····················································································146
8.4.2 測試效果 ························································································147
8.5 小結 ································································································149
第9章 InfluxDB性能評估
9.1 性能測試工具 ····················································································151
9.1.1 安裝Go語言運行環境 ·······································································151
9.1.2 測試工具安裝 ··················································································153
9.2 基準性能測試 ····················································································154
9.2.1 測試環境 ························································································154
9.2.2 寫入性能測試 ··················································································154
9.3 性能最佳化 ··························································································157
9.3.1 數據寫入最佳化方案 ············································································157
9.3.2 數據查詢最佳化方案 ············································································157
9.4 性能報警 ··························································································159
9.4.1 創建檢查 ························································································159
9.4.2 添加通知端點 ··················································································162
9.4.3 創建通知規則 ··················································································163
9.5 小結 ································································································164
第10章 InfluxDB集群
10.1 集群簡介 ·························································································166
10.1.1 集群架構概述 ················································································166
10.1.2 數據所在的地方 ·············································································166
10.1.3 節點數量 ······················································································167
10.2 集群安裝配置 ···················································································167
10.2.1 申請試用 ······················································································167
10.2.2 環境準備 ······················································································169
10.2.3 添加DNS條目 ···············································································170
10.2.4 Meta節點的安裝配置 ·······································································171
10.2.5 Data節點的安裝配置 ·······································································173
10.3 小結 ·······························································································176
第11章 備份管理
11.1 單機版備份管理 ················································································178
11.1.1 備份數據 ·······················································································178
11.1.2 恢複數據 ·······················································································179
11.2 集群版備份管理 ················································································180
11.2.1 備份數據 ·······················································································181
11.2.2 恢複數據 ·······················································································182
11.2.3 導出數據 ·······················································································184
11.2.4 導入數據 ·······················································································185
11.3 小結 ·······························································································185
第12章 InfluxDB與程式設計
12.1 Java SDK使用 ·················································································187
12.1.1 使用Java在InfluxDB中寫入數據 ·······················································188
12.1.2 WriteApiBlocking ············································································192
12.1.3 使用Java查詢InfluxDB中的數據 ·······················································193
12.1.4 queryApi ·······················································································195
12.1.5 使用Java為bucket添加許可權 ·····························································196
12.1.6 連線InfluxDB的另一種方式—用戶名和密碼 ······································198
12.2 Python SDK使用 ··············································································200
12.2.1 使用Python在InfluxDB中寫入數據 ····················································201
12.2.2 使用Python查詢InfluxDB中的數據 ····················································202
12.3 小結 ·······························································································203
第13章 InfluxDB數據處理語言Flux
13.1 Flux概述 ························································································205
13.2 基本數據類型 ···················································································205
13.2.1 Boolean(布爾值) ·········································································206
13.2.2 Bytes(位元組) ················································································206
13.2.3 Duration(持續時間) ······································································206
13.2.4 String(字元串類型) ······································································207
13.2.5 Time(時間類型) ··········································································207
13.2.6 Float(浮點類型) ··········································································208
13.2.7 Integer(整數類型) ········································································208
13.2.8 Null(空值) ·················································································209
13.3 查詢數據源 ······················································································209
13.3.1 from()函式 ····················································································210
13.3.2 range()函式 ···················································································210
13.3.3 查詢InfluxDB 1.x ············································································211
13.3.4 遠程查詢InfluxDB Cloud 或InfluxDB 2.x ··············································211
13.4 寫入數據源 ······················································································212
13.5 小結 ·······························································································213
第14章 InfluxDB存儲引擎
14.1 InfluxDB存儲引擎歷史 ·······································································215
14.2 LSM-Tree(LSM樹)概述··································································215
14.2.1 LSM-Tree存儲原理 ·········································································216
14.2.2 優勢和問題 ···················································································220
14.3 InfluxDB數據格式 ·············································································220
14.4 TSM存儲組件 ··················································································221
14.5 TSM file詳解 ··················································································222
14.5.1 SeriesKey(時間序列關鍵字) ···························································223
14.5.2 Series Data Block ·············································································224
14.5.3 Series Index Block ············································································225
14.6 TSM數據寫入 ··················································································227
14.6.1 寫入總體框架 ················································································227
14.6.2 Shard路由 ·····················································································228
14.6.3 倒排索引引擎構建倒排索引 ······························································228
14.6.4 寫入流程 ······················································································229
14.7 小結 ·······························································································230

相關詞條

熱門詞條

聯絡我們