欢迎投稿

今日深度:

Cassandra安装,

Cassandra安装,


Cassandra Installation

Intruduction

The Apache Cassandra database is the right choice when you need scalability and high availability without compromising performance. Linear scalability and proven fault-tolerance on commodity hardware or cloud infrastructure make it the perfect platform for mission-critical data. Cassandra's support for replicating across multiple datacenters is best-in-class, providing lower latency for your users and the peace of mind of knowing that you can survive regional outages.

 

Installing Cassandra

Prerequisites

Install JDK1.8

Download JDK from Oracle. The url is https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Unzip tar to an indicated directory such as /usr/local, configure JAVA_HOME and PATH, then verify java installation.

# java -version

If print out the following, it is a proof of successful installation.

java version "1.8.0_191"

Java(TM) SE Runtime Environment (build 1.8.0_191-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

 

Install Cassandra

Download Cassandra. The url is http://www.apache.org/dyn/closer.lua/cassandra/3.11.3/apache-cassandra-3.11.3-bin.tar.gz.

Unzip apache-cassandra-3.11.3-bin.tar.gz.

# tar zxvf apache-cassandra-3.11.3-bin.tar.gz

 

Run Cassandra

Enter into cassandra’s bin directory and execute cassandra with parameter -f -R, just like follows.

$./cassandra -f -R

Note that -f parameter means cassandra progress running in the foreground. If run with root, you have to use the parameter.

 

Inserting and querying

cqlsh is a command line shell for interacting with Cassandra through CQL. It is shipped with every Cassandra package, and can be found in the bin/ directory alongside the cassandra executable. It connects to the single node specified on the command line. For example:

$ bin/cqlsh localhost

Connected to Test Cluster at localhost:9042.

[cqlsh 5.0.1 | Cassandra 3.8 | CQL spec 3.4.2 | Native protocol v4]

Use HELP for help.

cqlsh> SELECT cluster_name, listen_address FROM system.local;

 

 cluster_name | listen_address

--------------+----------------

 Test Cluster |      127.0.0.1

 

(1 rows)

cqlsh>

 

 

Command

Create keyspace, for example:

CREATE KEYSPACE yourKeyspaceName WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1};

Note that replication_factor is used to indicate replication number. 1 means there will be only one replication.

 

Create table, for example:

CREATE TABLE CMAX_ADMX_Users (
    userid varchar primary key,
    password varchar,
    userGroup varchar,
    status varchar,
    registrationDate timestamp,
    expiryDate timestamp,
    lockCounter int
);

 

Insert data into table, for example:

insert into CMAX_ADMX_Users(userid, password, userGroup)

values('omo', '47d3870b12334fd498ff0d95c7421ac2', 'CMAX');

 

Show keyspace, for example:

describe keyspaces;

 

Show tables, for example:

describe tables;

 

Show table details, for example:

describe table tablename;

 

 

Troubles

  • When you create keyspace with the follow, CREATE KEYSPACE gui WITH replication = {'class': 'NetworkTopologyStrategy', 'SB KIC': '3'}  AND durable_writes = true, you may encounter an error like this NoHostAvailable. The answer is when creating, pls use correct parameters like WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 1}.

www.htsjk.Com true http://www.htsjk.com/cassandra/32540.html NewsArticle Cassandra安装, Cassandra Installation Intruduction The Apache Cassandra database is the right choice when you need scalability and high availability without compromising performance. Linear scalability and proven fault-tolerance on co...
相关文章
    暂无相关文章
评论暂时关闭