我正在尝试从此站点https://www.howtoforge.com/tutorial/install-mongodb-on-ubuntu/在Ubuntu 18.04 LTS上安装mongodb。
运行此命令后:
sudo apt-get install -y mongodb-org
我明白了:
root@walid-HP-250-G4-Notebook-PC:/# sudo apt-get install -y mongodb-org
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell
mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 50 not upgraded.
Need to get 81.7 MB of archives.
After this operation, 271 MB of additional disk space will be used.
Get:1 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org-shell amd64 4.2.1 [11.9 MB]
Get:2 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org-server amd64 4.2.1 [18.3 MB]
Get:3 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org-mongos amd64 4.2.1 [10.0 MB]
Get:4 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org-tools amd64 4.2.1 [41.5 MB]
Get:5 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org amd64 4.2.1 [3,528 B]
Fetched 81.7 MB in 35min 43s (38.1 kB/s)
Selecting previously unselected package mongodb-org-shell.
(Reading database ... 179789 files and directories currently installed.)
Preparing to unpack .../mongodb-org-shell_4.2.1_amd64.deb ...
Unpacking mongodb-org-shell (4.2.1) ...
Selecting previously unselected package mongodb-org-server.
Preparing to unpack .../mongodb-org-server_4.2.1_amd64.deb ...
Unpacking mongodb-org-server (4.2.1) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_4.2.1_amd64.deb (--unpack):
trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../mongodb-org-mongos_4.2.1_amd64.deb ...
Unpacking mongodb-org-mongos (4.2.1) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-mongos_4.2.1_amd64.deb (--unpack):
trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_4.2.1_amd64.deb ...
Unpacking mongodb-org-tools (4.2.1) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../mongodb-org_4.2.1_amd64.deb ...
Unpacking mongodb-org (4.2.1) ...
Errors were encountered while processing:
/var/cache/apt/archives/mongodb-org-server_4.2.1_amd64.deb
/var/cache/apt/archives/mongodb-org-mongos_4.2.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
任何人都可以帮忙!
答案 0 :(得分:0)
存在一个现有的程序包,因此出现以下错误“试图覆盖”。
dpkg:处理归档文件/var/cache/apt/archives/mongodb-org-mongos_4.2.1_amd64.deb(--unpack)时出错: 试图覆盖'/ usr / bin / mongos',它也在软件包mongodb-server-core 1:3.6.3-0ubuntu1.1
中尝试使用--force-overwrite覆盖软件包
运行命令 sudo dpkg -i --force-all /var/cache/apt/archives/mongodb-org-mongos_4.2.1_amd64.deb
然后运行安装 sudo apt-get install -f mongodb-org
答案 1 :(得分:0)
该错误是由您的系统已经安装了mongodb软件包,然后尝试安装mongodb-org引起的。
运行以下命令删除/取消安装现有的mongo软件包。
sudo apt remove mongodb-org
sudo apt purge mongodb-org
sudo apt remove mongodb
sudo apt purge mongodb
您可能还需要sudo apt autoremove
才能删除系统中的通用软件包。
现在尝试安装。这次确定应该没有任何错误地完成它
sudo apt install mongodb-org
启动mongod
sudo systemctl start mongod
sudo systemctl enable mongod
检查mongod是否在运行
sudo service mongod status
答案 2 :(得分:0)
sudo apt remove mongo*
并重新安装可能会有所帮助。