Because of the Cassandra non-relational database used in the work, summarize common operations. Cassandra is written in the Java language, so you first need to install the JDK before you install it. The version you use is apache-cassandra-2.1.11-bin.tar.gz and installed on Ubuntu 12.04. Because at present only in the single machine above the experiment, so the cluster part after finishing.
1. Cassandra Installation and Configuration
(1) ~/.BASHRC environment variable configuration
Export cassandra_home=/usr/local/cassandra/apache-cassandra-2.1.11
Export Path=${cassandra_home}/bin: $PATH
(2) Modify the Cassandra configuration file
The CASSANDRA configuration file is $cassandra_home/conf/cassandra.yaml as follows:
- Default cluster Name (cluster_name): ' Test cluster '
- Default cache file storage path (saved_caches_directory): $CASSANDRA _home/data/saved_caches
- Default data file storage path (data_file_directories): $CASSANDRA _home/data/data
- Default Commitlog storage Path (commitlog_directory): $CASSANDRA _home/data/commitlog
- Default Cassandra Service address (rpc_address): localhost
- Default Cassandra Service port (rpc_port): 9160
- Default CQL Local Service port (native_transport_port): 9042
Description: Use all default configuration options.
(3) Modify Cassandra User name and password
- Modify the Authenticator:allowallauthenticator in the configuration file Cassandra.yaml to Authenticator:passwordauthenticator.
- Start the default account./cqlsh-ucassandra-pcassandra, create user SSW with password ' 913292836 ' Superuser;
- Delete the default account drop user Cassandra, and then sign in with your new account and password.
2. Cassandra Basic operation
The keyspace in Cassandra equivalent to the Database,column family of the relational database is the table.
(1) Create Keyspace
CREATE with REPLICATION = {'class'simplestrategy'replication_ Factor'1 };
(2) CREATE table
CREATE TABLE text PRIMARY KEY Count int);
(3) Inserting data
INSERT into Count VALUES ('foo'); INSERT into Count VALUES ('bar');
(4) Finding data
SELECT * from words;
Look for the results as follows:
Description: Your focus is on the interoperability of Spark rdds and Cassandra tables.
Reference documents:
[1] How to install and configure cassandra:http://www.cnblogs.com/gpcuster/archive/2010/03/25/1695490.html
[2] How to set Cassandra User name and password: http://zhaoyanblog.com/archives/307.html
[3] Distributed Key-value Storage System: Cassandra Introduction: http://www.ibm.com/developerworks/cn/opensource/os-cn-cassandra/
[4] Cassandra Query Language (CQL) v3.2.0:http://cassandra.apache.org/doc/cql3/cql-2.1.html
[5] Cassandra Study guide: http://heipark.iteye.com/blog/1902918
[6] DataStax Spark Cassandra connector:https://github.com/datastax/spark-cassandra-connector
Cassandra Non-relational database