ITeye博客

cassandra分布式安装

windowboy · 2015-11-03 20:01 · 大数据 · 数据库 · Markdown

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操作的基本语法

 

创建 keysapce

CREATE 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');

具体的操作请网上搜索

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。