influxDB -writing old

Published onesixx on

OLD ver.

https://youtu.be/a00l1GxJszM
# influx
Connected to http://localhost:8086 version 1.6.4
InfluxDB shell version: 1.6.4

> show databases
name: databases
name
----
_internal
devopsjourney
mydb

> use _internal
Using database _internal

> show measurements   -- tables과 같음.
name: measurements
name
----
cq
database
httpd
queryExecutor
runtime
shard
subscriber
tsm1_cache
tsm1_engine
tsm1_filestore
tsm1_wal
write

> select * from runtime limit 3;     -- sql사용
name: runtime
time                Alloc   Frees  HeapAlloc HeapIdle HeapInUse HeapObjects HeapReleased HeapSys Lookups Mallocs NumGC NumGoroutine PauseTotalNs Sys      TotalAlloc hostname
----                -----   -----  --------- -------- --------- ----------- ------------ ------- ------- ------- ----- ------------ ------------ ---      ---------- --------
1636541260000000000 2952168 266883 2952168   1916928  4571136   35171       0            6488064 965     302054  6     15           1038172      10590456 14440448   924e04304caf
1636541270000000000 2903840 288837 2903840   1236992  5251072   15549       0            6488064 1049    304386  7     17           1203278      10590456 15927728   924e04304caf
1636541280000000000 3280040 288988 3280040   917504   5570560   17637       0            6488064 1053    306625  7     17           1203278      10590456 16303928   924e04304caf

> select Alloc, Frees, HeapAlloc, NumGC  from runtime limit 3;   --time 안씀
name: runtime
time                Alloc   Frees  HeapAlloc NumGC
----                -----   -----  --------- -----
1636541260000000000 2952168 266883 2952168   6
1636541270000000000 2903840 288837 2903840   7
1636541280000000000 3280040 288988 3280040   7

> quit
# influx -precision rfc3339
Connected to http://localhost:8086 version 1.6.4
InfluxDB shell version: 1.6.4

# precision 'rfc3339|h|m|s|ms|u|ns'
# Precision specifies the format of the timestamp:  rfc3339, h, m, s, ms, u or ns.

> create database exemDB
> use exemDB
-- 한 Point(행)은 line protocol 로 구성
-- Measurement, Tag set 키=값  Field set 키=값  timeStamp
-- ex)
insert soccer,name=son,nation=Korea   team="tottenham",age=29,city="London"   1511866000000000000
insert soccer,name=messi,nation=Argentina   team="PSG",age=34,city="Paris"   1521967000000000000
insert soccer,name=HarryKane,nation=England   team="tottenham",age=28,city="London"

> show measurements
name: measurements
name
----
soccer

> select * from soccer
name: soccer
time                         age city   name      nation    team
----                         --- ----   ----      ------    ----
2017-11-28T10:46:40Z         29  London son       Korea     tottenham
2018-03-25T08:36:40Z         34  Paris  messi     Argentina PSG
2021-11-15T07:07:35.8174169Z 28  London HarryKane England   tottenham

> show tag keys on exemDB from soccer
name: soccer
tagKey
------
name
nation

> show field keys from soccer
name: soccer
fieldKey fieldType
-------- ---------
age      float
city     string
team     string

> delete from soccer where nation='England'
> select * from soccer
name: soccer
time                 age city   name  nation    team
----                 --- ----   ----  ------    ----
2017-11-28T10:46:40Z 29  London son   Korea     tottenham
2018-03-25T08:36:40Z 34  Paris  messi Argentina PSG

> drop measuerment soccer
> drop database exemDB
$ docker exec -it 924e04304caff1826d9364ccaae1aea0e06c99280768ec5a24472db6ca1b23a1 /bin/

$# influxd backup -portable -database exemDB /tmp/backup
2021/11/15 07:28:55 backing up metastore to /tmp/backup/meta.00
2021/11/15 07:28:55 backing up db=exemDB
2021/11/15 07:28:55 backing up db=exemDB rp=autogen shard=6 to /tmp/backup/exemDB.autogen.00006.00 since 0001-01-01T00:00:00Z
2021/11/15 07:28:55 backing up db=exemDB rp=autogen shard=7 to /tmp/backup/exemDB.autogen.00007.00 since 0001-01-01T00:00:00Z
2021/11/15 07:28:55 backing up db=exemDB rp=autogen shard=8 to /tmp/backup/exemDB.autogen.00008.00 since 0001-01-01T00:00:00Z
2021/11/15 07:28:55 backup complete:
2021/11/15 07:28:55     /tmp/backup/20211115T072855Z.meta
2021/11/15 07:28:55     /tmp/backup/20211115T072855Z.s6.tar.gz
2021/11/15 07:28:55     /tmp/backup/20211115T072855Z.s7.tar.gz
2021/11/15 07:28:55     /tmp/backup/20211115T072855Z.s8.tar.gz
2021/11/15 07:28:55     /tmp/backup/20211115T072855Z.manifest

$# influxd restore -portable -db exemDB /tmp/backup
2021/11/15 07:35:42 Restoring shard 7 live from backup 20211115T072855Z.s7.tar.gz
2021/11/15 07:35:42 Restoring shard 8 live from backup 20211115T072855Z.s8.tar.gz
2021/11/15 07:35:42 Restoring shard 6 live from backup 20211115T072855Z.s6.tar.gz

Retention Policy 보존 정책

> show retention policies on exemDB
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        true


> create retention policy my_rp on exemDB duration 365d replication 1 shard duration 2w default
> show retention policies on exemDB
name    duration  shardGroupDuration replicaN default
----    --------  ------------------ -------- -------
autogen 0s        168h0m0s           1        false
my_rp   8760h0m0s 336h0m0s           1        true

> alter retention policy my_rp on exemDB duration 4w
> show retention policies on exemDB
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        false
my_rp   672h0m0s 336h0m0s           1        true

> drop retention policy my_rp on exemDB
> show retention policies on exemDB
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        false

> alter retention policy autogen on exemDB default
> show retention policies on exemDB
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        true
  • name: autogen 기본 정책
  • duration: 0s 삭제없이 영원히 데이터 보관
  • ShardGroupDurtaion : 168h 7일 샤드그룹에의해 보호되는 시간범위
  • replicaN: 1 클러스터에 저장된 데이터의 복사본 수이지만, 단일서버이므로 1
  • default: True

분할

Vertical Partitioning

No Image
  • 도메인에 따라 쉽게 분리할 수 있습니다.
  • 도메인에 영향을 많이 받기 때문에 대부분 application level에서 CRUD를 구현합니다.

Horizontal Partitioning

No Image

샤딩(Sharding)

Database의 샤딩(Sharding)이란?

데이터베이스의 수평 분할
개개의 파티션은 Shard라 부른다.
개개의 데이터베이스 서버 인스턴스에서 부하 분산을 위해 각 shard룰 보유하고 있다.

No Image
  • 같은 테이블 스키마를 가진 데이터를 다수의 데이터베이스에 분산하여 저장하는 방법을 의미합니다.
  • application level에서도 가능하지만 database level에서도 가능합니다.
  • Horizontal Partitioning이라고 볼 수 있습니다.

grafana

Categories: Influxdb

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x