Linux Cassandra配置和管理平台使用,配置好jdk1.6以上版本的环境安装后查看java版本,必须是java version quot;1.6.0_24quot;
贴一个配置 使用cassandra的实际例子
1.配置好jdk1.6以上版本的环境
安装后查看java版本,必须是java version "1.6.0_24" 以上,不然在启动时会报类似out of memory的错误
2.新建日志等目录并解压缩
mkdir -p /var/log/cassandra
mkdir -p /var/lib/cassandra
tar zxvf apache-cassandra-0.8.6-bin.tar.gz
3.启动
cd bin
nohup ./cassandra -f &
查看127.0.0.1:9106启动没有
4.连接
./cassandra-cli
connect localhost/9160 ---也可连接其他主机
5.查看信息
show cluster name;
6.创建keyspace
CREATE KEYSPACE demo
with placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy'
and strategy_optiOns= [{replication_factor:1}];
use demo
7.创建列族
create column family users with comparator = UTF8Type AND key_validation_class=UTF8Type AND column_metadata = [{column_name: full_name, validation_class: UTF8Type} {column_name: email, validation_class: UTF8Type}];
查看列;族信息
describe keyspace demo;
8.读写数据
写入数据
SET users['bobbyjo']['full_name']='Robert Jones';
SET users['bobbyjo']['email']='bobjones@gmail.com';
set Manager['pig']['big']='234';
确认写入
count users['bobbyjo'];
2 columns
读取数据
get users['bobbyjo'];
=> (column=email, value=bobjones@gmail.com, timestamp=1318176737871000)
=> (column=full_name, value=Robert Jones, timestamp=1318176726678000)
Returned 2 results.
删除数据 --bobbyjo的行键值的email列
del users['bobbyjo'][email];
column removed.
del users['bobbyjo']--删除行,,没指定列名字
管理机器软件:
Cassandra-Cluster-Admin,通过web方式管理数据库.部署简单 使用方便.