deepin 安装mongodb

MongoDB数据库安装指南 Edit

Revision history

MongoDB安装指南

说明

Use this tutorial to install MongoDB Community Edition from .deb packages on Debian 7 “Wheezy” or Debian 8 “Jessie”. While Debian includes its own MongoDB packages, use the official MongoDB Community Edition packages to ensure that you have the latest release.

MongoDB 仅提供 64位系统版本。

程序包相关

MongoDB provides officially supported packages in their own repository. This repository contains the following packages:

Package Name Description
mongodb-org A metapackage that will automatically install the four component packages listed below.
mongodb-org-server Contains the mongod daemon and associated configuration and init scripts.
mongodb-org-mongos Contains the mongos daemon.
mongodb-org-shell Contains the mongo shell.
mongodb-org-tools Contains the following MongoDB tools: mongoimport bsondump, mongodump, mongoexport, mongofiles, mongooplog, mongoperf, mongorestore, mongostat, and mongotop.
The mongodb-org-server package provides an initialization script that starts mongod with the /etc/mongod.conf configuration file.

See Run MongoDB Community Edition for details on using this initialization script.

These packages conflict with the mongodb, mongodb-server, and mongodb-clients packages provided by Debian.

The default /etc/mongod.conf configuration file supplied by the packages have bind_ip set to 127.0.0.1 by default. Modify this setting as needed for your environment before initializing a replica set.

安装 MongoDB

NOTE To install a different version of MongoDB, please refer to that version’s documentation. For example, see version 3.2. This installation guide only supports 64-bit systems. See Platform Support for details.

The Debian package management tools (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys.

1. 导入MongoDB公钥.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

2. 创建MongoDB的软件源 /etc/apt/sources.list.d/mongodb-org-3.4.list

你可以选择安装 Debian 7 “Wheezy"仓库

echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

也可以选择 Debian 8 “Jessie”仓库

echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

当前软件仅支持 Debian 7 “Wheezy" 和 Debian 8 “Jessie"。

3. 安装MongoDB.

sudo apt-get update
sudo apt-get install -y mongodb-org

4.解决没有/home/mongodb目录的问题

sudo mkdir /home/mongodb
sudo chown -R mongodb:mongodb /home/mongodb

运行 MongoDB

Most Unix-like operating systems limit the system resources that a session may use. These limits may negatively impact MongoDB operation. See UNIX ulimit Settings for more information.

The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodb by default, and runs using the mongodb user account. You can specify alternate log and data file directories in /etc/mongod.conf. See systemLog.path and storage.dbPath for additional information.

If you change the user that runs the MongoDB process, you must modify the access control rights to the /var/lib/mongodb and /var/log/mongodb directories to give this user access to these directories.

1. 启动 MongoDB 服务

命令启动MongoDB的 mongod 服务项。:

sudo systemctl start mongod 

2. 验证 MongoDB是否安装成功

查看MongoDB的日志文件 /var/log/mongodb/mongod.log,你可以看到类似这样的描述信息

[initandlisten] waiting for connections on port <port>
where <port> is the port configured in /etc/mongod.conf, 27017 by default.

你也可以通过命令过滤查看信息

cat /var/log/mongodb/mongod.log | grep port

默认端口是2701

3. 停止 MongoDB 服务

sudo systemctl stop mongod

4. 重启 MongoDB 服务

sudo systemctl restart mongod

5.设置开机启动或禁用 MOngoDB服务

设置开机启动:

sudo systemctl enable mongod

如果你不想开机启动,也可以禁用开机启动

sudo systemctl disable mongod

6. 开始使用 MongoDB

如果想获取帮助, MongoDB 提供了开始指导. 看看 开始指南 获取有用帮助信息。
在命令窗口输入 monogo进入MongoDB交互模式, Control+C 退出命令窗口,当然后台mongod必须在运行状态。

删除 MongoDB

To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.

警告: 这个删除MongoDB过程是不可逆的,包括程序配置文件、数据库文件都将被删除。所以,删除前,请备份好配置文件和数据库文件。

1. 停止 MongoDB 服务.

通过命令停止mongodb服务:

sudo systemctl stop mongod 

2. 删除软件.

移除已经安装的MongoDB程序。

sudo apt-get purge mongodb-org*

3. 删除数据目录.

删除 MongoDB 数据库文件和日志文件。

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb

https://wiki.deepin.org/index.php?title=MongoDB%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97&language=en

 

途中遇到过报错

dpkg: 处理归档 /var/cache/apt/archives/libexpat1-dev_2.2.5-3_amd64.deb (--unpack)时出错:

2018年12月12日 10:52:05 yamanda 阅读数:114

使用sudo apt-get install 安装软件的时候报错:

dpkg: 处理归档 /var/cache/apt/archives/libexpat1-dev_2.2.5-3_amd64.deb (--unpack)时出错:
 正试图覆盖 /usr/include/expat.h,它同时被包含于软件包 expat-devel 2.2.6-2
dpkg-deb: 错误: 子进程 粘贴 被信号(断开的管道) 终止了
在处理时有错误发生:
 /var/cache/apt/archives/libexpat1-dev_2.2.5-3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

终端输入  sudo dpkg -i --force-overwrite /var/cache/apt/archives/*.deb  然后再执行就没问题了

sudo apt --fix-broken install
 

 

 

忽略‘google-chrome.list.1’(于目录‘/etc/apt/sources.list.d/’),鉴于它的文件扩展名无效 问题的解决方法

在执行sudo apt-get update时出现题目中标题的错误,解决步骤如下: 
1. 将google-chrome.list.1文件的下载源复制到google-chrome.list(先清空)

sudo gedit /etc/apt/sources.list.d/google-chrome.list.1(复制其内容到清空后的google-chrome.list)
sudo gedit /etc/apt/sources.list.d/google-chrome.list(保存)
1
2
3
2.然后删除google-chrome.list.1文件

sudo rm -f /etc/apt/sources.list.d/google-chrome.list.1
--------------------- 
作者:GeraldJones 
来源:CSDN 
原文:https://blog.csdn.net/Gerald_Jones/article/details/80757479 
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值