Cassandra3简单通讯代码

整理了一下Cassandra3的简单通信代码,包括增删改查。

Continue reading Cassandra3简单通讯代码

Cassandra3基本操作01

1、首先看一下各节点状态

neohope@debian8-node01:~/Deploy/apache-cassandra-3.0.1$ bin/nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address        Load       Tokens       Owns    Host ID                               Rack
UN  172.16.172.23  230.25 KB  256          ?       760879a3-e06b-43bb-97bf-b045a655da9c  rack1
UN  172.16.172.24  237.17 KB  256          ?       5bf3e77d-ccf4-4f81-9465-de0babe1e0cc  rack1
UN  172.16.172.25  241.55 KB  256          ?       5a7ed53f-c8e0-4658-af9a-41880dada5ef  rack1

Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless

2、然后用cqlsh连接cassandra

neohope@debian8-node01:~/Deploy/apache-cassandra-3.0.1$ bin/cqlsh debian8-node01
Connected to NeoCluster at debian8-node01:9042.
[cqlsh 5.0.1 | Cassandra 3.0.1 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.

cqlsh:neokeyspace> help

Documented shell commands:
===========================
CAPTURE  CLS          COPY  DESCRIBE  EXPAND  LOGIN   SERIAL  SOURCE   UNICODE
CLEAR    CONSISTENCY  DESC  EXIT      HELP    PAGING  SHOW    TRACING

CQL help topics:
================
AGGREGATES               CREATE_KEYSPACE           DROP_TRIGGER      TEXT     
ALTER_KEYSPACE           CREATE_MATERIALIZED_VIEW  DROP_TYPE         TIME     
ALTER_MATERIALIZED_VIEW  CREATE_ROLE               DROP_USER         TIMESTAMP
ALTER_TABLE              CREATE_TABLE              FUNCTIONS         TRUNCATE 
ALTER_TYPE               CREATE_TRIGGER            GRANT             TYPES    
ALTER_USER               CREATE_TYPE               INSERT            UPDATE   
APPLY                    CREATE_USER               INSERT_JSON       USE      
ASCII                    DATE                      INT               UUID     
BATCH                    DELETE                    JSON            
BEGIN                    DROP_AGGREGATE            KEYWORDS        
BLOB                     DROP_COLUMNFAMILY         LIST_PERMISSIONS
BOOLEAN                  DROP_FUNCTION             LIST_ROLES      
COUNTER                  DROP_INDEX                LIST_USERS      
CREATE_AGGREGATE         DROP_KEYSPACE             PERMISSIONS     
CREATE_COLUMNFAMILY      DROP_MATERIALIZED_VIEW    REVOKE          
CREATE_FUNCTION          DROP_ROLE                 SELECT          
CREATE_INDEX             DROP_TABLE                SELECT_JSON     

Continue reading Cassandra3基本操作01

搭建Cassandra集群环境

1、环境准备

VirtualBox4
Debian8
JDK8u60
Cassandra3

2、安装虚拟机,安装Guset插件

su
apt-get install gcc
apt-get install linux-headers-$(uname -r)
apt-get install build-essential
./VBoxLinuxAdditions.run

设置共享目录,将需要的文件拷贝到虚拟机。
当然也可以设置好虚拟的的ssh后,用scp或winscp将文件拷贝到虚拟机。

3.网络配置为两块网卡,第一块为Hostonly设为固定IP,第二块为NAT,设置为dhcp
修改配置文件/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 172.16.172.23
netmask 255.255.0.0
gateway 172.16.172.2

auto eth1
iface eth1 inet dhcp

修改hosts文件

#/etc/hosts
127.0.0.1	localhost
172.16.172.23	node01
172.16.172.24	node02
172.16.172.25	node03

修改hostname

#/etc/hostname
node01

根据需要(一般用不到),修改配置文件/etc/resolv.conf

nameserver xxx.xxx.xxx.xxx

重启网卡

su
ifconfig eth0 down
ifconfig eth0 up
ifconfig eth1 down
ifconfig eth1 up

Continue reading 搭建Cassandra集群环境