MongoDB数据库安装指南 Edit
Revision history
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.
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.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
你可以选择安装 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"。
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo mkdir /home/mongodb
sudo chown -R mongodb:mongodb /home/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.
命令启动MongoDB的 mongod 服务项。:
sudo systemctl start mongod
查看MongoDB的日志文件 /var/log/mongodb/mongod.log,你可以看到类似这样的描述信息
[initandlisten] waiting for connections on port
where is the port configured in /etc/mongod.conf, 27017 by default.
你也可以通过命令过滤查看信息
cat /var/log/mongodb/mongod.log | grep port
默认端口是2701
sudo systemctl stop mongod
sudo systemctl restart mongod
设置开机启动:
sudo systemctl enable mongod
如果你不想开机启动,也可以禁用开机启动
sudo systemctl disable mongod
如果想获取帮助, MongoDB 提供了开始指导. 看看 开始指南 获取有用帮助信息。
在命令窗口输入 monogo进入MongoDB交互模式, Control+C 退出命令窗口,当然后台mongod必须在运行状态。
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过程是不可逆的,包括程序配置文件、数据库文件都将被删除。所以,删除前,请备份好配置文件和数据库文件。
通过命令停止mongodb服务:
sudo systemctl stop mongod
移除已经安装的MongoDB程序。
sudo apt-get purge mongodb-org*
删除 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
途中遇到过报错
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
版权声明:本文为博主原创文章,转载请附上博文链接!