SequoiaDB資料庫之資料庫的配置與啟動

buptdream發表於2013-11-26

1.1    獨立模式下的配置和啟動

         1: 進入/opt/sequpiadb/目錄以sdbadmin使用者進行安裝:

sdbserver1:~ # cd /opt/sequoiadb/

sdbserver1:/opt/sequoiadb # su sdbadmin

sdbadmin@sdbserver1:~> cd /opt/sequoiadb/

sdbadmin@sdbserver1:~> ls

bin   doc      java  license  sequoiadb  uninstall      www

conf  include  lib   samples  tools      uninstall.dat

2:建立配置檔案存放目錄

sdbadmin@sdbserver1:~> mkdir -p /opt/sequoiadb/conf/local/50000

注意:官方文件上出現的#P,應該為-P

         3:拷貝獨立模式的配置

sdbadmin@sdbserver1:~>cp /opt/sequoiadb/conf/samples/sdb.conf.standalone  /opt/sequoiadb/conf/local/50000/sdb.conf

         4:修改配置檔案

sdbadmin@sdbserver1:~> vi /opt/sequoiadb/conf/local/50000/sdb.conf

 

# SequoiaDB configuration

 

# configure file path

# confpath=

 

# log file path

# logpath=

 

# diagnostic log file path

# diagpath=

 

# database path

dbpath=/opt/sequoiadb/database/standalone

 

# index path

# indexpath=

 

# backup path

# bkuppath=

 

# max pooled agent

maxpool=100

 

"conf/local/50000/sdb.conf" 65L, 893C written

5:建立上面配置檔案中dbpath指向的檔案存放地址

sdbadmin@sdbserver1:~> mkdir -p /opt/sequoiadb/database/standalone

6:啟動資料庫程式

sdbadmin@sdbserver1:~>/opt/sequoiadb/bin/sdbstart -c /opt/sequoiadb/conf/local/50000

Success: SequoiaDB engine is successfully started (9114)

7shell測試

sdbadmin@sdbserver1:~> cd /opt/sequoiadb/bin/

sdbadmin@sdbserver1:~/bin> ./sdb

Welcome to SequoiaDB shell!

help() for help, Ctrl+c or quit to exit

> help

function () {

    println("   var db = new Sdb('localhost', 50000)   connect to database");

    println("   db.help()                              help on db methods");

    println("   db.cs.help()                           help on collection space cs");

    println("   db.cs.cl                               access collection cl on collection space cs");

    println("   db.cs.cl.help()                        help on collection cl");

    println("   db.cs.cl.find()                        list all records");

    println("   db.cs.cl.find({a:1})                   list records where a=1");

    println("   print(x), println(x)                   print out x");

    println("   traceFmt(,,)            format trace input(in) to output(out) by type");

    println("   getErr(ret)                            print error description for return code");

    println("   quit                                   exit");

}

Takes 0.394s.

> x=100

100

Takes 0.228s.

> x/10

10

Takes 0.140s.

> new Date()

Mon Oct 28 2013 15:18:11 GMT+0800 (CST)

Takes 0.315s.

 

 

 

8:訪問監控頁面如下:

2.1    叢集模式的配置與啟動

三臺伺服器的分佈如下:

192.168.25.151  sdbserver1

192.168.25.152  sdbserver2

192.168.25.153  sdbserver3

採用三臺伺服器進行搭建叢集模式。在叢集模式中,至少需要三個節點。在叢集環境下,sequoiaDB需要三種角色的節點,分佈為:資料節點,編目節點,協調節點。叢集模式的最小配置中,每種角色的節點至少啟動一個,才能構成完整的叢集模式。

叢集模式中客戶端或應用程式直接連線到協調節點,其餘資料節點與編目節點對應用程式完全透明。應用程式本身不需關心資料存放在哪個資料節點,協調節點會對接收到的請求解析,自動將其傳送到需要的資料節點上進行處理。

在叢集模式下,資料分割槽之間的資料無共享,資料分割槽內的節點間進行非同步資料複製,保證資料的最終一致性。這一點和ORACLE RAC是不一樣的,oracle是多個節點共享一份資料。在資料安全性來說,資料多份存放是很安全的一種方式。

 

1:檢查每臺伺服器上上的sdbcm狀態,保證每臺伺服器都正常安裝軟體:

sdbserver1:/ # service sdbcm status

sdbcm.service - LSB: Example initscript

          Loaded: loaded (/etc/init.d/sdbcm)

          Active: active (exited) since Mon, 2013-10-28 15:55:56 CST; 2s ago

         Process: 10104 ExecStop=/etc/init.d/sdbcm stop (code=exited, status=0/SUCCESS)

         Process: 10109 ExecStart=/etc/init.d/sdbcm start (code=exited, status=0/SUCCESS)

          CGroup: name=systemd:/system/sdbcm.service

 

Oct 28 15:55:53 sdbserver1 systemd[1]: Starting LSB: Example initscript...

Oct 28 15:55:53 sdbserver1 su[10110]: (to sdbadmin) root on none

Oct 28 15:55:53 sdbserver1 su[10110]: pam_unix(su-l:session): session opene...0)

Oct 28 15:55:55 sdbserver1 sdbcm[10109]: Starting sequoiadb databse service:...)

Oct 28 15:55:56 sdbserver1 sdbcm[10109]: Successful to start sdbcm

Oct 28 15:55:56 sdbserver1 sdbcm[10109]: .

Oct 28 15:55:56 sdbserver1 systemd[1]: Started LSB: Example initscript.

2:啟動一個協調節點,建立協調節點目錄,埠號設定為50000

sdbserver1:/ # su sdbadmin

sdbadmin@sdbserver1:/> mkdir -p /opt/sequoiadb/conf/local/50000

sdbadmin@sdbserver1:/>cp /opt/sequoiadb/conf/samples/sdb.conf.coord  /opt/sequoiadb/conf/local/50000/sdb.conf

3:修改配置檔案

sdbadmin@sdbserver1:/> vi /opt/sequoiadb/conf/local/50000/sdb.conf

 

# SequoiaDB configuration

 

# configure file path

# confpath=

 

# log file path

# logpath=

 

# diagnostic log file path

# diagpath=

 

# database path

dbpath=/opt/sequoiadb/database/coord

 

# index path

# indexpath=

 

# backup path

# bkuppath=

 

# max pooled agent

maxpool=100

 

"~/conf/local/50000/sdb.conf" 65L, 883C written

4:建立資料檔案存放目錄

sdbadmin@sdbserver1:/> mkdir -p /opt/sequoiadb/database/coord

5:啟動協調節點程式

sdbadmin@sdbserver1:/>/opt/sequoiadb/bin/sdbstart -c /opt/sequoiadb/conf/local/50000/

Success: SequoiaDB engine is successfully started (10201)

6:進入shell終端,建立編目節點組

sdbadmin@sdbserver1:/> /opt/sequoiadb/bin/sdb

Welcome to SequoiaDB shell!

help() for help, Ctrl+c or quit to exit

>  var db = new Sdb("192.168.25.151",50000)

Takes 0.8423s.

> db.createCataRG("sdbserver1", 30000, "/opt/sequoiadb/database/cata/30000")

Takes 7.66259s.

> var catarg = db.getRG("SYSCatalogGroup");

Takes 0.19453s.

>var node1=catarg.createNode("sdbserver2",30000,"/opt/sequoiadb/database/cata/30000")

Takes 0.25331s.

> var node2 = catarg.createNode("sdbserver3", 30000,"/opt/sequoiadb/database/cata/30000")

Takes 0.5964s.

7:啟動編目節點組

> node1.start()

Takes 7.41135s.

> node2.start()

Takes 7.37497s.

8:建立資料節點組

> var datarg = db.createRG("datagroup1")

Takes 0.3216s.

> datarg.createNode("sdbserver1", 51000, "/opt/sequoiadb/database/data/51000")

sdbserver1:51000

Takes 0.26794s.

> datarg.createNode("sdbserver2", 51000,"/opt/sequoiadb/database/data/51000")

sdbserver2:51000

Takes 0.6524s.

> datarg.createNode("sdbserver3", 51000, "/opt/sequoiadb/database/data/51000")

sdbserver3:51000

Takes 0.5700s.

9:啟動資料節點組

> datarg.start()

Takes 15.4294625759s.

 

10:在其他兩臺伺服器上建立協調節點,建立協調節點目錄,拷貝樣本配置檔案

sdbserver2:/ # mkdir -p /opt/sequoiadb/conf/local/50000

sdbserver2:/#cp/opt/sequoiadb/conf/samples/sdb.conf.coord /opt/sequoiadb/conf/local/50000/sdb.conf

11:編輯檔案

sdbserver2:/ # vi /opt/sequoiadb/conf/local/50000/sdb.conf

 

# SequoiaDB configuration

 

# configure file path

# confpath=

 

# log file path

# logpath=

 

# diagnostic log file path

# diagpath=

 

# database path

dbpath=/opt/sequoiadb/database/coord

 

# index path

# indexpath=

 

# backup path

# bkuppath=

 

# max pooled agent

maxpool=100

 

# local service name or port

svcname=50000

 

# replication service name or port

replname=50001

 

# sharding service name or port

shardname=50002

 

# catalog service name or port

catalogname=50003

 

# RESTful service name or port

httpname=50004

 

# diag level (0-5)

diaglevel=3

 

# role of the node (data/coord/catalog/standalone)

role=coord

 

# catalog addr (hostname1:servicename1,hostname2:servicename2,...)

catalogaddr=sdbserver1:30003,sdbserver2:30003,sdbserver3:30003

 

# group id

# groupid=

 

"/opt/sequoiadb/conf/local/50000/sdb.conf" 65L, 931C written 

對上面catalogaddr中的伺服器名稱進行新增伺服器地址和埠,請使用hosts檔案中的名稱。

12:建立資料檔案存放目錄

sdbserver2:/ # mkdir -p /opt/sequoiadb/database/coord

13:啟動協調節點程式

sdbserver2:/ # /opt/sequoiadb/bin/sdbstart -c /opt/sequoiadb/conf/local/50000/

Success: SequoiaDB engine is successfully started (9761)

sdbserver2:/ #

10步驟開始,在另外一臺伺服器上進行安裝協調節點

安裝好後,在監控web介面可以看到如下介面,三臺伺服器節點已經可以在web中看到。

   

在整個過程中,建立了兩個邏輯組,具體邏輯組的概念可以參考官方文件。
 

在監控中,可以看到資料檢視和實時檢視的變化,可以時刻看到這些資料的變化。







採用shell檢視配置的節點資訊如下:

sdbserver1:~ # /opt/sequoiadb/bin/sdb

Welcome to SequoiaDB shell!

help() for help, Ctrl+c or quit to exit

> var db = new Sdb("192.168.25.151",50000)

Takes 0.8264s.

Takes 0.7635s.

> db.listReplicaGroups();

{

  "Group": [

    {

      "dbpath": "/opt/sequoiadb/database/cata/30000",

      "HostName": "sdbserver1",

      "Service": [

        {

          "Type": 0,

          "Name": "30000"

        },

        {

          "Type": 1,

          "Name": "30001"

        },

        {

          "Type": 2,

          "Name": "30002"

        },

        {

          "Type": 3,

          "Name": "30003"

        }

      ],

      "NodeID": 1

    },

    {

      "HostName": "sdbserver2",

      "dbpath": "/opt/sequoiadb/database/cata/30000",

      "Service": [

        {

          "Type": 0,

          "Name": "30000"

        },

        {

          "Type": 1,

          "Name": "30001"

        },

        {

          "Type": 2,

          "Name": "30002"

        },

        {

          "Type": 3,

          "Name": "30003"

        }

      ],

      "NodeID": 4

    },

    {

      "HostName": "sdbserver3",

      "dbpath": "/opt/sequoiadb/database/cata/30000",

      "Service": [

        {

          "Type": 0,

          "Name": "30000"

        },

        {

          "Type": 1,

          "Name": "30001"

        },

        {

          "Type": 2,

          "Name": "30002"

        },

        {

          "Type": 3,

          "Name": "30003"

        }

      ],

      "NodeID": 5

    }

  ],

  "GroupID": 1,

  "GroupName": "SYSCatalogGroup",

  "PrimaryNode": 1,

  "Role": 2,

  "Status": 1,

  "Version": 7,

  "_id": {

    "$oid": "526e1ae519b8314ddc83b1f4"

  }

}

{

  "Group": [

    {

      "HostName": "sdbserver1",

      "dbpath": "/opt/sequoiadb/database/data/51000",

      "Service": [

        {

          "Type": 0,

          "Name": "51000"

        },

        {

          "Type": 1,

          "Name": "51001"

        },

        {

          "Type": 2,

          "Name": "51002"

        }

      ],

      "NodeID": 1000

    },

    {

      "HostName": "sdbserver2",

      "dbpath": "/opt/sequoiadb/database/data/51000",

      "Service": [

        {

          "Type": 0,

          "Name": "51000"

        },

        {

          "Type": 1,

          "Name": "51001"

        },

        {

          "Type": 2,

          "Name": "51002"

        }

      ],

      "NodeID": 1001

    },

    {

      "HostName": "sdbserver3",

      "dbpath": "/opt/sequoiadb/database/data/51000",

      "Service": [

        {

          "Type": 0,

          "Name": "51000"

        },

        {

          "Type": 1,

          "Name": "51001"

        },

        {

          "Type": 2,

          "Name": "51002"

        }

      ],

      "NodeID": 1002

    }

  ],

  "GroupID": 1000,

  "GroupName": "datagroup1",

  "PrimaryNode": 1002,

  "Role": 0,

  "Status": 1,

  "Version": 4,

  "_id": {

    "$oid": "526e1d4519b8314ddc83b1f5"

  }

}

Return 2 row(s).

Takes 0.25536s.


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10701850/viewspace-1061116/,如需轉載,請註明出處,否則將追究法律責任。

相關文章