安装网络上的教程安装发现总是报错
dpkg-deb: 错误: ./libssl1.1_1.1.1-1ubuntu2.1~18.04.20_amd64.deb 并非 Debian 格式的包文件
dpkg: 处理归档 ./libssl1.1_1.1.1-1ubuntu2.1~18.04.20_amd64.deb (--install)时出错:
dpkg-deb --control 子进程返回错误状态 2
在处理时有错误发生:
./libssl1.1_1.1.1-1ubuntu2.1~18.04.20_amd64.deb
搜索之后发现是Ubuntu自18.04版本后就将libssl删除掉了 所以当前版本22.04没有这个包 那么就好说了 直接下载这个包不就行了
sudo apt install libssl1.1
但并没有解决该问题 问了gpt说是 包下载的地址有问题
在stack上搜索相关问题后解决措施如下
echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
sudo apt-get update
sudo apt-get install libssl1.1
换了地址后 更新下载源 下载成功
sudo apt install -y mongodb-org
安装mongodb 安装成功后开启服务和查看状态显示以下画面 即安装成功
mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2023-06-25 12:02:43 CST; 3s ago
Docs: https://docs.mongodb.org/manual
Main PID: 111906 (mongod)
Memory: 72.3M
CPU: 1.124s
CGroup: /system.slice/mongod.service
└─111906 /usr/bin/mongod --config /etc/mongod.conf
6月 25 12:02:43 zquan-virtual-machine systemd[1]: Started MongoDB Database Server.
6月 25 12:02:43 zquan-virtual-machine mongod[111906]: {"t":{"$date":"2023-06-25T04:02:43.539Z"},"s":"I", "c":"CONTROL">
...skipping...
开启服务后 可以输入这个命令 将mongod设置为系统开启时 就不用每次想要开启mongo服务输入sudo systemctl start mongod了
sudo systemctl enable mongod
需要进行本地mongo数据库操作 输入命令 mongosh 就可以看到以下画面
Using MongoDB: 6.0.6
Using Mongosh: 1.10.1
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
------
The server generated these startup warnings when booting
2023-06-25T12:02:44.115+08:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2023-06-25T12:02:44.916+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2023-06-25T12:02:44.916+08:00: vm.max_map_count is too low
------
test>
在里面输入 show dbs 即可查看所有数据库了 不过需要注意的是 mongo本身就带有三个数据库分别是 local config admin 不建议去里面添加自己的数据库表 另外新建一个就行。