Mac安装influxdb
# brew 又叫Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便。brew类似ubuntu系统下的apt-get的功能
brew update
# 如果不能使用可以先删除旧的Homebrew,再安装新的Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 安装influxDB
brew install influxdb
# 要在登录时启动influxDB,运行:
ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents
# 配置文件在/etc/influxdb/influxdb.conf ,如果没有就将/usr/local/etc/influxdb.conf 拷一个过去
配置缓存:cache-max-memory-size
# 启动服务
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
# 停止服务
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
# 前台启动
influxd -config /usr/local/etc/influxdb.conf
# 查看influxdb运行配置
influxd config
# 启动客户端
influx -precision rfc3339
基本操作
参考:http://docs.influxdata.com/influxdb/v1.3/query_language/data_exploration/#the-group-by-clause
数据库操作
创建数据库
create database mydb
删除数据库
drop database mydb
使用数据库
use mydb
数据插入
语法
<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp]类似: 表,联合主键1,联合主键2 普通列1,普通列2 时间
第一次插入数据会确定数据类型,之后的插入不能换数据类型。
插入同一时间的数据会覆盖旧的,时间是主键。可以乱序插入。
示例
insert cpu,machine=unit42,type=assembly external=25,internal=37 1434067467000000000插入字符串类型的数据用双引号表示insert temperature,machine=unit42,type=1 external=25,internal1="37"
查询
where 中对字符串的过滤必须用单引号,tag默认为字符串类型
select * from temperature where type='assembly'
以下是本人亲测命令行代码,从下载到安装成功并启动服务:
-
Last login: Thu May 31 09: 22: 07 on ttys000
-
bogon:~ weixiangming$ <span style= "color:#ff0000;">brew update</span>
-
-bash: brew: command not found
-
bogon:~ weixiangming$ <span style= "color:#ff0000;">ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"</span>
-
==> This script will install:
-
/usr/local/bin/brew
-
/usr/local/share/doc/homebrew
-
/usr/local/share/man/man1/brew .1
-
/usr/local/share/zsh/site-functions/_brew
-
/usr/local/etc/bash_completion.d/brew
-
/usr/local/Homebrew
-
==> The following existing directories will be made group writable:
-
/usr/local/bin
-
/usr/local/share
-
/usr/local/share/man
-
/usr/local/share/man/man1
-
/usr/local/share/man/man3
-
/usr/local/share/man/man5
-
/usr/local/share/man/man7
-
==> The following existing directories will have their owner set to weixiangming:
-
/usr/local/bin
-
/usr/local/share
-
/usr/local/share/man
-
/usr/local/share/man/man1
-
/usr/local/share/man/man3
-
/usr/local/share/man/man5
-
/usr/local/share/man/man7
-
==> The following existing directories will have their group set to admin:
-
/usr/local/bin
-
/usr/local/share
-
/usr/local/share/man
-
/usr/local/share/man/man1
-
/usr/local/share/man/man3
-
/usr/local/share/man/man5
-
/usr/local/share/man/man7
-
==> The following new directories will be created:
-
/usr/local/Cellar
-
/usr/local/Homebrew
-
/usr/local/Frameworks
-
/usr/local/etc
-
/usr/local/ include
-
/usr/local/lib
-
/usr/local/opt
-
/usr/local/sbin
-
/usr/local/share/zsh
-
/usr/local/share/zsh/site-functions
-
/usr/local/ var
-
-
Press RETURN to continue or any other key to abort
-
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
-
Password:
-
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
-
==> /usr/bin/sudo /usr/sbin/chown weixiangming /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
-
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
-
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/ include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/ var
-
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/ include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/ var
-
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
-
==> /usr/bin/sudo /usr/sbin/chown weixiangming /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/ include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/ var
-
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/ include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/ var
-
==> /usr/bin/sudo /bin/mkdir -p /Users/weixiangming/Library/Caches/Homebrew
-
==> /usr/bin/sudo /bin/chmod g+rwx /Users/weixiangming/Library/Caches/Homebrew
-
==> /usr/bin/sudo /usr/sbin/chown weixiangming /Users/weixiangming/Library/Caches/Homebrew
-
==> /usr/bin/sudo /bin/mkdir -p /Library/Caches/Homebrew
-
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
-
==> /usr/bin/sudo /usr/sbin/chown weixiangming /Library/Caches/Homebrew
-
==> Downloading and installing Homebrew...
-
remote: Counting objects: 101830, done.
-
remote: Compressing objects: 100% ( 4/ 4), done.
-
remote: Total 101830 (delta 0), reused 2 (delta 0), pack-reused 101826
-
Receiving objects: 100% ( 101830/ 101830), 23.21 MiB | 112.00 KiB/s, done.
-
Resolving deltas: 100% ( 74173/ 74173), done.
-
From https: //github.com/Homebrew/brew
-
* [ new branch] master -> origin/master
-
* [ new tag] 0.1 -> 0.1
-
* [ new tag] 0.2 -> 0.2
-
* [ new tag] 0.3 -> 0.3
-
* [ new tag] 0.4 -> 0.4
-
* [ new tag] 0.5 -> 0.5
-
* [ new tag] 0.6 -> 0.6
-
* [ new tag] 0.7 -> 0.7
-
* [ new tag] 0.7 .1 -> 0.7 .1
-
* [ new tag] 0.8 -> 0.8
-
* [ new tag] 0.8 .1 -> 0.8 .1
-
* [ new tag] 0.9 -> 0.9
-
* [ new tag] 0.9 .1 -> 0.9 .1
-
* [ new tag] 0.9 .2 -> 0.9 .2
-
* [ new tag] 0.9 .3 -> 0.9 .3
-
* [ new tag] 0.9 .4 -> 0.9 .4
-
* [ new tag] 0.9 .5 -> 0.9 .5
-
* [ new tag] 0.9 .8 -> 0.9 .8
-
* [ new tag] 0.9 .9 -> 0.9 .9
-
* [ new tag] 1.0 .0 -> 1.0 .0
-
* [ new tag] 1.0 .1 -> 1.0 .1
-
* [ new tag] 1.0 .2 -> 1.0 .2
-
* [ new tag] 1.0 .3 -> 1.0 .3
-
* [ new tag] 1.0 .4 -> 1.0 .4
-
* [ new tag] 1.0 .5 -> 1.0 .5
-
* [ new tag] 1.0 .6 -> 1.0 .6
-
* [ new tag] 1.0 .7 -> 1.0 .7
-
* [ new tag] 1.0 .8 -> 1.0 .8
-
* [ new tag] 1.0 .9 -> 1.0 .9
-
* [ new tag] 1.1 .0 -> 1.1 .0
-
* [ new tag] 1.1 .1 -> 1.1 .1
-
* [ new tag] 1.1 .10 -> 1.1 .10
-
* [ new tag] 1.1 .11 -> 1.1 .11
-
* [ new tag] 1.1 .12 -> 1.1 .12
-
* [ new tag] 1.1 .13 -> 1.1 .13
-
* [ new tag] 1.1 .2 -> 1.1 .2
-
* [ new tag] 1.1 .3 -> 1.1 .3
-
* [ new tag] 1.1 .4 -> 1.1 .4
-
* [ new tag] 1.1 .5 -> 1.1 .5
-
* [ new tag] 1.1 .6 -> 1.1 .6
-
* [ new tag] 1.1 .7 -> 1.1 .7
-
* [ new tag] 1.1 .8 -> 1.1 .8
-
* [ new tag] 1.1 .9 -> 1.1 .9
-
* [ new tag] 1.2 .0 -> 1.2 .0
-
* [ new tag] 1.2 .1 -> 1.2 .1
-
* [ new tag] 1.2 .2 -> 1.2 .2
-
* [ new tag] 1.2 .3 -> 1.2 .3
-
* [ new tag] 1.2 .4 -> 1.2 .4
-
* [ new tag] 1.2 .5 -> 1.2 .5
-
* [ new tag] 1.2 .6 -> 1.2 .6
-
* [ new tag] 1.3 .0 -> 1.3 .0
-
* [ new tag] 1.3 .1 -> 1.3 .1
-
* [ new tag] 1.3 .2 -> 1.3 .2
-
* [ new tag] 1.3 .3 -> 1.3 .3
-
* [ new tag] 1.3 .4 -> 1.3 .4
-
* [ new tag] 1.3 .5 -> 1.3 .5
-
* [ new tag] 1.3 .6 -> 1.3 .6
-
* [ new tag] 1.3 .7 -> 1.3 .7
-
* [ new tag] 1.3 .8 -> 1.3 .8
-
* [ new tag] 1.3 .9 -> 1.3 .9
-
* [ new tag] 1.4 .0 -> 1.4 .0
-
* [ new tag] 1.4 .1 -> 1.4 .1
-
* [ new tag] 1.4 .2 -> 1.4 .2
-
* [ new tag] 1.4 .3 -> 1.4 .3
-
* [ new tag] 1.5 .0 -> 1.5 .0
-
* [ new tag] 1.5 .1 -> 1.5 .1
-
* [ new tag] 1.5 .10 -> 1.5 .10
-
* [ new tag] 1.5 .11 -> 1.5 .11
-
* [ new tag] 1.5 .12 -> 1.5 .12
-
* [ new tag] 1.5 .13 -> 1.5 .13
-
* [ new tag] 1.5 .14 -> 1.5 .14
-
* [ new tag] 1.5 .2 -> 1.5 .2
-
* [ new tag] 1.5 .3 -> 1.5 .3
-
* [ new tag] 1.5 .4 -> 1.5 .4
-
* [ new tag] 1.5 .5 -> 1.5 .5
-
* [ new tag] 1.5 .6 -> 1.5 .6
-
* [ new tag] 1.5 .7 -> 1.5 .7
-
* [ new tag] 1.5 .8 -> 1.5 .8
-
* [ new tag] 1.5 .9 -> 1.5 .9
-
* [ new tag] 1.6 .0 -> 1.6 .0
-
* [ new tag] 1.6 .1 -> 1.6 .1
-
* [ new tag] 1.6 .2 -> 1.6 .2
-
* [ new tag] 1.6 .3 -> 1.6 .3
-
* [ new tag] 1.6 .4 -> 1.6 .4
-
* [ new tag] 1.6 .5 -> 1.6 .5
-
* [ new tag] 1.6 .6 -> 1.6 .6
-
HEAD is now at 0f65758f8 Merge pull request #4240 from Homebrew/dependabot/bundler/docs/github-pages-186
-
==> Tapping homebrew/core
-
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
-
remote: Counting objects: 4780, done.
-
remote: Compressing objects: 100% ( 4562/ 4562), done.
-
remote: Total 4780 (delta 50), reused 1151 (delta 30), pack-reused 0
-
Receiving objects: 100% ( 4780/ 4780), 3.88 MiB | 115.00 KiB/s, done.
-
Resolving deltas: 100% ( 50/ 50), done.
-
Tapped 4568 formulae ( 4, 821 files, 12.2MB)
-
==> Cleaning up /Library/Caches/Homebrew...
-
==> Migrating /Library/Caches/Homebrew to /Users/weixiangming/Library/Caches/Homebrew...
-
==> Deleting /Library/Caches/Homebrew...
-
Already up-to-date.
-
==> Installation successful!
-
-
==> Homebrew has enabled anonymous aggregate user behaviour analytics.
-
Read the analytics documentation ( and how to opt-out) here:
-
https: //docs.brew.sh/Analytics.html
-
-
==> Next steps:
-
- Run `brew help` to get started
-
- Further documentation:
-
https: //docs.brew.sh
-
bogon:~ weixiangming$ brew update
-
Already up-to-date.
-
bogon:~ weixiangming$ <span style= "color:#ff0000;">brew install influxdb</span>
-
==> Downloading https: //homebrew.bintray.com/bottles/influxdb-1.5.3.high_sierra.
-
######################################################################## 100.0%
-
==> Pouring influxdb -1.5 .3.high_sierra.bottle.tar.gz
-
==> Caveats
-
To have launchd start influxdb now and restart at login:
-
brew services start influxdb
-
Or, if you don 't want/need a background service you can just run:
-
influxd -config /usr/local/etc/influxdb.conf
-
==> Summary
-
bogon:~ weixiangming$ <span style="color:#ff0000;">l </span> <span style="color:#ff0000;">n -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents </span>
-
/Users/weixiangming/Library/LaunchAgents -> /usr/local/opt/influxdb/homebrew.mxcl.influxdb.plist
-
bogon:~ weixiangming$ <span style= "color:#ff0000;">influxd -config /usr/ local/etc/influxdb.conf< /span>
-
-
8888888 .d888 888 8888888b. 888888b.
-
888 d88P" 888 888 "Y88b 888 "88b
-
888 888 888 888 888 888 .88P
-
888 88888b. 888888 888 888 888 888 888 888 888 8888888K.
-
888 888 "88b 888 888 888 888 Y8bd8P' 888 888 888 "Y88b
-
888 888 888 888 888 888 888 X88K 888 888 888 888
-
888 888 888 888 888 Y88b 888 .d8""8b. 888 .d88P 888 d88P
-
8888888 888 888 888 888 "Y88888 888 888 8888888P" 8888888P"
-
-
2018-05-31T04:01:20.910618Z info InfluxDB starting {"log_id": "08P5ZI3W000", "version": "v1.5.3", "branch": "master", "commit": "89e084a80fb1e0bf5e7d38038e3367f821fdf3d7"}
-
2018-05-31T04:01:20.910660Z info Go runtime {"log_id": "08P5ZI3W000", "version": "go1.10.2", "maxprocs": 4}
-
2018-05-31T04:01:21.014441Z info Using data dir {"log_id": "08P5ZI3W000", "service": "store", "path": "/usr /local/var /influxdb/data "}
-
2018-05-31T04:01:21.014556Z info Open store (start) {"log_id ": "08P5ZI3W00 0 ", "service ": "store ", "trace_id ": "08P5ZITW00 0 ", "op_name ": "tsdb_open ", "op_event ": "start "}
-
2018-05-31T04:01:21.019431Z info Reading file {"log_id ": "08P5ZI3W00 0 ", "engine ": "tsm1 ", "service ": "cacheloader ", "path ": "/usr/ local/var/influxdb/wal/PARAMTER_DB/defalut/ 2/_00001.wal ", "size ": 8260}
-
2018-05-31T04:01:21.022644Z info Opened shard {"log_id ": "08P5ZI3W00 0 ", "service ": "store ", "trace_id ": "08P5ZITW00 0 ", "op_name ": "tsdb_open ", "path ": "/usr/ local/var/influxdb/data/PARAMTER_DB/defalut/ 2 ", "duration ": " 4.239ms "}
-
2018-05-31T04:01:21.022808Z info Reading file {"log_id ": "08P5ZI3W00 0 ", "engine ": "tsm1 ", "service ": "cacheloader ", "path ": "/usr/ local/var/influxdb/wal/_internal/monitor/ 1/_00001.wal ", "size ": 355787}
-
2018-05-31T04:01:21.045731Z info Opened shard {"log_id ": "08P5ZI3W00 0 ", "service ": "store ", "trace_id ": "08P5ZITW00 0 ", "op_name ": "tsdb_open ", "path ": "/usr/ local/var/influxdb/data/_internal/monitor/ 1 ", "duration ": " 24.397ms "}
-
2018-05-31T04:01:21.045817Z info Open store (end) {"log_id ": "08P5ZI3W00 0 ", "service ": "store ", "trace_id ": "08P5ZITW00 0 ", "op_name ": "tsdb_open ", "op_event ": "end ", "op_elapsed ": " 31.264ms "}
-
2018-05-31T04:01:21.045864Z info Opened service {"log_id ": "08P5ZI3W00 0 ", "service ": "subscriber "}
-
2018-05-31T04:01:21.045882Z info Starting monitor service {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor "}
-
2018-05-31T04:01:21.045893Z info Registered diagnostics client {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "name ": "build "}
-
2018-05-31T04:01:21.045902Z info Registered diagnostics client {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "name ": "runtime "}
-
2018-05-31T04:01:21.045910Z info Registered diagnostics client {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "name ": "network "}
-
2018-05-31T04:01:21.045923Z info Registered diagnostics client {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "name ": " system "}
-
2018-05-31T04:01:21.045963Z info Starting precreation service {"log_id ": "08P5ZI3W00 0 ", "service ": "shard-precreation ", "check_interval ": " 10 m ", "advance_period ": " 30 m "}
-
2018-05-31T04:01:21.045984Z info Starting snapshot service {"log_id ": "08P5ZI3W00 0 ", "service ": "snapshot "}
-
2018-05-31T04:01:21.045998Z info Starting continuous query service {"log_id ": "08P5ZI3W00 0 ", "service ": "continuous_querier "}
-
2018-05-31T04:01:21.046016Z info Starting HTTP service {"log_id ": "08P5ZI3W00 0 ", "service ": "httpd ", "authentication ": false}
-
2018-05-31T04:01:21.046027Z info opened HTTP access log {"log_id ": "08P5ZI3W00 0 ", "service ": "httpd ", "path ": "stderr "}
-
2018-05-31T04:01:21.046003Z info Storing statistics {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "db_instance ": "_internal ", "db_rp ": "monitor ", "interval ": " 10 s "}
-
2018-05-31T04:01:21.046163Z info Listening on HTTP {"log_id ": "08P5ZI3W00 0 ", "service ": "httpd ", "addr ": "[::]: 8086 ", "https ": false}
-
2018-05-31T04:01:21.046187Z info Starting retention policy enforcement service {"log_id ": "08P5ZI3W00 0 ", "service ": "retention ", "check_interval ": " 30 m "}
-
2018-05-31T04:01:21.046287Z info Listening for signals {"log_id ": "08P5ZI3W00 0 "}
-
2018-05-31T04:01:21.046385Z info Sending usage statistics to usage.influxdata.com {"log_id ": "08P5ZI3W00 0 "}