Skip to content

Commit 5ca6d44

Browse files
committed
book 0.1.0
1 parent 72a2f07 commit 5ca6d44

26 files changed

+447
-17
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/_book
2+
3+
/picture

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,42 @@
1-
# InfluxDB手册
1+
# InfluxDB简明手册
2+
23
写这本手册有两个目的:
34
1. 作为自己的学习influxDB的笔记
45
2. 顺便了解下gitbook的使用
56

7+
------
8+
手册不断完善中,欢迎 **pull request!**
9+
**如果对你有所帮助,请给一个Star!**
10+
项目地址: [https://github.com/xtutu/influxdb-handbook](https://github.com/xtutu/influxdb-handbook)
611

7-
这本手册还在编辑中,非常欢迎给我 **pull request**
12+
-------
813

9-
项目地址: [https://github.com/xtutu/influxdb-handbook](https://github.com/xtutu/influxdb-handbook)
1014

11-
教程地址: [https://www.gitbook.com/read/book/xtutu/influxdb-handbook](https://www.gitbook.com/read/book/xtutu/influxdb-handbook)
15+
手册在线地址: [https://www.gitbook.com/read/book/xtutu/influxdb-handbook](https://www.gitbook.com/read/book/xtutu/influxdb-handbook)
1216

1317
作者博客: [http://www.xtutu.me/](http://www.xtutu.me/)
18+
19+
20+
## 项目介绍
21+
**写这本手册的时候InfluxDB版本为: v0.10 **
22+
23+
本手册只是简单的上手教程,并不是官方文档的详细翻译。 之所以不是官方文档的中文翻译,有两方面原因:
24+
1. 精力有限,全部翻译量实在是太大了。
25+
2. 官方文档是开源的:[https://github.com/influxdata/docs.influxdata.com](https://github.com/influxdata/docs.influxdata.com)
26+
它所采用的文档工具[gohugo.io](http://gohugo.io/tutorials/create-a-multilingual-site/)是支持多语言设计的。所以有兴趣参与的同学,可以直接在Github上Fork。
27+
28+
29+
## 使用方法
30+
如果嫌在线速度慢的话,也直接在本地生成。具体方法如下:
31+
1. 安装NodeJS
32+
2. 安装gitbook
33+
```bash
34+
npm install gitbook -g
35+
```
36+
37+
3. clone本仓库
38+
4. 生成html代码
39+
```bash
40+
gitbook build
41+
```
42+
然后就可以直接在本地看啦

SUMMARY.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
* [前言](README.md)
44
* [InfluxDB介绍](influxdbjie_shao.md)
55
* [安装使用](an_zhuang_shi_yong.md)
6-
* [名词解析](ming_ci_jie_xi.md)
7-
* [增删改查](chapter1.md)
6+
* [名词解释](ming_ci_jie_xi.md)
7+
* [基本操作](ji_ben_cao_zuo_md.md)
88
* [](zeng.md)
9-
* [更进一步](geng_jin_yi_bu.md)
9+
* [删与改](shanyugai_md_md.md)
10+
* [](cha.md)
11+
* [数据库与表的操作](shu_ju_ku_yu_biao_de_cao_zuo.md)
1012
* [数据保存策略(Retention Policies)](shu_ju_bao_cun_ce_lve_retention_policies.md)
13+
* [连续查询(Continuous Queries)](lian_xu_cha_xun_continuous_queries.md)
14+
* [用户管理](yong_hu_guan_li.md)
15+
* [第三方库API接口](disan_fang_ku_md.md)
16+
* [NodeJS](nodejs-api.md)
17+
* [数据展示工具](shu_ju_zhan_shi_gong_ju.md)
18+
* [Grafana简单使用](grafanajian_dan_shi_yong.md)
19+
* [接下去可以看些什么?](jie_xia_qu_ke_yi_kan_xie_shen_me.md)
1120

an_zhuang_shi_yong.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,61 @@
11
# 安装使用
22

3-
这里以ubuntu为例
3+
## 下载地址
4+
直接官网下载就好,非常简单。
5+
[https://influxdata.com/downloads/#influxdb](https://influxdata.com/downloads/#influxdb)
46

5-
todo
7+
## 安装
8+
```bash
9+
sudo dpkg -i influxdbName.deb
10+
```
11+
12+
## 启动
13+
```bash
14+
sudo service influxdb start
15+
```
16+
17+
## 使用
18+
启动成功之后,我们就可以开始使用influxDB啦!
19+
20+
### 命令行
21+
在命令行中直接输入influx,就可以管理数据库了。
22+
23+
```bash
24+
root@xtutu:~# influx
25+
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
26+
Connected to http://localhost:8086 version 0.10.0
27+
InfluxDB shell 0.10.0
28+
> show databases
29+
name: databases
30+
---------------
31+
name
32+
_internal
33+
mydb
34+
35+
```
36+
37+
### 使用web页面来操作
38+
在浏览器中输入[localhost:8083](localhost:8083) 即可进入web管理页面。
39+
40+
![](img_20160225175525.jpg)
41+
42+
## 创建一个数据库
43+
```bash
44+
> CREATE DATABASE "testDB"
45+
> show databases
46+
name: databases
47+
---------------
48+
name
49+
_internal
50+
mydb
51+
testDB
52+
```
53+
54+
## 使用数据库
55+
```bash
56+
> use testDB
57+
Using database testDB
58+
```
59+
**现在我们就可以在这个数据库上进行各种操作了!**
60+
61+
*表的增删改查等操作在之后的几个章节里*

cha.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
3+
本节将演示下查询数据的一些常用方法。
4+
5+
## 通过命令行
6+
```bash
7+
use testDB
8+
# 查询最新的三条数据
9+
SELECT * FROM weather ORDER BY time DESC LIMIT 3
10+
```
11+
12+
13+
## 通过Http接口
14+
```bash
15+
curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=testDB" --data-urlencode "q=SELECT * FROM weather ORDER BY time DESC LIMIT 3"
16+
```
17+
18+
**InfluxDB是支持类SQL语句的,具体的查询语法都差不多,就不再详细描述了。**

chapter1.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

disan_fang_ku_md.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 第三方库API接口
2+
InfluxDB提供了各种语言的Http API接口的封装。具体可以看这里:
3+
[https://docs.influxdata.com/influxdb/v0.10/clients/api/](https://docs.influxdata.com/influxdb/v0.10/clients/api/)
4+
5+
同时,官方也提供了Telegraf插件来收集数据,除此之外还有collectd等比较常用的第三方数据收集工具。
6+
7+
我并不推荐一开始就用各种工具,这样会淡化对InfluxDB的理解。
8+
*当然,如果你本身对这些工具很熟悉,那么就直接使用吧!*
9+
10+
所以本章节主要介绍各语言对InfluxDB Http API接口的封装。
11+

grafanajian_dan_shi_yong.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Grafana简单使用
2+
3+
## 下载安装
4+
Grafana也是用GO语言写的,无任何依赖,安装非常简单。
5+
6+
## 启动
7+
```bash
8+
sudo service grafana-server start
9+
```
10+
11+
## 运行
12+
直接访问:http://your_ip:3000
13+
14+
## 登入
15+
默认帐号:admin
16+
默认密码:admin
17+
18+
![](img_20160226114619.jpg)
19+
20+
## 添加数据库
21+
在Data Sources中添加数据库testDB
22+
![](img_20160226115132.jpg)
23+
24+
25+
其中user和password,如果没有设置过,可以随便填下。
26+
保存之后,可以通过Test Connection来测试,是否填写正确。
27+
28+
## 创建Dashboard
29+
点击New按钮就可以了。
30+
31+
![](img-20160226115614.jpg)
32+
33+
## 添加一个图形界面
34+
![](img_20160226115801.jpg)
35+
36+
## 为界面关联数据
37+
1. 选择testDB数据库
38+
2. 添加查询语句
39+
3. 完美显示!记得保存
40+
41+
![](img_20160226120201.jpg)

img-20160226115614.jpg

18 KB
Loading

img_20160225175525.jpg

13.6 KB
Loading

img_20160226114619.jpg

14.4 KB
Loading

img_20160226115132.jpg

43.1 KB
Loading

img_20160226115801.jpg

14.9 KB
Loading

img_20160226120201.jpg

66.5 KB
Loading

influxdbjie_shao.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
# InfluxDB介绍
22

33
[InfluxDB](https://www.influxdata.com)用Go语言编写的一个开源分布式时序、事件和指标数据库,和传统是数据库相比有不少不同的地方。
4+
5+
类似的数据库有Elasticsearch、Graphite等。
6+
7+
## 特点
8+
1. 提供了Http接口的API来操作数据
9+
2. 提供了类似sql的数据库语句
10+
3. 其它...
11+
12+
## 用途
13+
一般用来储存实时数据,配合一套UI界面来展示信息。

ji_ben_cao_zuo_md.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 基本操作
2+
3+
本章将介绍InfluxDB中的一些基本操作,包括数据的增删改查、数据库与表的操作等。

jie_xia_qu_ke_yi_kan_xie_shen_me.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 接下去可以看些什么?
2+
3+
1. 官方教程
4+
2. 集群
5+
3. 性能优化
6+
4. 等等等...

lian_xu_cha_xun_continuous_queries.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# 连续查询(Continuous Queries)
2+
当数据超过保存策略里指定的时间之后,就会被删除。
3+
如果我们不想完全删除掉,比如做一个数据统计采样:把原先每秒的数据,存为每小时的数据,让数据占用的空间大大减少(以降低精度为代价)。
4+
5+
这就需要InfluxDB提供的:连续查询(Continuous Queries)。
6+
7+
## 当前数据库的Continuous Queries
8+
```bash
9+
# 这条命令得在命令行下输入,在web管理界面不能显示。
10+
SHOW CONTINUOUS QUERIES
11+
```
12+
13+
## 创建新的Continuous Queries
14+
```bash
15+
> CREATE CONTINUOUS QUERY cq_30m ON testDB BEGIN SELECT mean(temperature) INTO weather30m FROM weather GROUP BY time(30m) END
16+
```
17+
其中:
18+
1. cq_30m:连续查询的名字
19+
2. testDB:具体的数据库名
20+
3. mean(temperature): 算平均温度
21+
4. weather: 当前表名
22+
5. weather30m: 存新数据的表名
23+
6. 30m:时间间隔为30分钟
24+
25+
26+
**当我们插入新数据之后,可以发现数据库中多了一张名为weather30m(里面已经存着计算好的数据了)。这一切都是通过Continuous Queries自动完成的。**
27+
28+
```bash
29+
> SHOW MEASUREMENTS
30+
name: measurements
31+
------------------
32+
name
33+
weather
34+
weather30m
35+
```
36+
37+
## 删除Continuous Queries
38+
```bash
39+
DROP CONTINUOUS QUERY <cq_name> ON <database_name>
40+
```
41+
42+
**具体效果,大家可以直接自己在测试数据库上试验**

ming_ci_jie_xi.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
# 名词解析
2-
31
# 名词解释
4-
这里先将以下场景:
5-
我们有一个数据库名为testDB,里面有一张表weather用于记录:多个地区在几组海拔下的一天的温度变化,所以表中有以下字段:
2+
在上一个章节中,已经建立了一个名为testDB的数据库。在之后的演示中,都将在这个数据库上操作。
3+
4+
在InfluxDB中有不少名词,初学者非常容易搞混,这一节主要就是对这些名词进行解释。
5+
6+
## 场景定义
7+
我们有一个数据库名为testDB,里面有一张表weather用于记录:多个地区在几组海拔下的一天的温度变化,所以表中有以下字段:
68
1. 时间 time
79
2. 温度 temperature
810
3. 湿度 humidity
911
3. 地区 area
1012
4. 海拔 altitude
1113

12-
## 数据库、表、数据
14+
## 与传统数据库中的名词做比较
15+
1316

1417
| influxDB中的名词 | 传统数据库中的概念 |
1518
| :----: | :----: |
@@ -51,7 +54,7 @@ time altitude area humidity temperature
5154

5255
它的series为:
5356
```js
54-
> show series from weather
57+
> show series from weather
5558
name: weather
5659
-------------
5760
_key altitude area

0 commit comments

Comments
 (0)