Skip to content

Instantly share code, notes, and snippets.

@bassaer
Last active October 20, 2018 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bassaer/3b333bee706be64caa0ca26215ec399b to your computer and use it in GitHub Desktop.
Save bassaer/3b333bee706be64caa0ca26215ec399b to your computer and use it in GitHub Desktop.
cassandraセットアップメモ ref: https://qiita.com/bassaer/items/caaa4e78f98040e87c93
#start_rpc: false
start_rpc: true
#rpc_address: localhost
rpc_address: 192.168.33.10
❯ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
❯ wget http://archive.apache.org/dist/cassandra/3.11.1/apache-cassandra-3.11.1-bin.tar.gz
cqlsh:mykeyspace> CREATE INDEX ON users (lname);
cqlsh:mykeyspace> SELECT * FROM users WHERE lname = 'smith';
user_id | fname | lname
---------+-------+-------
1745 | john | smith
1746 | john | smith
(2 rows)
❯ cqlsh 192.168.33.10
Connection error: ('Unable to connect to any servers', {'192.168.33.10': error(61, "Tried connecting to [('192.168.33.10', 9042)]. Last error: Connection refused")})
❯ cqlsh 192.168.33.10
Connected to Test Cluster at 192.168.33.10:9042.
[cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>
❯ tar xzvf apache-cassandra-3.11.1-bin.tar.gz
apache-cassandra-3.11.1/bin/
apache-cassandra-3.11.1/conf/
apache-cassandra-3.11.1/conf/triggers/
...
❯ cd apache-cassandra-3.11.1
~/apache-cassandra-3.11.1 localhost.localdomain
❯ ll
合計 488K
drwxr-xr-x. 2 vagrant vagrant 4.0K 10月 1 01:10 bin
drwxr-xr-x. 3 vagrant vagrant 4.0K 10月 1 01:10 conf
drwxr-xr-x. 4 vagrant vagrant 45 10月 1 01:10 doc
drwxr-xr-x. 2 vagrant vagrant 30 10月 1 01:10 interface
drwxr-xr-x. 3 vagrant vagrant 4.0K 10月 1 01:10 javadoc
drwxr-xr-x. 4 vagrant vagrant 4.0K 10月 1 01:10 lib
drwxr-xr-x. 3 vagrant vagrant 38 10月 1 01:10 pylib
drwxr-xr-x. 4 vagrant vagrant 135 10月 1 01:10 tools
-rw-r--r--. 1 vagrant vagrant 347K 10月 3 2017 CHANGES.txt
-rw-r--r--. 1 vagrant vagrant 12K 10月 3 2017 LICENSE.txt
-rw-r--r--. 1 vagrant vagrant 105K 10月 3 2017 NEWS.txt
-rw-r--r--. 1 vagrant vagrant 2.8K 10月 3 2017 NOTICE.txt
~/apache-cassandra-3.11.1 localhost.localdomain
❯ bin/cassandra -f
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
...
❯ bin/cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>
cqlsh> CREATE KEYSPACE mykeyspace
... WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
cqlsh> USE mykeyspace;
cqlsh:mykeyspace>
cqlsh:mykeyspace> CREATE TABLE users (
... user_id int PRIMARY KEY,
... fname text,
... lname text
... );
cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname)
... VALUES (1745, 'john', 'smith');
cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname)
... VALUES (1744, 'john', 'doe');
cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname)
... VALUES (1746, 'john', 'smith');
cqlsh:mykeyspace> SELECT * FROM users;
user_id | fname | lname
---------+-------+-------
1745 | john | smith
1744 | john | doe
1746 | john | smith
(3 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment