Centos6.X 安装MongoDb
1、查看linux版本,之所以查看linux版本,是因为centos7和以前版本用的防火墙不一样,安装完mongodb后,需要关闭防火墙(或者其他方法,专业运维人员使用,我们这里为简单,直接关闭即可)才可以让其他电脑访问到,
cat /etc/redhat-release
2、以下步骤完全按照mongodb 官方文档操作:
Configure the package management system (yum).
Create a /etc/yum.repos.d/mongodb-org-3.2.repo file so that you can install MongoDB directly, using yum.
touch /etc/yum.repos.d/mongodb-org-3.2.repo #新建文件
vi /etc/yum.repos.d/mongodb-org-3.2.repo #编辑文件
运行上面的命令,打开文件后,按键盘i键,编辑此文件,直接复制如下内容带文件,然后按Esc 键,再按shift+:键,就是打出一个冒号,然后按x键,保存,不熟悉vi命令的童鞋看这个,熟悉的飘过
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
3、安装最新版的mongodb
To install the latest stable version of MongoDB, issue the following command:
sudo yum install -y mongodb-org
4、启动mongodb
You can start the mongod process by issuing the following command:
sudo service mongod start
sudo service mongod status # 查看mongodb 状态
5、设置开机启动
You can optionally ensure that MongoDB will start following a system reboot by issuing the following command:
sudo chkconfig mongod on
6、停止mongodb
Stop MongoDB.
As needed, you can stop the mongod process by issuing the following command:
sudo service mongod stop
7、重启mongodb
Restart MongoDB.
You can restart the mongod process by issuing the following command:
sudo service mongod restart
8、设置局域网其他电脑可访问(重点)
sudo vi /etc/mongod.conf
找到这一段,将默认的127.0.0.1 改为 0.0.0.0
net:
port: 27017
bindIp: 0.0.0.0 # Listen to local interface only, comment to listen on all interfaces.
9、关闭防火墙
sudo service iptables stop #即时生效,重启后会失效,默认会开启防火墙
sudo chkconfig iptables off #防火墙关闭,重启后也是关闭状态
sudo service iptables start # 开启防火墙
sudo chkconfig iptables on #防火墙开启
sudo service iptables status #查看防火墙状态
CentOS 7.0默认使用的是firewall作为防火墙
firewall-cmd --state # 查看防火墙状态
systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动
10、官网上有这么一段:
To configure SELinux, administrators have three options:
- If SELinux is in enforcing mode, enable access to the relevant ports that the MongoDB deployment will use (e.g. 27017). 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 mongod_port_t -p tcp 27017
经本人测试,无需理会,可以忽略,如果有的同学执行这条命令提示:
semanage SELinux Command Not Found
,可以按照以下步骤安装semanage,运行下面两条命令中的任意一条即可,
yum provides /usr/sbin/semanage
或者:
yum whatprovides /usr/sbin/semanage
执行后输出类似这样的内容:
Loaded plugins: rhnplugin
policycoreutils-python-2.0.83-19.8.el6_0.x86_64 : SELinux policy core python utilities
Repo : rhel-x86_64-server-6
Matched from:
Filename : /usr/sbin/semanage
policycoreutils-python-2.0.83-19.1.el6.x86_64 : SELinux policy core python utilities
Repo : rhel-x86_64-server-6
Matched from:
Filename : /usr/sbin/semanage
然后执行下面这条命令:
yum -y install policycoreutils-python
11、卸载mongodb
Uninstall MongoDB
Remove Packages.
Remove any MongoDB packages that you had previously installed.
sudo yum erase $(rpm -qa | grep mongodb-org)
Remove Data Directories.
Remove MongoDB databases and log files.
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongo
这里友谊提醒一句,使用rm -rf 删除文件夹的时候注意一下,据说centos6以下的版本,如果手一抖写成这样 rm -rf / (/后加空格),那么你的系统就被你活活的干掉了,这个本人木有亲测,熟悉linux的大神帮确认一下,据说京东曾经出现过这样的案例,某位运维人员手一抖系统木有啦,哈哈
参考官方文档:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Centos6.X 安装MongoDb的更多相关文章
- 阿里云CentOS6.3 安装MongoDB教程
安装说明 系统环境:Centos-6.3安装软件:mongodb-linux-x86_64-2.2.2.tgz下载地址:http://www.mongodb.org/downloads安装机器:192 ...
- 在CENTOS6上安装MONGODB
为接下来的工作热一下手.. 以前看过一本书,了解了,但好像有三四年,又忘了..:( 参考URL: http://www.centoscn.com/image-text/install/2014/112 ...
- RedHat6/Centos6.5安装mongodb
1 设置mongodb目录 [root@localhost /]# cd home/ [root@localhost home]# mkdir mongodb/db 2 配置yum [root@loc ...
- CentOS6.4 安装MongoDB
1.下载MongoDB(64位) http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz 或 http://pan.baidu.c ...
- centos6.5安装mongodb
搜索正面五个文件,由于MongoDB的redhat国外镜像访问非常慢,下载安装suse版本并安装: mongodb-org-2.6.6-1.i686.rpm mongodb-org-mongos-2. ...
- RedHat6/Centos6.5安装mongodb php driver
条件: 安装apache 安装php 1.下载mongodb phh driver 下载地址:pecl wget http://pecl.php.net/get/mongo-1.5.8.tgz 2.解 ...
- linux安装mongodb并启动
CentOS6.4 安装MongoDB 1.下载MongoDB(64位) http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tg ...
- CentOS6.3安装MongoDB2.2 及 安装PHP的MongoDB客户端
下载源码:(放到 /usr/local/src 目录下) 到官网 http://www.mongodb.org/downloads 下载源码 https://fastdl.mongodb.org/li ...
- CentOS6.5下安装mongodb
MongoDB是目前最常用的NoSQL-非关系型数据库. 本文将介绍在CentOS下如何通过yum安装MongoDB. 1.首先在CentOS6.5下,编辑Mongo的yum源: 在/etc/yum. ...
随机推荐
- Strategy Pattern(策略模式)
Head First定义: 策略模式定义了算法族,分别封装起来,让他们之间可以互相替换,此模式让算法的变化独立于使用算法的客户. 策略模式的设计原则主要有三个: 找出应用中可能需要变化的部分,把它们独 ...
- http网络通信--页面源代码查看
1.要在andorid中实现网络图片查看,涉及到用户隐私问题,所以要在AndroidManifest.xml中添加访问网络权限 <uses-permission android:name=&qu ...
- 使用HTML5画布(canvas)生成阴影效果
来源:GBin1.com 使用HTML5的画布特性,我们可以创建图形,在这片文章中,我们将创建图形的阴影. var canvas = document.getElementById('shadowca ...
- 常用class 总结
清除浮动 // Clearfix @mixin clearfix { &:before, &:after { content: " "; // 1 display: ...
- 解决Xcode 6 编译Cocos2d-x iOS项目失败
在Xcode 6 beta里编译Cocos2d-x iOS项目时可能会失败,提示如下错误: Undefined symbols for architecture i386: "_fwrite ...
- CDN新应用和客户
目前的CDN配置服务主要应用于证券.金融保险.ISP.ICP.网上交易.门户网站.大中型公司.网络教学等领域.另外在行业专网.互联网中都可以用到,甚至可以对局域网进行网络优化.利用CDN,这些网站无需 ...
- 操作系统开发之——一个简单的Bootsect
先吓唬一下读者朋友呵呵,直接发代码:(这是UOS操作系统的Bootsect)(有兴趣的朋友能够增加我们,联系方式在最后) ;------------------------------ ;文件名称:B ...
- android adb 权限改动
1. 改动 ADB ROOT权限: system/core$ git diff adb/adb.c diff --git a/adb/adb.c b/adb/adb.c index 99bea0f.. ...
- angular 禁止事件冒泡 和 默认行为
事件冒泡和事件捕捉一直以来都是被讨论的话题,也许大家平时在工作中没有遇到过需要解决事件冒泡的情况举个例子: <body ng-click="fun1()"> <d ...
- C# 操作ini配置文件
最近使用Winform做一个小系统,由于需要保存一些默认配置项.自然就想到了轻量级的配置文件类型ini.在此也分享和记录一下实现方式,方便以后查询和使用. 废话不多说上代码: 实现公共函数↓ publ ...