安装MongoDB Server
xuej@xuej-VirtualBox:~/Downloads$ sudo apt-get install libcurl4 openssl liblzma5
[sudo] password for xuej:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
fonts-liberation2 fonts-opensymbol gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gir1.2-gudev-1.0 gir1.2-udisks-2.0 grilo-plugins-0.3-base gstreamer1.0-gtk3 libboost-date-time1.65.1
libboost-filesystem1.65.1 libboost-iostreams1.65.1 libboost-locale1.65.1 libcdr-0.1-1 libclucene-contribs1v5 libclucene-core1v5 libcmis-0.5-5v5 libcolamd2 libdazzle-1.0-0 libe-book-0.1-1
libedataserverui-1.2-2 libeot0 libepubgen-0.1-1 libetonyek-0.1-1 libevent-2.1-6 libexiv2-14 libfreerdp-client2-2 libfreerdp2-2 libgc1c2 libgee-0.8-2 libgexiv2-2 libgom-1.0-0 libgpgmepp6
libgpod-common libgpod4 liblangtag-common liblangtag1 liblirc-client0 liblua5.3-0 libmediaart-2.0-0 libmspub-0.1-1 libodfgen-0.1-1 libqqwing2v5 libraw16 librevenge-0.0-0 libsgutils2-2 libssh-4
libsuitesparseconfig5 libvncclient1 libwinpr2-2 libxapian30 libxmlsec1 libxmlsec1-nss lp-solve media-player-info python3-mako python3-markupsafe syslinux syslinux-common syslinux-legacy
usb-creator-common
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
libcurl4
The following packages will be upgraded:
liblzma5 openssl
2 upgraded, 1 newly installed, 0 to remove and 182 not upgraded.
Need to get 220 kB/925 kB of archives.
After this operation, 655 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.18 [220 kB]
Fetched 220 kB in 3s (70.9 kB/s)
(Reading database ... 114570 files and directories currently installed.)
Preparing to unpack .../liblzma5_5.2.2-1.3ubuntu0.1_amd64.deb ...
Unpacking liblzma5:amd64 (5.2.2-1.3ubuntu0.1) over (5.2.2-1.3) ...
Setting up liblzma5:amd64 (5.2.2-1.3ubuntu0.1) ...
(Reading database ... 114570 files and directories currently installed.)
Preparing to unpack .../openssl_1.1.1-1ubuntu2.1~18.04.17_amd64.deb ...
Unpacking openssl (1.1.1-1ubuntu2.1~18.04.17) over (1.1.1-1ubuntu2.1~18.04.13) ...
Selecting previously unselected package libcurl4:amd64.
Preparing to unpack .../libcurl4_7.58.0-2ubuntu3.18_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.18) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.18) ...
Setting up openssl (1.1.1-1ubuntu2.1~18.04.17) ...
Processing triggers for libc-bin (2.27-3ubuntu1.4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
xuej@xuej-VirtualBox:~/Downloads$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-5.0.9.tgz
--2022-06-07 20:17:00-- https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-5.0.9.tgz
Resolving fastdl.mongodb.org (fastdl.mongodb.org)... 18.65.216.126, 18.65.216.124, 18.65.216.58, ...
Connecting to fastdl.mongodb.org (fastdl.mongodb.org)|18.65.216.126|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 86232946 (82M) [application/gzip]
Saving to: ‘mongodb-linux-x86_64-ubuntu1804-5.0.9.tgz’
mongodb-linux-x86_64-ubuntu1804-5.0.9.tgz 100%[==============================================================================================================>] 82.24M 1.50MB/s in 65s
2022-06-07 20:18:07 (1.26 MB/s) - ‘mongodb-linux-x86_64-ubuntu1804-5.0.9.tgz’ saved [86232946/86232946]
xuej@xuej-VirtualBox:~/Downloads$ tar -zxvf mongodb-linux-x86_64-ubuntu1804-5.0.9.tgz
mongodb-linux-x86_64-ubuntu1804-5.0.9/LICENSE-Community.txt
mongodb-linux-x86_64-ubuntu1804-5.0.9/MPL-2
mongodb-linux-x86_64-ubuntu1804-5.0.9/README
mongodb-linux-x86_64-ubuntu1804-5.0.9/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-ubuntu1804-5.0.9/bin/install_compass
mongodb-linux-x86_64-ubuntu1804-5.0.9/bin/mongo
mongodb-linux-x86_64-ubuntu1804-5.0.9/bin/mongod
mongodb-linux-x86_64-ubuntu1804-5.0.9/bin/mongos
xuej@xuej-VirtualBox:~/Downloads$ sudo cp -r mongodb-linux-x86_64-ubuntu1804-5.0.9 /opt/
[sudo] password for xuej:
xuej@xuej-VirtualBox:~/Downloads$ sudo ln -s /opt/mongodb-linux-x86_64-ubuntu1804-5.0.9/bin/* /usr/local/bin/
xuej@dev-server:~/Documents/sts4/express-mongo$ sudo service mongod start
xuej@dev-server:~/Documents/sts4/express-mongo$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2022-08-20 00:07:49 CST; 1s ago
Docs: https://docs.mongodb.org/manual
Process: 5593 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
Main PID: 5593 (code=exited, status=14)
Aug 20 00:07:48 dev-server systemd[1]: Started MongoDB Database Server.
Aug 20 00:07:49 dev-server systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Aug 20 00:07:49 dev-server systemd[1]: mongod.service: Failed with result 'exit-code'.
xuej@dev-server:~/Documents/sts4/express-mongo$ ll /tmp/mongodb-27017.sock
srwx------ 1 xuej xuej 0 Aug 20 00:05 /tmp/mongodb-27017.sock=
xuej@dev-server:~/Documents/sts4/express-mongo$ chown mongodb:mongodb /tmp/mongodb-27017.sock
chown: changing ownership of '/tmp/mongodb-27017.sock': Operation not permitted
xuej@dev-server:~/Documents/sts4/express-mongo$ sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
xuej@dev-server:~/Documents/sts4/express-mongo$ sudo service mongod restart
xuej@dev-server:~/Documents/sts4/express-mongo$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2022-08-20 00:14:55 CST; 5s ago
Docs: https://docs.mongodb.org/manual
Main PID: 7499 (mongod)
CGroup: /system.slice/mongod.service
└─7499 /usr/bin/mongod --config /etc/mongod.conf
Aug 20 00:14:55 dev-server systemd[1]: Started MongoDB Database Server.
安装MongoDB Shell
xuej@xuej-VirtualBox:~/Downloads$ wget https://downloads.mongodb.com/compass/mongosh-1.5.0-linux-x64.tgz
--2022-06-07 20:36:06-- https://downloads.mongodb.com/compass/mongosh-1.5.0-linux-x64.tgz
Resolving downloads.mongodb.com (downloads.mongodb.com)... 13.33.210.127, 13.33.210.56, 13.33.210.87, ...
Connecting to downloads.mongodb.com (downloads.mongodb.com)|13.33.210.127|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 58084414 (55M) [application/octet-stream]
Saving to: ‘mongosh-1.5.0-linux-x64.tgz’
mongosh-1.5.0-linux-x64.tgz 100%[==============================================================================================================>] 55.39M 1.80MB/s in 40s
2022-06-07 20:36:47 (1.38 MB/s) - ‘mongosh-1.5.0-linux-x64.tgz’ saved [58084414/58084414]
xuej@xuej-VirtualBox:~/Downloads$ tar -zxvf mongosh-1.5.0-linux-x64.tgz
mongosh-1.5.0-linux-x64/
mongosh-1.5.0-linux-x64/LICENSE-crypt-library
mongosh-1.5.0-linux-x64/LICENSE-mongosh
mongosh-1.5.0-linux-x64/README
mongosh-1.5.0-linux-x64/THIRD_PARTY_NOTICES
mongosh-1.5.0-linux-x64/bin/
mongosh-1.5.0-linux-x64/mongosh.1.gz
mongosh-1.5.0-linux-x64/bin/mongosh
mongosh-1.5.0-linux-x64/bin/mongosh_crypt_v1.so
xuej@xuej-VirtualBox:~/Downloads$ chmod +x mongosh-1.5.0-linux-x64/bin/mongosh
xuej@xuej-VirtualBox:~/Downloads$ sudo cp -r mongosh-1.5.0-linux-x64 /opt/
xuej@xuej-VirtualBox:~/Downloads$ sudo ln -s /opt/mongosh-1.5.0-linux-x64/bin/* /usr/local/bin/
部署MongoDB Replication
https://www.mongodb.com/docs/manual/replication/
部署MongoDB Sharding
https://www.mongodb.com/docs/manual/sharding/