Single Node Deployment

Deploy by docker

Create docker-compose file

vim docker-compose-mongodb.yml

version: "3.1"		#Related to mirroring, only 3.1 is supported here
services:
  mongo:
    container_name: mongodb
    image: mongo:4.2
    restart: always
    ports:
      - 27017:27017
    volumes:
#      - ./setup:/docker-entrypoint-initdb.d/
      - /data/mongo:/data/db:rw
#      - /data/mongo_key:/mongo:rw
    environment:
      MONGO_INITDB_ROOT_USERNAME: admin		
      MONGO_INITDB_ROOT_PASSWORD: 123456	
  mongo-express:	#If you don't need the web side of MongoDB, the following can be left out
    image: mongo-express
    restart: always
    ports:
      - 8081:8081
    environment:
#Here you can only use the same root account as MONGO_INITDB_ROOT_USERNAME above
      ME_CONFIG_MONGODB_ADMINUSERNAME: admin
      ME_CONFIG_MONGODB_ADMINPASSWORD: 123456

start up

docker-compose -f docker-compose-mongodb.yml up -d

CentOS/Ubuntu installation

CentOS/RedHat installation

Creating yum sources

vim /etc/yum.repos.d/mongodb.repo

[mongodb-org]
name=MongoDB Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mongodb/yum/el$releasever/
gpgcheck=0
enabled=1

Refresh the cache and install mongodb

yum makecache
yum install mongodb-org

Ubuntu/Debian way to install

Add public key

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

Add installation source

Select the appropriate source according to the system version

vim /etc/apt/sources.list.d/mongodb.list

Ubuntu 16.04
deb https://mirrors.tuna.tsinghua.edu.cn/mongodb/apt/ubuntu xenial/mongodb-org/4.4 multiverse

Ubuntu 18.04
deb https://mirrors.tuna.tsinghua.edu.cn/mongodb/apt/ubuntu bionic/mongodb-org/4.4 multiverse

Ubuntu20.04
deb https://mirrors.tuna.tsinghua.edu.cn/mongodb/apt/ubuntu focal/mongodb-org/4.4 multiverse

Install mongodb

apt update
apt install mongodb-org

Related articles

kolla Deploying openstack (stein)

Basic Configuration Extended Source yum install epel-release -y hostname [root@kolla ~]# cat /etc/hostname kolla [root@kolla ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost