https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-red-hat/
内容如下:
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
$sudo yum install -y mongodb-org
$sudo yum install -y mongodb-org-6.0.4 mongodb-org-database-6.0.4 mongodb-org-server-6.0.4 mongodb-org-mongos-6.0.4 mongodb-org-tools-6.0.4
vi /etc/yum.conf
加上:
exclude=mongodb-org,mongodb-org-database,mongodb-org-server,mongodb-mongosh,mongodb-org-mongos,mongodb-org-tools
vi /etc/mongod.conf
storage;
dbPath = /app/mongodb/db systemLog.path = /app/mongodb/log
https://www.mongodb.com/docs/manual/tutorial/deploy-replica-set/
vi /etc/profile
MONGO_HOME=/XXX PATH=$MONGO_HOME/bin:$PATH export MONGO_HOME PATH
mognDB 默认启动脚本: /usr/bin/mongod mognDB 配置文件: /etc/mongod.conf
security: authorization: 'enabled' clusterAuthMode: "keyFile" keyFile: /etc/mongod/rs.key
replication: oplogSizeMB: 82400 #复制操作日志的最大大小,以M为单位,默认情况下,mongod进程基于最大可用空间创建oplog,对于64位系统,oplog通常占可用磁盘空间的5%; replSetName: tx #副本集的名称 enableMajorityReadConcern: false
mkdir -p /etc/mongod
openssl rand -base64 741 > rs.key
mongod -f /etc/mongod.conf --replSet=tx
mongod --shutdown --dbpath /app/mongodb/db
$mongosh
>use admin
>config = {_id: 'tx', members: [
{_id: 0, host: '127.0.0.1:27017',priority:2},
{_id: 1, host: '127.0.0.2:27017',priority:1},
{ "_id" : 2,"host" : "127.0.0.3:27017","arbiterOnly" : true}
>rs.initiate(config)
进入主节点:
use admin
以下才是配置超管:
db.createUser({
user: "admin",
pwd: "@123_79_200",
roles: ["root"]
})
‘
use tx-biz
db.createUser({user:"root",pwd: "hao#231",roles: [{ role: "readWrite", db:"tx-biz"}]})