mac安装influxDB

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'


以下是本人亲测命令行代码,从下载到安装成功并启动服务:

  1. Last login: Thu May 31 09: 22: 07 on ttys000
  2. bogon:~ weixiangming$ <span style= "color:#ff0000;">brew update</span>
  3. -bash: brew: command not found
  4. bogon:~ weixiangming$ <span style= "color:#ff0000;">ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"</span>
  5. ==> This script will install:
  6. /usr/local/bin/brew
  7. /usr/local/share/doc/homebrew
  8. /usr/local/share/man/man1/brew .1
  9. /usr/local/share/zsh/site-functions/_brew
  10. /usr/local/etc/bash_completion.d/brew
  11. /usr/local/Homebrew
  12. ==> The following existing directories will be made group writable:
  13. /usr/local/bin
  14. /usr/local/share
  15. /usr/local/share/man
  16. /usr/local/share/man/man1
  17. /usr/local/share/man/man3
  18. /usr/local/share/man/man5
  19. /usr/local/share/man/man7
  20. ==> The following existing directories will have their owner set to weixiangming:
  21. /usr/local/bin
  22. /usr/local/share
  23. /usr/local/share/man
  24. /usr/local/share/man/man1
  25. /usr/local/share/man/man3
  26. /usr/local/share/man/man5
  27. /usr/local/share/man/man7
  28. ==> The following existing directories will have their group set to admin:
  29. /usr/local/bin
  30. /usr/local/share
  31. /usr/local/share/man
  32. /usr/local/share/man/man1
  33. /usr/local/share/man/man3
  34. /usr/local/share/man/man5
  35. /usr/local/share/man/man7
  36. ==> The following new directories will be created:
  37. /usr/local/Cellar
  38. /usr/local/Homebrew
  39. /usr/local/Frameworks
  40. /usr/local/etc
  41. /usr/local/ include
  42. /usr/local/lib
  43. /usr/local/opt
  44. /usr/local/sbin
  45. /usr/local/share/zsh
  46. /usr/local/share/zsh/site-functions
  47. /usr/local/ var
  48. Press RETURN to continue or any other key to abort
  49. ==> /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
  50. Password:
  51. ==> /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
  52. ==> /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
  53. ==> /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
  54. ==> /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
  55. ==> /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
  56. ==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
  57. ==> /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
  58. ==> /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
  59. ==> /usr/bin/sudo /bin/mkdir -p /Users/weixiangming/Library/Caches/Homebrew
  60. ==> /usr/bin/sudo /bin/chmod g+rwx /Users/weixiangming/Library/Caches/Homebrew
  61. ==> /usr/bin/sudo /usr/sbin/chown weixiangming /Users/weixiangming/Library/Caches/Homebrew
  62. ==> /usr/bin/sudo /bin/mkdir -p /Library/Caches/Homebrew
  63. ==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
  64. ==> /usr/bin/sudo /usr/sbin/chown weixiangming /Library/Caches/Homebrew
  65. ==> Downloading and installing Homebrew...
  66. remote: Counting objects: 101830, done.
  67. remote: Compressing objects: 100% ( 4/ 4), done.
  68. remote: Total 101830 (delta 0), reused 2 (delta 0), pack-reused 101826
  69. Receiving objects: 100% ( 101830/ 101830), 23.21 MiB | 112.00 KiB/s, done.
  70. Resolving deltas: 100% ( 74173/ 74173), done.
  71. From https: //github.com/Homebrew/brew
  72. * [ new branch] master -> origin/master
  73. * [ new tag] 0.1 -> 0.1
  74. * [ new tag] 0.2 -> 0.2
  75. * [ new tag] 0.3 -> 0.3
  76. * [ new tag] 0.4 -> 0.4
  77. * [ new tag] 0.5 -> 0.5
  78. * [ new tag] 0.6 -> 0.6
  79. * [ new tag] 0.7 -> 0.7
  80. * [ new tag] 0.7 .1 -> 0.7 .1
  81. * [ new tag] 0.8 -> 0.8
  82. * [ new tag] 0.8 .1 -> 0.8 .1
  83. * [ new tag] 0.9 -> 0.9
  84. * [ new tag] 0.9 .1 -> 0.9 .1
  85. * [ new tag] 0.9 .2 -> 0.9 .2
  86. * [ new tag] 0.9 .3 -> 0.9 .3
  87. * [ new tag] 0.9 .4 -> 0.9 .4
  88. * [ new tag] 0.9 .5 -> 0.9 .5
  89. * [ new tag] 0.9 .8 -> 0.9 .8
  90. * [ new tag] 0.9 .9 -> 0.9 .9
  91. * [ new tag] 1.0 .0 -> 1.0 .0
  92. * [ new tag] 1.0 .1 -> 1.0 .1
  93. * [ new tag] 1.0 .2 -> 1.0 .2
  94. * [ new tag] 1.0 .3 -> 1.0 .3
  95. * [ new tag] 1.0 .4 -> 1.0 .4
  96. * [ new tag] 1.0 .5 -> 1.0 .5
  97. * [ new tag] 1.0 .6 -> 1.0 .6
  98. * [ new tag] 1.0 .7 -> 1.0 .7
  99. * [ new tag] 1.0 .8 -> 1.0 .8
  100. * [ new tag] 1.0 .9 -> 1.0 .9
  101. * [ new tag] 1.1 .0 -> 1.1 .0
  102. * [ new tag] 1.1 .1 -> 1.1 .1
  103. * [ new tag] 1.1 .10 -> 1.1 .10
  104. * [ new tag] 1.1 .11 -> 1.1 .11
  105. * [ new tag] 1.1 .12 -> 1.1 .12
  106. * [ new tag] 1.1 .13 -> 1.1 .13
  107. * [ new tag] 1.1 .2 -> 1.1 .2
  108. * [ new tag] 1.1 .3 -> 1.1 .3
  109. * [ new tag] 1.1 .4 -> 1.1 .4
  110. * [ new tag] 1.1 .5 -> 1.1 .5
  111. * [ new tag] 1.1 .6 -> 1.1 .6
  112. * [ new tag] 1.1 .7 -> 1.1 .7
  113. * [ new tag] 1.1 .8 -> 1.1 .8
  114. * [ new tag] 1.1 .9 -> 1.1 .9
  115. * [ new tag] 1.2 .0 -> 1.2 .0
  116. * [ new tag] 1.2 .1 -> 1.2 .1
  117. * [ new tag] 1.2 .2 -> 1.2 .2
  118. * [ new tag] 1.2 .3 -> 1.2 .3
  119. * [ new tag] 1.2 .4 -> 1.2 .4
  120. * [ new tag] 1.2 .5 -> 1.2 .5
  121. * [ new tag] 1.2 .6 -> 1.2 .6
  122. * [ new tag] 1.3 .0 -> 1.3 .0
  123. * [ new tag] 1.3 .1 -> 1.3 .1
  124. * [ new tag] 1.3 .2 -> 1.3 .2
  125. * [ new tag] 1.3 .3 -> 1.3 .3
  126. * [ new tag] 1.3 .4 -> 1.3 .4
  127. * [ new tag] 1.3 .5 -> 1.3 .5
  128. * [ new tag] 1.3 .6 -> 1.3 .6
  129. * [ new tag] 1.3 .7 -> 1.3 .7
  130. * [ new tag] 1.3 .8 -> 1.3 .8
  131. * [ new tag] 1.3 .9 -> 1.3 .9
  132. * [ new tag] 1.4 .0 -> 1.4 .0
  133. * [ new tag] 1.4 .1 -> 1.4 .1
  134. * [ new tag] 1.4 .2 -> 1.4 .2
  135. * [ new tag] 1.4 .3 -> 1.4 .3
  136. * [ new tag] 1.5 .0 -> 1.5 .0
  137. * [ new tag] 1.5 .1 -> 1.5 .1
  138. * [ new tag] 1.5 .10 -> 1.5 .10
  139. * [ new tag] 1.5 .11 -> 1.5 .11
  140. * [ new tag] 1.5 .12 -> 1.5 .12
  141. * [ new tag] 1.5 .13 -> 1.5 .13
  142. * [ new tag] 1.5 .14 -> 1.5 .14
  143. * [ new tag] 1.5 .2 -> 1.5 .2
  144. * [ new tag] 1.5 .3 -> 1.5 .3
  145. * [ new tag] 1.5 .4 -> 1.5 .4
  146. * [ new tag] 1.5 .5 -> 1.5 .5
  147. * [ new tag] 1.5 .6 -> 1.5 .6
  148. * [ new tag] 1.5 .7 -> 1.5 .7
  149. * [ new tag] 1.5 .8 -> 1.5 .8
  150. * [ new tag] 1.5 .9 -> 1.5 .9
  151. * [ new tag] 1.6 .0 -> 1.6 .0
  152. * [ new tag] 1.6 .1 -> 1.6 .1
  153. * [ new tag] 1.6 .2 -> 1.6 .2
  154. * [ new tag] 1.6 .3 -> 1.6 .3
  155. * [ new tag] 1.6 .4 -> 1.6 .4
  156. * [ new tag] 1.6 .5 -> 1.6 .5
  157. * [ new tag] 1.6 .6 -> 1.6 .6
  158. HEAD is now at 0f65758f8 Merge pull request #4240 from Homebrew/dependabot/bundler/docs/github-pages-186
  159. ==> Tapping homebrew/core
  160. Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
  161. remote: Counting objects: 4780, done.
  162. remote: Compressing objects: 100% ( 4562/ 4562), done.
  163. remote: Total 4780 (delta 50), reused 1151 (delta 30), pack-reused 0
  164. Receiving objects: 100% ( 4780/ 4780), 3.88 MiB | 115.00 KiB/s, done.
  165. Resolving deltas: 100% ( 50/ 50), done.
  166. Tapped 4568 formulae ( 4, 821 files, 12.2MB)
  167. ==> Cleaning up /Library/Caches/Homebrew...
  168. ==> Migrating /Library/Caches/Homebrew to /Users/weixiangming/Library/Caches/Homebrew...
  169. ==> Deleting /Library/Caches/Homebrew...
  170. Already up-to-date.
  171. ==> Installation successful!
  172. ==> Homebrew has enabled anonymous aggregate user behaviour analytics.
  173. Read the analytics documentation ( and how to opt-out) here:
  174. https: //docs.brew.sh/Analytics.html
  175. ==> Next steps:
  176. - Run `brew help` to get started
  177. - Further documentation:
  178. https: //docs.brew.sh
  179. bogon:~ weixiangming$ brew update
  180. Already up-to-date.
  181. bogon:~ weixiangming$ <span style= "color:#ff0000;">brew install influxdb</span>
  182. ==> Downloading https: //homebrew.bintray.com/bottles/influxdb-1.5.3.high_sierra.
  183. ######################################################################## 100.0%
  184. ==> Pouring influxdb -1.5 .3.high_sierra.bottle.tar.gz
  185. ==> Caveats
  186. To have launchd start influxdb now and restart at login:
  187. brew services start influxdb
  188. Or, if you don 't want/need a background service you can just run:
  189. influxd -config /usr/local/etc/influxdb.conf
  190. ==> Summary
  1. bogon:~ weixiangming$ <span style="color:#ff0000;">l </span> <span style="color:#ff0000;">n -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents </span>
  2. /Users/weixiangming/Library/LaunchAgents -> /usr/local/opt/influxdb/homebrew.mxcl.influxdb.plist
  1. bogon:~ weixiangming$ <span style= "color:#ff0000;">influxd -config /usr/ local/etc/influxdb.conf< /span>
  2. 8888888 .d888 888 8888888b. 888888b.
  3. 888 d88P" 888 888 "Y88b 888 "88b
  4. 888 888 888 888 888 888 .88P
  5. 888 88888b. 888888 888 888 888 888 888 888 888 8888888K.
  6. 888 888 "88b 888 888 888 888 Y8bd8P' 888 888 888 "Y88b
  7. 888 888 888 888 888 888 888 X88K 888 888 888 888
  8. 888 888 888 888 888 Y88b 888 .d8""8b. 888 .d88P 888 d88P
  9. 8888888 888 888 888 888 "Y88888 888 888 8888888P" 8888888P"
  10. 2018-05-31T04:01:20.910618Z info InfluxDB starting {"log_id": "08P5ZI3W000", "version": "v1.5.3", "branch": "master", "commit": "89e084a80fb1e0bf5e7d38038e3367f821fdf3d7"}
  11. 2018-05-31T04:01:20.910660Z info Go runtime {"log_id": "08P5ZI3W000", "version": "go1.10.2", "maxprocs": 4}
  12. 2018-05-31T04:01:21.014441Z info Using data dir {"log_id": "08P5ZI3W000", "service": "store", "path": "/usr /local/var /influxdb/data "}
  13. 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 "}
  14. 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}
  15. 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 "}
  16. 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}
  17. 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 "}
  18. 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 "}
  19. 2018-05-31T04:01:21.045864Z info Opened service {"log_id ": "08P5ZI3W00 0 ", "service ": "subscriber "}
  20. 2018-05-31T04:01:21.045882Z info Starting monitor service {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor "}
  21. 2018-05-31T04:01:21.045893Z info Registered diagnostics client {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "name ": "build "}
  22. 2018-05-31T04:01:21.045902Z info Registered diagnostics client {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "name ": "runtime "}
  23. 2018-05-31T04:01:21.045910Z info Registered diagnostics client {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "name ": "network "}
  24. 2018-05-31T04:01:21.045923Z info Registered diagnostics client {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "name ": " system "}
  25. 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 "}
  26. 2018-05-31T04:01:21.045984Z info Starting snapshot service {"log_id ": "08P5ZI3W00 0 ", "service ": "snapshot "}
  27. 2018-05-31T04:01:21.045998Z info Starting continuous query service {"log_id ": "08P5ZI3W00 0 ", "service ": "continuous_querier "}
  28. 2018-05-31T04:01:21.046016Z info Starting HTTP service {"log_id ": "08P5ZI3W00 0 ", "service ": "httpd ", "authentication ": false}
  29. 2018-05-31T04:01:21.046027Z info opened HTTP access log {"log_id ": "08P5ZI3W00 0 ", "service ": "httpd ", "path ": "stderr "}
  30. 2018-05-31T04:01:21.046003Z info Storing statistics {"log_id ": "08P5ZI3W00 0 ", "service ": "monitor ", "db_instance ": "_internal ", "db_rp ": "monitor ", "interval ": " 10 s "}
  31. 2018-05-31T04:01:21.046163Z info Listening on HTTP {"log_id ": "08P5ZI3W00 0 ", "service ": "httpd ", "addr ": "[::]: 8086 ", "https ": false}
  32. 2018-05-31T04:01:21.046187Z info Starting retention policy enforcement service {"log_id ": "08P5ZI3W00 0 ", "service ": "retention ", "check_interval ": " 30 m "}
  33. 2018-05-31T04:01:21.046287Z info Listening for signals {"log_id ": "08P5ZI3W00 0 "}
  34. 2018-05-31T04:01:21.046385Z info Sending usage statistics to usage.influxdata.com {"log_id ": "08P5ZI3W00 0 "}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值