centos7 部署mongodb4.0

centos7.8 部署mongodb

1. 下载包

直接下载

https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.28.tgz

官网下载

https://www.mongodb.com/try/download/community-kubernetes-operator
2. 解压包
tar xvf mongodb-linux-x86_64-rhel70-4.0.28.tgz -C /usr/local/
3. 重命名
cd /usr/local
mv mongodb-linux-x86_64 mongodb
4. 添加环境变量

cat /etc/profile
主要修改数据目录和日志目录,fork修改为true表示后台,认证先改为disabled

export PATH=$PATH:/usr/local/mongodb/bin
5. 编辑配置文件

cat /usr/local/mongodb/mongodb.conf

# mongod.conf
# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where and how to store data.
storage:
  dbPath: /usr/local/mongodb/data/
  journal:
    enabled: true
  directoryPerDB: false

# where to write logging data.
systemLog:
  destination: file
  quiet: false
  logAppend: true
  logRotate: reopen
  path: /usr/local/mongodb/logs/mongodb.log
  verbosity: 0

# network interfaces
net:
  port: 27017
  unixDomainSocket:
    enabled: true
    pathPrefix: /usr/local/mongodb/tmp
  ipv6: false
  bindIpAll: true
  bindIp: 0.0.0.0

# replica set options
#replication:
  #replSetName: replicaset
  #enableMajorityReadConcern: true

# process management options
processManagement:
   fork: true
   pidFilePath: /usr/local/mongodb/tmp/mongodb.pid

# set parameter options
setParameter:
   enableLocalhostAuthBypass: true


# security options
security:
  authorization: disabled
  #keyFile: replace_me

6. 创建普通用户
useradd mongodb
7. 创建目录
mkdir /usr/local/mongodb/data
mkdir /usr/local/mongodb/logs
mkdir /usr/local/mongodb/tmp
8. 赋予mongodb用户权限
chown -R mongodb. /usr/local/mongodb
9. 切换mongodb用户启动
su - mongodb
cd /usr/local/mongodb
mongod -f mongodb.conf
10. 设置密码

进入数据库设置密码
mongo命令

---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

>

创建账号

> use admin
> db.createUser({ user:'root',pwd:'Ictsoft+123',roles:[ { role:'root', db: 'admin'}]});
Successfully added user: {
	"user" : "root",
	"roles" : [
		{
			"role" : "root",
			"db" : "admin"
		}
	]
}

退出数据库修改配置文件

security:
  authorization: enabled
  #keyFile: replace_me

重启mongodb

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值