mongoDB yum安装
yum安装mongoDB
官方网站
http://www.mongodb.org/downloads
以下截取至mongodb官网
一.配置yum源
Configure the package management system (YUM).
Create a /etc/yum.repos.d/mongodb.repo file to hold the following configuration information for the MongoDB repository:
If you are running a 64-bit system, use the following configuration:
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
提示:可以使用国内源
CentOS6http://mirrors.aliyun.com/mongodb/yum/redhat/6/mongodb-org/stable/x86_64/
CentOS7http://mirrors.aliyun.com/mongodb/yum/redhat/7/mongodb-org/stable/x86_64/
二.安装mongoDB
Install the MongoDB packages and associated tools.
When you install the packages, you choose whether to install the current release or a previous one. This step provides the commands for both.
To install the latest stable version of MongoDB, issue the following command:
sudo yum install -y mongodb-org
To install a specific release of MongoDB, specify each component package individually and append the version number to the package name, as in the following example that installs the 2.6.1` release of MongoDB:
sudo yum install -y mongodb-org-2.6.1 mongodb-org-server-2.6.1 mongodb-org-shell-2.6.1 mongodb-org-mongos-2.6.1 mongodb-org-tools-2.6.1
You can specify any available version of MongoDB. However yum will upgrade the packages when a newer version becomes available. To prevent unintended upgrades, pin the package. To pin a package, add the following exclude directive to your /etc/yum.conf file:
exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools
Previous versions of MongoDB packages use different naming
conventions.
See the 2.4
version of documentation
for more information.
通过标准的yum源安装完成后,会生成如下几个目录:
/var/lib/mongo
/var/log/mongdb
提示:对于大批量安装,可以将安装包缓存到本地,在内网上搭一个mongodb yum源。
yum --downloadonly --downloaddir=/mongodb mongodb-org
三.启动mongoDB
注意:如果启用了selinux,则需要解决非标准端口访问问题。
You must configure SELinux to allow MongoDB to start on Red Hat Linux-based systems (Red Hat Enterprise Linux, CentOS, Fedora). Administrators have three options:
-
enable access to the relevant ports (e.g. 27017) for SELinux. See Default MongoDB Port for more information on MongoDB’s default ports. For default settings, this can be accomplished by running
semanage port -a -t mongodb_port_t -p tcp 27017
service mongod start
2.加入开机启动项
chkconfig mongod on
3.查看日志
tail -f /var/log/mongodb/mongod.log