极其简易实用的mongodb安装(Linux)!!!

1.配置mongo的yum源

sudo vi /etc/yum.repos.d/mongodb-org-3.4.repo

#在该文件中添加如下代码
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc

2.关闭selinux(将SELINUX修改为 SELINUX=disabled)

sudo vi /etc/sysconfig/selinux 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

3.重新启动虚拟机

reboot

4.待重启完成后,执行如下命令(本地安装给你了rpm包,rpm -ivh *.rpm)

sudo yum install -y mongodb-org

5.接下来找到文件存储的地方进行手动安装

find   /   -name mongodb-org-3.4

6.然后执行下面命令,全部安装

rpm -ivh *.rpm

7.#修改mongo的配置文件

sudo vi /etc/mongod.conf 
#注释掉bindIp,如果不注释掉其他机器不能访问进去,相当于防火墙一样
#  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.

8.#启动mongo

[hadoop@hadoop01 packages]$ sudo service mongod start
Starting mongod:                                           [  OK  ]

9.启动成功如下所示

[hadoop@hadoop01 packages]$ mongo
MongoDB shell version v3.4.18
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.18
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	http://docs.mongodb.org/
Questions? Try the support group
	http://groups.google.com/group/mongodb-user
Server has startup warnings: 
2019-01-09T15:54:20.083+0800 I STORAGE  [initandlisten] 
2019-01-09T15:54:20.083+0800 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-01-09T15:54:20.083+0800 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-01-09T15:54:20.185+0800 I CONTROL  [initandlisten] 
2019-01-09T15:54:20.185+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-01-09T15:54:20.185+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] 
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] 
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] 
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] 
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
2019-01-09T15:54:20.186+0800 I CONTROL  [initandlisten] 
> show dbs;
admin  0.000GB
local  0.000GB

你可能感兴趣的:(Mongodb)