Difference between revisions of "Cassandra"
(Created page with "# Install Via Kubernetes https://docs.portworx.com/portworx-install-with-kubernetes/application-install-with-kubernetes/cassandra/#installation # Install Centos7 https://www...") |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | # Commands | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | sudo nodetool status | ||
| + | cqlsh | ||
| + | </syntaxhighlight> | ||
| + | |||
# Install Via Kubernetes | # Install Via Kubernetes | ||
| − | https://docs.portworx.com/portworx-install-with-kubernetes/application-install-with-kubernetes/cassandra/#installation | + | - https://docs.portworx.com/portworx-install-with-kubernetes/application-install-with-kubernetes/cassandra/#installation |
| + | - https://kubernetes.io/docs/tutorials/stateful-application/cassandra/ | ||
# Install Centos7 | # Install Centos7 | ||
| + | |||
| + | http://cassandra.apache.org/download/ | ||
| + | |||
| + | or using datastax distro | ||
https://www.howtoforge.com/tutorial/how-to-install-cassandra-database-on-centos-7/ | https://www.howtoforge.com/tutorial/how-to-install-cassandra-database-on-centos-7/ | ||
| + | |||
| + | |||
| + | # Cheat Sheet | ||
| + | |||
| + | http://codefoundries.com/developer/cassandra/cassandra-cheatsheet.html | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | DESCRIBE keyspaces; | ||
| + | Detailed list of databases | ||
| + | |||
| + | SELECT * FROM system_schema.keyspaces; | ||
| + | Create database rebar suitable for development: | ||
| + | |||
| + | CREATE KEYSPACE rebar | ||
| + | WITH replication = { | ||
| + | 'class':'SimpleStrategy', | ||
| + | 'replication_factor' : 1 | ||
| + | }; | ||
| + | Switch to database rebar: | ||
| + | |||
| + | USE rebar; | ||
| + | List of tables: | ||
| + | |||
| + | DESCRIBE tables; | ||
| + | List of columns in a table User in database rebar: | ||
| + | |||
| + | SELECT * FROM system.schema_columns | ||
| + | WHERE keyspace_name = 'rebar' | ||
| + | AND columnfamily_name = 'User'; | ||
| + | MANAGE TABLES | ||
| + | Create a table: | ||
| + | |||
| + | CREATE TABLE User( | ||
| + | id uuid PRIMARY KEY, | ||
| + | username varchar, | ||
| + | password varchar, | ||
| + | displayname varchar, | ||
| + | email varchar, | ||
| + | ); | ||
| + | Create an index on a column: | ||
| + | |||
| + | CREATE INDEX User_username_ix | ||
| + | ON User( username ); | ||
| + | List details for table rebar: | ||
| + | |||
| + | DESCRIBE TABLE rebar; | ||
| + | MANAGE DATA | ||
| + | Insert a record into a table with auto-generated UUID: | ||
| + | |||
| + | insert into User( id, username, password, displayName, email ) | ||
| + | values( uuid(), 'jack', 'secret', 'Jack', 'jack@example.com' ); | ||
| + | Insert a record into a table with given UUID: | ||
| + | |||
| + | insert into User( id, | ||
| + | username, password, displayName, email | ||
| + | ) | ||
| + | values( d362e1df-1fa8-466b-b311-af90b2a71e8e, | ||
| + | 'jack', 'secret', 'Jack Myuser', 'jack@example.com' | ||
| + | ); | ||
| + | DATA TYPES | ||
| + | Type Description | ||
| + | ascii ASCII character string | ||
| + | bigint 8-byte long | ||
| + | blob Arbitrary bytes (no validation) | ||
| + | boolean true or false | ||
| + | counter Counter column (8-byte long) | ||
| + | decimal Variable-precision decimal | ||
| + | double 8-byte floating point | ||
| + | float 4-byte floating point | ||
| + | int 4-byte integer | ||
| + | text UTF8 encoded string | ||
| + | timestamp Date plus time, encoded as 8 bytes since epoch | ||
| + | uuid Type 1, or type 4 UUID | ||
| + | varchar UTF8 encoded string | ||
| + | varint Arbitrary-precision integer | ||
| + | </syntaxhighlight> | ||
Latest revision as of 14:59, 18 April 2021
Commands
Install Via Kubernetes
- https://docs.portworx.com/portworx-install-with-kubernetes/application-install-with-kubernetes/cassandra/#installation
- https://kubernetes.io/docs/tutorials/stateful-application/cassandra/
Install Centos7
http://cassandra.apache.org/download/
or using datastax distro
https://www.howtoforge.com/tutorial/how-to-install-cassandra-database-on-centos-7/
Cheat Sheet
http://codefoundries.com/developer/cassandra/cassandra-cheatsheet.html
SELECT * FROM system_schema.keyspaces; Create database rebar suitable for development:
CREATE KEYSPACE rebar WITH replication = {
'class':'SimpleStrategy', 'replication_factor' : 1
}; Switch to database rebar:
USE rebar; List of tables:
DESCRIBE tables; List of columns in a table User in database rebar:
SELECT * FROM system.schema_columns WHERE keyspace_name = 'rebar' AND columnfamily_name = 'User'; MANAGE TABLES Create a table:
CREATE TABLE User(
id uuid PRIMARY KEY, username varchar, password varchar, displayname varchar, email varchar,
); Create an index on a column:
CREATE INDEX User_username_ix ON User( username ); List details for table rebar:
DESCRIBE TABLE rebar; MANAGE DATA Insert a record into a table with auto-generated UUID:
insert into User( id, username, password, displayName, email ) values( uuid(), 'jack', 'secret', 'Jack', 'jack@example.com' ); Insert a record into a table with given UUID:
insert into User( id,
username, password, displayName, email
) values( d362e1df-1fa8-466b-b311-af90b2a71e8e,
'jack', 'secret', 'Jack Myuser', 'jack@example.com'
); DATA TYPES Type Description ascii ASCII character string bigint 8-byte long blob Arbitrary bytes (no validation) boolean true or false counter Counter column (8-byte long) decimal Variable-precision decimal double 8-byte floating point float 4-byte floating point int 4-byte integer text UTF8 encoded string timestamp Date plus time, encoded as 8 bytes since epoch uuid Type 1, or type 4 UUID varchar UTF8 encoded string varint Arbitrary-precision integer