Mongodb3.4--2 Shard Configuration Experiment Wiredtiger-account management

Source: Internet
Author: User

# Update by CSC 20170217

#opensystem CentOS 6.5 bit


Tar-xvzf mongodb-linux-x86_64-rhel62-3.4.2.gz-c/usr/local/

Mv/usr/local/mongodb-linux-x86_64-rhel55-3.4.2/usr/local/mongodb


Echo ' Export path= $PATH:/usr/local/mongodb/bin ' >>/etc/profile

Source/etc/profile

===============================



Mkdir-p/data/mongodb/config/data

Mkdir-p/data/mongodb/config/log


Mkdir-p/data/mongodb/mongos/log


Mkdir-p/data/mongodb/shard1/data

Mkdir-p/data/mongodb/shard1/log


Mkdir-p/data/mongodb/shard2/data

Mkdir-p/data/mongodb/shard2/log


Configure if the alarm is activated;

echo 0 >/proc/sys/vm/zone_reclaim_mode

Echo Never >/sys/kernel/mm/transparent_hugepage/enabled

Echo Never >/sys/kernel/mm/transparent_hugepage/defrag


Cat >>/etc/rc.d/rc.local<<eof

echo 0 >/proc/sys/vm/zone_reclaim_mode

Echo Never >/sys/kernel/mm/transparent_hugepage/enabled

Echo Never >/sys/kernel/mm/transparent_hugepage/defrag

Eof



############## Production keyfile file (certification use-account management)

#openssl rand-base64 753

Copy String to/usr/local/mongodb/key

chmod 600/root/mobgodb/key

and copy the key file to the same directory as the other 2 nodes


################################


/usr/local/mongodb/bin/mongod--configsvr--replset cfgreplset--dbpath/data/mongodb/config/data--port 21000-- Logpath/data/mongodb/config/log/config.log--fork--keyfile/usr/local/mongodb/key



/usr/local/mongodb/bin/mongod--shardsvr--replset shard1--port 22001--dbpath/data/mongodb/shard1/data--logpath/ Data/mongodb/shard1/log/shard1.log--fork--oplogsize 10000--keyfile/usr/local/mongodb/key



/usr/local/mongodb/bin/mongod--shardsvr--replset shard2--port 22002--dbpath/data/mongodb/shard2/data--logpath/ Data/mongodb/shard2/log/shard2.log--fork--oplogsize 10000--keyfile/usr/local/mongodb/key




/usr/local/mongodb/bin/mongos--configdb cfgreplset/192.168.1.15:21000,192.168.1.16:21000,192.168.1.17:21000-- Port 30000--logpath/data/mongodb/mongos/log/mongos.log--fork--keyfile/usr/local/mongodb/key

=======================


MONGO 192.168.1.15:21000

Use admin

Config = {_id: "Cfgreplset", members:[

{_id:0,host: "192.168.1.15:21000"},

{_id:1,host: "192.168.1.16:21000"},

{_id:2,host: "192.168.1.17:21000"}

]

}


Rs.initiate (config);


=========================


MONGO 192.168.1.15:22001

Use admin

Config = {_id: "Shard1", members:[

{_id:0,host: "192.168.1.15:22001", Priority:2},

{_id:1,host: "192.168.1.16:22001", priority:1},

{_id:2,host: "192.168.1.17:22001", arbiteronly:true}

]

}


Rs.initiate (config);






========================

MONGO 192.168.1.16:22002

Use admin

Config = {_id: "Shard2", members:[

{_id:0,host: "192.168.1.15:22002", priority:1},

{_id:1,host: "192.168.1.16:22002", Priority:2},

{_id:2,host: "192.168.1.17:22002", arbiteronly:true}

]

}


Rs.initiate (config);


=====================

MONGO 192.168.1.15:30000

Use admin

Concatenation-Increase--routing server and allocation replica set 1


Db.runcommand ({addshard: "shard1/192.168.1.15:22001,192.168.1.16:22001,192.168.1.17:22001"});


Concatenation-Increase--routing server and allocation replica set 2

Db.runcommand ({addshard: "shard2/192.168.1.15:22002,192.168.1.16:22002,192.168.1.17:22002"});


#############################################

# #创建账户

MONGOs 192.168.1.15:30000

# #创建超级管理用户密码 root/12345

Use admin

Db.createuser (

{

User: "Root",

PWD: "12345",

Roles: [{role: ' Useradminanydatabase ', db: ' admin '}]

}

)


# # #查看

Show Users


##########################################################


Account password for #创建 database portal/123456 database: whty_edu_469026


Use whty_edu_469026

Db.createuser (

{

User: "Portal",

PWD: "123456",

Roles: [

{role: "ReadWrite", DB: "whty_edu_469026"},

]

}

)


##### View

Show Users





############ Link Way 1:

# mongo-u Portal-p 123456 127.0.0.1:30000/whty_edu_469026


########### Link Way 2:

Use admin

Db.auth ("Portal", "123456") #认证, returning 1 indicates success




# # # Delete an account

Log in with the admin account, then use the database,

Execute Db.dropuser ("portal")




This article is from the "Clumsy birds have" blog, make sure to keep this source http://2574526.blog.51cto.com/2564526/1898915

Mongodb3.4--2 Shard Configuration Experiment Wiredtiger-account management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.