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. ...
随机推荐
- iis服务器配置 url rewrite 模块
从网上找了一下,原来微软IIS官方网站给IIS7及以后续版本提供了个URL重写组件. 下载地址:https://www.iis.net/downloads/microsoft/url-rewrite ...
- 浏览器兼容性问题解决方案之CSS,已在IE、FF、Chrome测试
当前主浏览器的核心是什么? 1) Trident:IE浏览器使用的内核,该内核程序在1997年的IE4中首次被采用,是微软在Mosaic代码的基础之上修改而来的,并沿用到目前的 IE7.Trident ...
- B. Vanya and Books( Codeforces Round #308 (Div. 2) 简单题)
B. Vanya and Books time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Android资源图片读取机制
在新建一个Android项目时.在res目录下会自己主动生成几个drawable目录,drawable-ldpi,drawable-mdpi,drawable-hdpi,一直以来都对此不太清楚.图片应 ...
- 08-session详解
如何获取session对象? 1,openSession 2,getCurrentSession 如果使用getCurrentSession需要在hibernate.cfg.xml文件中进行配置: 如 ...
- struts2 常用标签
版权声明:本文为博主原创文章,未经博主允许不得转载. Struts2可以将所有标签分成3类: 准备工作:需要在JSP页面引入标签库 <%@ taglib prefix="s" ...
- log4j 配置(转)
log4j是干什么的 log4j是Apache的一个开源项目,主要功能是打印日志信息,以各种形式在各种地方花式打印日志. 使用log4j的准备工作 使用log4j就必须要引入其jar包.附上官网地址h ...
- cookie技术自动登录
user public class User implements Serializable{ private String username; private String nick; privat ...
- Linux 下Tomcat的启动、关闭、杀死进程
Linux下Tomcat的启动.关闭.杀死进程 打开终端 cd /java/tomcat #执行 bin/startup.sh #启动tomcat bin/shutdown.sh #停止tomcat ...
- Android studio 使用心得(六)—android studio 如何加载.so文件
之前一直没怎么注意,以为.so文件android为像eclipse一样直接加载,但是直到昨天我在android studio上调试公司项目推送消息的时候,才发现,.so文件原来没有加载成功. 可能之前 ...