cassandra分布式安装,
1.下载 cassandra 建议安装镜像文件 wget http://mirror.bit.edu.cn/apache/cassandra/2.2.3/apache-cassandra-2.2.3-bin.tar.gz; 2.解压文件 tar -zxvf apache-cassandra-2.2.3-bin.tar.gz 3. 修改配置文件 cassandra安装路径下 /conf/cassandra.yaml 配置项如下: 1> cluster_name: '集群名称Cluster' 2> data_file_directories: - /path/cassandra/data ---数据文件存储位置 3> commitlog_directory: /path/cassandra/commitlog -- commitlog文件存储位置 4> saved_caches_directory: /path/cassandra/saved_caches ---saved_caches 存储位置 5> seed_provider: # Addresses of hosts that are deemed contact points. # Cassandra nodes use this list of hosts to find each other and learn # the topology of the ring. You must change this if you are running # multiple nodes! - class_name: org.apache.cassandra.locator.SimpleSeedProvider parameters: # seeds is actually a comma-delimited list of addresses. # Ex: "<ip1>,<ip2>,<ip3>" - seeds: "192.168.1.10" ---配置集群的masterIP,可以设置多个 6>listen_address: 192.168.1.10 ---配置当前机器的IP,如果是 slave机器就配置slave机器IP,matser就配置 matserIP 4.拷贝配置好的包分别到机器的机器里面 在分布式中分别在安装包的 bin目录下启动 ./cassandra -f & 如果要执行 cql 功能,类似 sql ./cqlsh Ip(分布式需要IP,其他的不需要) cql操作的基本语法 创建 keysapceCREATE KEYSPACE Excelsior
WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
CREATE KEYSPACE Excalibur
WITH replication = {'class': 'NetworkTopologyStrategy', 'DC1' : 1, 'DC2' : 3}
AND durable_writes = false;
删除 keyspace
DROP KEYSPACE myApp;
创建表
CREATE TABLE
Excelsior.
test(
pk int,
t text,
v text,
s text
PRIMARY KEY (pk)
)
创建索引
create index test (t);
删除索引
DROP INDEX userIndex; DROP INDEX userkeyspace.address_index;
新增数据
INSERT INTO test(pk, t, v, s) VALUES (0, 0, 'val0', 'static0');
具体的操作请网上搜索
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。