1.登录 路由节点 开启认证之前 进入路由创建管理员和普通用户
use admin
db
db.createUser(
{
user:"root",
pwd:"123456",
roles:[{role:"root",db:"admin"}]
}
)
use yyj_resume
db.createUser(
{
user:"yyj",
pwd:"123456",
roles:[{role:"readWrite",db:"yyj_resume"}]
}
)
2.关闭所有的配置节点 分片节点 和路由节点
安装psmisc
yum install psmisc
安装完之后可以使用killall 命令 快速关闭多个进程
killall mongod/mongo/mongos
3.生成秘钥文件 并修改权限
openssl rand -base64 756 > data/mongodb/testKeyFile.file
chmod 600 data/mongodb/testKeyFile.file
4.配置节点集群和分片节点集群开启安全认证和指定秘钥文件
auth=true
keyFile=data/mongodb/testKeyFile.file
5.在路由配置文件中 设置秘钥文件
keyFile=data/mongodb/testKeyFile.file
6.启动所有配置节点 分片节点 和路由节点 进行权限验证
编写shell脚本 批量启动
./bin/mongod -f config/config-17017.conf
./bin/mongod -f config/config-17018.conf
./bin/mongod -f config/config-17019.conf
./bin/mongod -f shard/shard-37017.conf
./bin/mongod -f shard/shard-37018.conf
./bin/mongod -f shard/shard-37019.conf
./bin/mongod -f shard2/shard2-47017.conf
./bin/mongod -f shard2/shard2-47018.conf
./bin/mongod -f shard2/shard2-47019.conf
./bin/mongos -f route/route-27017.conf
7.通过nosqlbooster链接进行验证