Chinaunix首页 | 论坛 | 博客
  • 博客访问: 629598
  • 博文数量: 149
  • 博客积分: 3901
  • 博客等级: 中校
  • 技术积分: 1558
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-16 14:33
文章分类

全部博文(149)

文章存档

2014年(2)

2013年(10)

2012年(32)

2011年(21)

2010年(84)

分类:

2010-04-15 12:22:00


Cassandra
Cassandra的主要特点就是它不是一个数据库,而是由一堆数据库节点共同构成的一个分布式网络服务,对Cassandra的一个操作,会 被复制到其他节点上去,对Cassandra的操作,也会被路由到某个节点上面去读取。对于一个Cassandra群集来说,扩展性能是比较简单的事 情,只管在群集里面添加节点就可以了。我看到有文章说Facebook的Cassandra群集有超过100台服务器构成的数据库群集。

本文目的 是 写-复制读-路由 的功能测试

0. 环境
 * java-1.6
 * apache-cassandra-0.6.0
 * 服务器 47 , 207  ( 目前测试服务器少,请大家 谅解。后面后添加多台 测试结果也会完善 )

1. 测试
1.1 配置  (具体 可以 google <安装和配置 Cassandra> )
 * 47 和 207 服务配置都修改 -$> vim conf/storage-conf.xml

1.1.1 配置集群节点信息

<Seeds>
    <Seed>192.168.102.47</Seed>
    <Seed>192.168.102.207</Seed>
</Seeds>
1.1.2 配置集群节点之间交互的监听地址
直接留空即可:
<ListenAddress></ListenAddress>
1.1.3 配置Thrift Server监听的地址
直接留空即可:
<ThriftAddress></ThriftAddress>
1.1.4 配置集群的名称
每一个集群的名称都应该是不用的
<ClusterName>gpcuster.cnblogs.com</ClusterName>
1.1.5 开启节点自动加入集群的功能
<AutoBootstrap>true</AutoBootstrap>
1.1.6 配置数据的备份数 (特别注意这里配置为 1 就是 单机本地存储,其他机器路由取值 )
<ReplicationFactor>1</ReplicationFactor>



1.2 服务启动( 特别注意 : 服务器 的时间 要 同步 date  )
  207-serv$> ./bin/cassandra -f
   47-serv$> ./bin/cassandra -f


1.2.0 先简单的 语法介绍 ( get , set , del )
 set Keyspace1.Standard2['jsmith']['first'] = 'John'
       \            \         \        \          \
        \            \         \_ key   \          \_ value
         \            \                  \_ column
          \_ keyspace  \_ column family

1.3 测试  ( 单机 结果 路由

 1.3.1 客户端启动
  207-cli$>./cassandra-cli --host 192.168.102.207 --port 9160
   47-cli$>./cassandra-cli --host 192.168.102.47 --port 9160

 1.3.2 : 207 insert 数据 ( 207 insert 结果成功! )
  207-cli$> set Keyspace1.Standard2['jsmith']['first'] = 'John'
  207-cli$> get Keyspace1.Standard2['jsmith']['first']        
            => (column=first, value=John, timestamp=1271303623077000)
 1.3.3 47 路由 数据 查看 ( 47 路由 查询 数据成功 )
  47-cli$>  get Keyspace1.Standard2['jsmith']['first']    
           => (column=first, value=John, timestamp=1271303623077000)
 
  207-服务器$> 关闭 207 服务器
  47-cli$>  get Keyspace1.Standard2['jsmith']['first']    
            #已经路由不到 207 取得结果,并且 第一次查询速度非常 慢 ,性能测试有待注意
            Exception null
  207-服务器$> ./bin/cassandra -f  #启动
  207-cli$> # 需要重启 要不,什么都取不到
  47-cli$>  get Keyspace1.Standard2['jsmith']['first']     #又能正常 取得
            => (column=first, value=John, timestamp=1271303623077000)

 1.3.4 47 路由修改 (  成功 )
    47-cli$>  set Keyspace1.Standard2['jsmith']['first'] = 'liukaiyi'
    47-cli$>  get Keyspace1.Standard2['jsmith']['first']
    #如果 2台服务器时间不同步,数据 可能就没有修改 ,根据 timestamp展现最后一条数据
            => (column=first, value=liukaiyi, timestamp=1271303623077000)

1.4 测试  ( 双机 结果 复制
  1.4.1 47 207 都 修改配置 , 配置数据的备份数 (特别注意这里配置为 2 就是都会存 数据)
       <ReplicationFactor>2</ReplicationFactor>
  1.4.2 服务重启启动
  ./bin/cassandra -f
  1.4.3   客户端启动
  207-cli$>./cassandra-cli --host 192.168.102.207 --port 9160
   47-cli$>./cassandra-cli --host 192.168.102.47 --port 9160
  1.4.4   测试
  207-cli$> get Keyspace1.Standard2['jsmith']['first'] 
        => (column=first, value=John, timestamp=1271304586125000)
  47-cli$> get Keyspace1.Standard2['jsmith']['first']   #有一小段等待时间
        => (column=first, value=John, timestamp=1271304586125000)
  207-服务器$> 关闭 207 服务器
  47-cli$> get Keyspace1.Standard2['jsmith']['first']  #结果 还能查询,表明有同步复制
        => (column=first, value=John, timestamp=1271304586125000)
  207-服务器$> ./bin/cassandra -f  #启动

1.4.5 同步修改 (  成功 )
  47-cli$> set Keyspace1.Standard2['jsmith']['first'] = 'liukaiyi'
  47-cli$> get Keyspace1.Standard2['jsmith']['first'] 
        => (column=first, value=liukaiyi, timestamp=1271304586125000)
  207-cli$> set Keyspace1.Standard2['jsmith']['first'] = 'liukaiyi_1'
  47-cli$> get Keyspace1.Standard2['jsmith']['first']  #成功
          => (column=first, value=liukaiyi_1, timestamp=1271305603524000)
*  关闭 207 服务器 ,查询 47  还能查询 。
*  再次修改 first = liukaiyi_2 , 开启 服务 207 ,207 客户端 查询 firest = liukaiyi_2



阅读(1241) | 评论(0) | 转发(0) |
0

上一篇:rsync 使用

下一篇:很好的 nginx ppt

给主人留下些什么吧!~~