ubuntu20.04 MongoDB6.0 安装/启动/shell/配置

目录

安装

启动与停止

进入shell

配置文件格式


安装

1.下载mongodb的公钥 

wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
若提示gnupg未安装,执行
sudo apt-get install gnupg
安装完成后,再执行第一步骤

2.更新apt-get的source-list源文件

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

3.重新加载本地apt-get包

sudo apt-get update

4.安装mongodb

sudo apt-get install -y mongodb-org

启动与停止

sudo service mongod start #启动服务
sudo service mongod status #查看状态
sudo service mongod stop #停止服务
sudo service mongod restart #重启服务

进入shell

mongosh

配置文件格式

mongod.conf默认存放位置为/etc/mongod.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: /var/lib/mongodb
#  engine:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:


若有其他问题,欢迎评论区交流!

sudo apt update sudo apt install -y mongodb-org Hit:1 http://mirrors.tencentyun.com/ubuntu focal InRelease Hit:2 http://mirrors.tencentyun.com/ubuntu focal-updates InRelease Hit:3 http://mirrors.tencentyun.com/ubuntu focal-backports InRelease Hit:4 http://mirrors.tencentyun.com/ubuntu focal-security InRelease Hit:5 https://download.docker.com/linux/ubuntu focal InRelease Hit:6 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease Get:7 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 InRelease [3,005 B] Get:8 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 Packages [53.2 kB] Fetched 56.2 kB in 2s (34.0 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libboost-filesystem1.71.0 libboost-iostreams1.71.0 libboost-program-options1.71.0 libgoogle-perftools4 libpcap0.8 libsnappy1v5 libtcmalloc-minimal4 libunwind8 libyaml-cpp0.6 mongo-tools mongodb-server-core Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: mongodb-database-tools mongodb-mongosh mongodb-org-database mongodb-org-database-tools-extra mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools The following packages will be REMOVED: mongodb mongodb-clients mongodb-server The following NEW packages will be installed: mongodb-database-tools mongodb-mongosh mongodb-org mongodb-org-database mongodb-org-database-tools-extra mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools 0 upgraded, 9 newly installed, 3 to remove and 0 not upgraded. Need to get 186 MB of archives. After this operation, 600 MB of additional disk space will be used. Get:1 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-database-tools amd64 100.13.0 [58.9 MB] Get:2 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-mongosh amd64 2.5.9 [57.9 MB] Get:3 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-org-shell amd64 8.0.15 [3,088 B] Get:4 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-org-server amd64 8.0.15 [39.7 MB] Get:5 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-org-mongos amd64 8.0.15 [29.8 MB] Get:6 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-org-database-tools-extra amd64 8.0.15 [7,756 B] Get:7 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-org-database amd64 8.0.15 [3,544 B] Get:8 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-org-tools amd64 8.0.15 [2,896 B] Get:9 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0/multiverse amd64 mongodb-org amd64 8.0.15 [2,936 B] Fetched 186 MB in 4s (42.4 MB/s) debconf: delaying package configuration, since apt-utils is not installed (Reading database ... 38109 files and directories currently installed.) Removing mongodb (1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3) ... Removing mongodb-server (1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3) ... invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of stop. Removing mongodb-clients (1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3) ... Selecting previously unselected package mongodb-database-tools. (Reading database ... 38091 files and directories currently installed.) Preparing to unpack .../0-mongodb-database-tools_100.13.0_amd64.deb ... Unpacking mongodb-database-tools (100.13.0) ... dpkg: error processing archive /tmp/apt-dpkg-install-Q6AJHa/0-mongodb-database-tools_100.13.0_amd64.deb (--unpack): trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.6.3-0ubuntu1 dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Selecting previously unselected package mongodb-mongosh. Preparing to unpack .../1-mongodb-mongosh_2.5.9_amd64.deb ... Unpacking mongodb-mongosh (2.5.9) ... Selecting previously unselected package mongodb-org-shell. Preparing to unpack .../2-mongodb-org-shell_8.0.15_amd64.deb ... Unpacking mongodb-org-shell (8.0.15) ... Selecting previously unselected package mongodb-org-server. Preparing to unpack .../3-mongodb-org-server_8.0.15_amd64.deb ... Unpacking mongodb-org-server (8.0.15) ... dpkg: error processing archive /tmp/apt-dpkg-install-Q6AJHa/3-mongodb-org-server_8.0.15_amd64.deb (--unpack): trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3 dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Selecting previously unselected package mongodb-org-mongos. Preparing to unpack .../4-mongodb-org-mongos_8.0.15_amd64.deb ... Unpacking mongodb-org-mongos (8.0.15) ... dpkg: error processing archive /tmp/apt-dpkg-install-Q6AJHa/4-mongodb-org-mongos_8.0.15_amd64.deb (--unpack): trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-core 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5.3 dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Selecting previously unselected package mongodb-org-database-tools-extra. Preparing to unpack .../5-mongodb-org-database-tools-extra_8.0.15_amd64.deb ... Unpacking mongodb-org-database-tools-extra (8.0.15) ... Selecting previously unselected package mongodb-org-database. Preparing to unpack .../6-mongodb-org-database_8.0.15_amd64.deb ... Unpacking mongodb-org-database (8.0.15) ... Selecting previously unselected package mongodb-org-tools. Preparing to unpack .../7-mongodb-org-tools_8.0.15_amd64.deb ... Unpacking mongodb-org-tools (8.0.15) ... Selecting previously unselected package mongodb-org. Preparing to unpack .../8-mongodb-org_8.0.15_amd64.deb ... Unpacking mongodb-org (8.0.15) ... Errors were encountered while processing: /tmp/apt-dpkg-install-Q6AJHa/0-mongodb-database-tools_100.13.0_amd64.deb /tmp/apt-dpkg-install-Q6AJHa/3-mongodb-org-server_8.0.15_amd64.deb /tmp/apt-dpkg-install-Q6AJHa/4-mongodb-org-mongos_8.0.15_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
最新发布
11-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值