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.
通过标准的yum源安装完成后,会生成如下几个目录:
/var/lib/mongo #数据库目录
/var/log/mongdb #日志目录
/etc/mongodb.conf #主配置文件提示:对于大批量安装,可以将安装包缓存到本地,在内网上搭一个mongodb yum源。
yum --downloadonly --downloaddir=/mongodb mongodb-org#静默下载指定的软件包到指定的目录