Centos7 mongodb分區實驗環境搭建(原創)

來源:互聯網
上載者:User
Mongodb3.3.6 CentOS7分區實驗環境搭建 一、拓撲圖


二、部署 1.Mongodb安裝

3台伺服器都安裝mongodb,安裝包拷到/usr/local/下,為了清晰展示,每個節點建立一個mongodb,共建立了4個,其中,master、slave、arbiter搭建副本級。

2、建立單個分區副本級

1)在每個目錄建立日誌目錄logs、資料目錄data/db、配置目錄conf

2)在每個conf目錄編寫設定檔mongd.conf

192.168.1.82

Master:

port=10002

dbpath=/usr/local/mongodb-3.3.6_master/data/db

logpath=/usr/local/mongodb-3.3.6_master/logs/mongod.log

fork=true 

logappend=true

nohttpinterface=true

replSet=test1 #複本集名稱

pidfilepath=/var/run/mongo_master.pid

bind_ip=192.168.1.82

 

 

Slave:

port=10001

dbpath=/usr/local/mongodb-3.3.6_slave/data/db

logpath=/usr/local/mongodb-3.3.6_slave/logs/mongod.log

fork=true

logappend=true

nohttpinterface=true

replSet=test1

pidfilepath=/var/run/mongo_slave.pid

bind_ip=192.168.1.82

 

Arbiter:

port=10000

dbpath=/usr/local/mongodb-3.3.6_arbiter/data/db

logpath=/usr/local/mongodb-3.3.6_arbiter/logs/mongod.log

fork=true

logappend=true

replSet=test1

nohttpinterface=true

pidfilepath=/var/run/mongo_arbiter.pid

bind_ip=192.168.1.82

 

3)分別啟動mongodb

/usr/local/mongodb-3.3.6_master/bin/mongod-f ../conf/mongod.conf

/usr/local/mongodb-3.3.6_slave/bin/mongod-f ../conf/mongod.conf

/usr/local/mongodb-3.3.6_arbiter/bin/mongod-f ../conf/mongod.conf

4)配置副本級

進入master的mongo shell

#cd /usrl/local/mongodb-3.3.6_master/bin

#./mongo192.168.1.82:10002

切換到admin庫

>useadmin

>config={‘_id’:’test1’,‘members’:[ {‘_id’:0,’host’:'192.168.1.82:10002',’priority’:2},{‘_id’:1,’host’:'192.168.1.82:10001',’priority’:1},{‘_id’:2,’host’:'192.168.1.82:10000',’arbiterOnly’:true}]};

初始化副本

>rs.initiate(config)

查看叢集狀態

>rs.status()

test1:PRIMARY>rs.status()

{

 "set" : "test1",

 "date" :ISODate("2017-01-04T06:36:07.732Z"),

 "myState" : 1,

 "term" : NumberLong(9),

 "heartbeatIntervalMillis" :NumberLong(2000),

 "optimes" : {

        "lastCommittedOpTime" : {

               "ts" :Timestamp(1483511762, 1),

               "t" : NumberLong(9)

        },

        "appliedOpTime" : {

               "ts" :Timestamp(1483511762, 1),

               "t" : NumberLong(9)

        },

        "durableOpTime" : {

               "ts" :Timestamp(1483511762, 1),

               "t" : NumberLong(9)

        }

 },

 "members" : [

        {

               "_id" : 0,

               "name" :"192.168.1.82:10002",

               "health" : 1,

               "state" : 1,

               "stateStr" :"PRIMARY",

               "uptime" : 448,

               "optime" : {

                      "ts" :Timestamp(1483511762, 1),

                      "t" :NumberLong(9)

               },

               "optimeDate" :ISODate("2017-01-04T06:36:02Z"),

               "electionTime" :Timestamp(1483511352, 1),

               "electionDate" :ISODate("2017-01-04T06:29:12Z"),

               "configVersion" : 3,

               "self" : true

        },

        {

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.