设为首页 加入收藏

TOP

Sequoiadb测试体验系列之六?Java开发3(二)
2015-07-24 10:26:58 来源: 作者: 【 】 浏览:2
Tags:Sequoiadb 测试 体验 系列 Java 开发
的复制组内添加三个主节点,数据组自动选举出新的主节点,停止主节点后,复制组内重新选举新的主节点。

运行以上代码后的结果是:

The replica groups are SYSCatalogGroup, datagroup, testRG, 
There are 3 replica groups in total.
Removing the old replica group...
The replica groups are SYSCatalogGroup, datagroup, 
There are 2 replica groups in total.
Adding the new replica group...
The replica groups are SYSCatalogGroup, datagroup, testRG, 
There are 3 replica groups in total.
Tere are 0 nodes in the group.
starting the node 50000...
starting the node 50010...
starting the node 50020...
Tere are 3 nodes in the group.
The master node is 50000
The slave node is 50010
stoping the master node...
re-selecting the master node...
The master node is 50020
可以看出,程序开始运行时,数据库内有三个复制组,其中testRG是上次运行遗留下来的无用复制组,另外两个是数据库默认的两个复制组。通过removeReplicaGroup()方法删除多余的testRG复制组,之后通过createReplicaGroup()添加新的testRG复制组,并且在新建的组内通过createNode()和start()添加并启动50000,50010,50020三个新的节点。通过getMaster()和getSlave()方法获取组内的主从节点,并利用stop()停止主节点50000,主节点完全停止后,组内将重新自动选举出新的主节点50020。

运行完成后,通过shell控制台查看数据库testRG复制组的详细情况:

>rg.getDetail()
{
  "Group": [
    {
      "HostName": "sdbserver1",
      "dbpath": "/opt/sequoiadb/database/test/50000",
      "Service": [
        {
          "Type": 0,
          "Name": "50000"
        },
        {
          "Type": 1,
          "Name": "50001"
        },
        {
          "Type": 2,
          "Name": "50002"
        }
      ],
      "NodeID": 1053
    },
    {
      "HostName": "sdbserver1",
      "dbpath": "/opt/sequoiadb/database/test/50010",
      "Service": [
        {
          "Type": 0,
          "Name": "50010"
        },
        {
          "Type": 1,
          "Name": "50011"
        },
        {
          "Type": 2,
          "Name": "50012"
        }
      ],
      "NodeID": 1054
    },
    {
      "HostName": "sdbserver1",
      "dbpath": "/opt/sequoiadb/database/test/50020",
      "Service": [
        {
          "Type": 0,
          "Name": "50020"
        },
        {
          "Type": 1,
          "Name": "50021"
        },
        {
          "Type": 2,
          "Name": "50022"
        }
      ],
      "NodeID": 1055
    }
  ],
  "GroupID": 1023,
  "GroupName": "testRG",
  "PrimaryNode": 1055,
  "Role": 0,
  "Status": 0,
  "Version": 4,
  "_id": {
    "$oid": "53d9d38e14a63a88c621edd8"
  }
}
Return 1 row(s).
Takes 0.4716s.
可以看出组内有三个节点,主节点(PrimaryNode)为1055,也就是50020。
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇c#程序中使用"like“查询acc.. 下一篇表结构变更后出现的ERROROGG-0116..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·bios设置按什么选择 (2025-12-26 17:20:08)
·知乎 - 知乎 (2025-12-26 17:20:04)
·http://和www.前缀网 (2025-12-26 17:20:01)
·Python爬虫教程(从 (2025-12-26 16:49:14)
·【全269集】B站最详 (2025-12-26 16:49:11)