zoukankan      html  css  js  c++  java
  • 04-influxdb基本操作

    influxdb基本操作

    1. 数据库基本操作

    # 创建数据库
    > create database db01;
    
    # 查看数据库
    > show databases;
    name: databases
    name
    ----
    _internal
    mydb
    db01
    
    # 删除数据库
    > drop database db01;
    > show databases;
    name: databases
    name
    ----
    _internal
    mydb
    
    # 使用数据库
    > use mydb;
    Using database mydb

    2. 表基本操作(measurement)

    # 查看表
    > show measurements;
    name: measurements
    name
    ----
    meas01
    meas02
    mymeans
    mymeas
    
    # 新建表
    # disk_free 就是表名,hostname是索引,value=xx是记录值,记录值可以有多个,最后是指定的时间
    > insert disk_free,hostname=server01 value=442221834240i 1435362189575692182
    > show measurements;
    
    name: measurements
    name
    ----
    disk_free
    meas01
    meas02
    mymeans
    mymeas
    
    # 查看表
    > select * from disk_free;
    name: disk_free
    time                hostname value
    ----                -------- -----
    1435362189575692182 server01 442221834240
    
    # 删除表
    > drop measurement disk_free;
    > show measurements;
    name: measurements
    name
    ----
    meas01
    meas02
    mymeans
    mymeas

    3. 系列基本操作(series)

    > select * from disk_free;
    name: disk_free
    time                hostname value
    ----                -------- -----
    1435362189335692182 server01 442221834240
    1435362189345692182 server01 442221834240
    1435362189355692182 server01 442221834240
    1435362189355692182 server02 442221834240
    # series表示这个表里面的数据,可以在图表上画成几条线,series主要通过tags排列组合算出来。 > show series from disk_free; key --- disk_free,hostname=server01 disk_free,hostname=server02

    4.  存储策略操作(rentention policy)

    # 注意:策略名称需要添加引号
    # 新建策略
    > create retention policy "role-02" on "mydb" duration 2h replication 1 default
    
    # 查看策略
    > show retention policies on mydb;
    name    duration shardGroupDuration replicaN default
    ----    -------- ------------------ -------- -------
    autogen 0s       168h0m0s           1        false
    2_hours 2h0m0s   1h0m0s             1        false
    role-01 2h0m0s   1h0m0s             1        false
    role-02 2h0m0s   1h0m0s             1        true
    
    # name--名称,此示例名称为 default
    # duration--持续时间,0代表无限制1h, 90m, 12h, 7d, 4w, INF 最小1h, 最大INF
    # shardGroupDuration--shardGroup的存储时间,shardGroup是InfluxDB的一个基本储存结构,应该大于这个时间的数据在查询效率上应该有所降低。
    # replicaN--全称是REPLICATION,副本个数
    # default--是否是默认策略
    
    # 修改策略
    > alter retention policy "role-01" on mydb duration 3h default
    > show retention policies on mydb;
    name    duration shardGroupDuration replicaN default
    ----    -------- ------------------ -------- -------
    autogen 0s       168h0m0s           1        false
    2_hours 2h0m0s   1h0m0s             1        false
    role-01 3h0m0s   1h0m0s             1        true
    role-02 2h0m0s   1h0m0s             1        false
    
    # 删除策略
    > drop retention policy "role-01" on mydb;
    > show retention policies on mydb;
    name    duration shardGroupDuration replicaN default
    ----    -------- ------------------ -------- -------
    autogen 0s       168h0m0s           1        false
    2_hours 2h0m0s   1h0m0s             1        false
    role-02 2h0m0s   1h0m0s             1        false
    

    5. 用户操作

    # 查看用户
    > show users;
    user  admin
    ----  -----
    admin true
    
    # 创建普通用户
    > create user root with password '123456';
    > show users;
    user  admin
    ----  -----
    admin true
    root  false
    
    # 创建具有admin权限的用户
    > create user root with password '111111' with all privileges;
    > show users;
    user  admin
    ----  -----
    admin true
    root  true
    
    # 授权root用户admin权限
    > grant all privileges to root;
    > show users;
    user  admin
    ----  -----
    admin true
    root  true
    
    # 删除用户
    > drop user root;
    > show users;
    user  admin
    ----  -----
    admin true
    
    # 修改用户密码
    > set password for admin='111111';
     
  • 相关阅读:
    Robot Framework-取出接口返回的字段
    利用VBA宏批量解决Word中图片大小、居中设置
    封装和继承
    Shiro的学习
    Redis集群搭建
    Mysql主从架构
    idea修改maven的默认配置不生效
    Mybatis笔记
    【python】文件的读写方法(r;r+;rb;w;w+;wb;a;a+;ab)
    【Python】Xpath语法&示例
  • 原文地址:https://www.cnblogs.com/gongniue/p/12498551.html
Copyright © 2011-2022 走看看