mongodb 3.2.10 for windows server 2008 R2 installation

清風艾艾發表於2016-10-21
一、作業系統資訊




二、叢集網路環境測試
224心跳節點

253分片節點

227分片節點


三、叢集環境NTP時鐘檢查

可以看到3個節點的時鐘並不同步,接下來進行NTP時鐘同步
點選windows介面右下角時間

點選更改日期和時間設定


點選Internet時間

點選更改設定

伺服器輸入:NTP伺服器所在機器的IP地址,本叢集選取10.138.2.227作為NTP時鐘伺服器

點選立即更新
NTP時鐘重新同步後:


四、檢查作業系統補丁
    主要檢查系統補丁Windows6.1-KB2577795-x64.msuWindows6.1-KB2731284-v3-x64.msu是否安裝,如果已安裝則跳過,沒有安裝則從微軟官方下載後點選自動安裝。
    注意:這2個補丁集的安裝需要重啟伺服器
   
檢查步驟:
開啟控制皮膚

點選系統和安全

點選檢視已安裝的更新


在“搜尋 已安裝更新”框裡輸入補丁號進行檢視:KB2577795、KB2731284



五、建立軟體安裝目錄

三個節點一致的目錄(開啟cmd直接執行命令即可,記得要檢視是否建立成功):
mkdir –p D:\MongoDB
m
kdir –p D:\mongodata


10.138.2.227
mkdir -p d:\mongodata\rs0-0       
mkdir -p d:\mongodata\rs0-arb
mkdir -p d:\mongodata\rs1-1
mkdir -p d:\mongodata\cfg

 

10.138.2.224
    
mkdir -p D:\MongoDB
    
mkdir -p D:\mongodata\cfg

 

10.138.2.253
    
mkdir -p D:\mongodata\rs0-1
    mkdir -p D:\mongodata\rs1-0
    mkdir -p D:\mongodata\rs1-arb
    
mkdir -p D:\mongodata\cfg

六、三個節點均安裝3.2.10版本的mongodb軟體
    安裝步驟

1、點選mongodb-win32-x86_64-2008plus-ssl-3.2.10-signed.msi安裝包,啟動安裝程式

2、接受許可點選下一步

3、選擇手動安裝custom

4、調整軟體安裝目錄後點選下一步進行安裝


5、點選介面的finish完成安裝

七、配置叢集

1、各分片節點和心跳節點開啟相應的例項程式

10.138.2.227分片操作

開啟例項

d:\MongoDB\Server\3.2\bin\mongod --dbpath d:\mongodata\rs0-0 --replSet rs0 --oplogSize 4096 --port 27011 --directoryperdb  --syncdelay 15

d:\MongoDB\Server\3.2\bin\mongod --dbpath d:\mongodata\rs1-1 --replSet rs1 --oplogSize 4096 --port 27012 --directoryperdb  --syncdelay 15

d:\MongoDB\Server\3.2\bin\mongod --dbpath d:\mongodata\rs0-arb --replSet rs0 --port 27015 --directoryperdb

d:\MongoDB\Server\3.2\bin\mongod --configsvr --replSet configReplSet --port 27001 --dbpath d:\mongodata\cfg


10.138.2.224
心跳節點操作

開啟例項

D:\MongoDB\Server\3.2\bin\mongod --configsvr --replSet configReplSet --port 27001 --dbpath D:\mongodata\cfg

 

10.138.2.253 分片操作

開啟例項

D:\MongoDB\Server\3.2\bin\mongod --dbpath D:\mongodata\rs0-1 --replSet rs0 --oplogSize 4096 --port 27012 --directoryperdb  --syncdelay 15

D:\MongoDB\Server\3.2\bin\mongod --dbpath D:\mongodata\rs1-0 --replSet rs1 --oplogSize 4096 --port 27011 --directoryperdb  --syncdelay 15

D:\MongoDB\Server\3.2\bin\mongod --dbpath D:\mongodata\rs1-arb --replSet rs1 --port 27015 --directoryperdb

D:\MongoDB\Server\3.2\bin\mongod --configsvr --replSet configReplSet --port 27001 --dbpath D:\mongodata\cfg

 

2、透過10.138.2.227節點配置副本集及成員

D:\MongoDB\Server\3.2\bin\mongo 10.138.2.227:27011

use admin

rsconf = { _id: "rs0",members: [ { _id: 0, host: "10.138.2.227:27011" } ] }

rs.initiate(rsconf)

rs.conf()

rs.add("10.138.2.253:27012")

rs.addArb("10.138.2.227:27015")

cfg = rs.conf()

cfg.members[0].priority = 100

cfg.members[1].priority = 1

rs.reconfig(cfg)

exit

#相關操作記錄見第八部分

 

D:\MongoDB\Server\3.2\bin\mongo 10.138.2.253:27011

use admin

rsconf = { _id: "rs1",members: [ { _id: 0, host: "10.138.2.253:27011" } ] }

rs.initiate(rsconf)

rs.conf()

rs.add("10.138.2.227:27012")

rs.addArb("10.138.2.253:27015")

cfg = rs.conf()

cfg.members[0].priority = 100

cfg.members[1].priority = 1

rs.reconfig(cfg)

exit

 
3、配置configrs模式

rs模式配置操作:
d:\MongoDB\Server\3.2\bin\mongo 10.138.2.227:27001

use admin

rs.initiate( {

   _id: "configReplSet",

   configsvr: true,

   members: [

      { _id: 0, host: "10.138.2.227:27001" },

      { _id: 1, host: "10.138.2.224:27001" },

      { _id: 2, host: "10.138.2.253:27001" }

   ]

} )

 

cfg = rs.conf()

cfg.members[0].priority = 100

cfg.members[2].priority = 100

rs.reconfig(cfg)

exit

 

4、在227253分片節點啟動mongos程式

D:\MongoDB\Server\3.2\bin\mongos --configdb configReplSet/10.138.2.227:27001,10.138.2.224:27001,10.138.2.253:27001 --port 27000 --chunkSize 128

D:\MongoDB\Server\3.2\bin\mongos --configdb configReplSet/10.138.2.227:27001,10.138.2.224:27001,10.138.2.253:27001 --port 27000 --chunkSize 128

 

5、在10.138.2.227節點新增分片資訊

D:\MongoDB\Server\3.2\bin\mongo 10.138.2.227:27000/admin

sh.addShard("rs0/10.138.2.227:27011")

sh.addShard("rs1/10.138.2.253:27011")

 

6、業務資料庫初始化操作

八、部分操作記錄

Microsoft Windows [版本 6.1.7601]

版權所有 (c) 2009 Microsoft Corporation。保留所有權利。

C:\Users\Administrator>D:\MongoDB\Server\3.2\bin\mongo 10.138.2.227:27011

2016-10-21T11:09:24.527+0800 I CONTROL  [main] Hotfix KB2731284 or later update is installed, no need to zero-out data files

MongoDB shell version: 3.2.10

connecting to: 10.138.2.227:27011/test

> use admin

switched to db admin

> rsconf = { _id: "rs0",members: [ { _id: 0, host: "10.138.2.227:27011" } ] }

{

        "_id" : "rs0",

        "members" : [

                {

                        "_id" : 0,

                        "host" : "10.138.2.227:27011"

                }

        ]

}

> rs.initiate(rsconf)

{ "ok" : 1 }

rs0:OTHER> rs.conf()

{

        "_id" : "rs0",

        "version" : 1,

        "protocolVersion" : NumberLong(1),

        "members" : [

                {

                        "_id" : 0,

                        "host" : "10.138.2.227:27011",

                        "arbiterOnly" : false,

                        "buildIndexes" : true,

                        "hidden" : false,

                        "priority" : 1,

                        "tags" : {

 

                        },

                        "slaveDelay" : NumberLong(0),

                        "votes" : 1

                }

        ],

        "settings" : {

                "chainingAllowed" : true,

                "heartbeatIntervalMillis" : 2000,

                "heartbeatTimeoutSecs" : 10,

                "electionTimeoutMillis" : 10000,

                "getLastErrorModes" : {

 

                },

                "getLastErrorDefaults" : {

                        "w" : 1,

                        "wtimeout" : 0

                },

                "replicaSetId" : ObjectId("5809870eca9ddae850ca70c4")

        }

}

rs0:PRIMARY> rs.add("10.138.2.253:27012")

{ "ok" : 1 }

rs0:PRIMARY> rs.addArb("10.138.2.227:27015")

{ "ok" : 1 }

rs0:PRIMARY> cfg = rs.conf()

{

        "_id" : "rs0",

        "version" : 3,

        "protocolVersion" : NumberLong(1),

        "members" : [

                {

                        "_id" : 0,

                        "host" : "10.138.2.227:27011",

                        "arbiterOnly" : false,

                        "buildIndexes" : true,

                        "hidden" : false,

                        "priority" : 1,

                        "tags" : {

 

                        },

                        "slaveDelay" : NumberLong(0),

                        "votes" : 1

                },

                {

                        "_id" : 1,

                        "host" : "10.138.2.253:27012",

                        "arbiterOnly" : false,

                        "buildIndexes" : true,

                        "hidden" : false,

                        "priority" : 1,

                        "tags" : {

 

                        },

                        "slaveDelay" : NumberLong(0),

                        "votes" : 1

                },

                {

                        "_id" : 2,

                        "host" : "10.138.2.227:27015",

                        "arbiterOnly" : true,

                        "buildIndexes" : true,

                        "hidden" : false,

                        "priority" : 1,

                        "tags" : {

 

                        },

                        "slaveDelay" : NumberLong(0),

                        "votes" : 1

                }

        ],

        "settings" : {

                "chainingAllowed" : true,

                "heartbeatIntervalMillis" : 2000,

                "heartbeatTimeoutSecs" : 10,

                "electionTimeoutMillis" : 10000,

                "getLastErrorModes" : {

 

                },

                "getLastErrorDefaults" : {

                        "w" : 1,

                        "wtimeout" : 0

                },

                "replicaSetId" : ObjectId("5809870eca9ddae850ca70c4")

        }

}

rs0:PRIMARY> cfg.members[0].priority = 100

100

rs0:PRIMARY> cfg.members[1].priority = 1

1

rs0:PRIMARY> rs.reconfig(cfg)

{ "ok" : 1 }

rs0:PRIMARY> exit

bye

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

相關文章