전체 keyspace를 덤프뜨려면 다음과 같이 진행한다.
$ ./bin/cqlsh -e "desc schema"
CREATE KEYSPACE users WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
CREATE TABLE users. follow_relation (
...
}
파일로 저장하려면 다음과 같이 진행한다.
$ ./bin/cqlsh -e "desc schema" > schema.cql
특정 keyspace만 파일로 저장하려면 다음과 같이 진행한다.
$ ./bin/cqlsh -e "desc keyspace my_status" > my_status.cql
$ cat schema.cql
CREATE KEYSPACE my_status WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
CREATE TABLE my_status.follow_relation (
followed_username text,
follower_username text,
....
}
생성된 keyspace 파일을 import하는 방법은 cqlsh에 들어가서 source 명령을 사용하면 된다.
$./bin/cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> source 'schema.cql'
cqlsh> use my_status;
cqlsh:my_status> describe my_status;
'cassandra' 카테고리의 다른 글
| [cassandra] node local의 의미 (0) | 2017.08.10 |
|---|---|
| [cassandra3] select now() (0) | 2017.08.09 |
| [cassandra3] schema 백업(backup)/복구(restore)하기 (0) | 2017.08.08 |
| [cassandra3] Cannot page queries with both ORDER BY and a IN restriction on the partition key; you must either remove the ORDER BY or the IN and sort client side, or disable paging for this query 해결하기 (0) | 2017.08.08 |
| [cassandra3] 복합 기본 키(compound primary key) (0) | 2017.07.06 |
| cassandra의 라이브러리를 사용한 UUID version1 테스트 (0) | 2017.07.06 |



댓글을 달아 주세요