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. ...
随机推荐
- Java笔记18:JUnit单元测试
1 从http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22junit%22%20AND%20a%3A%22junit%22 上下载最新的junit包. ...
- conkey conf
update_interval 1.0 # 更新时间间隔double_buffer yes # 双缓存,解决Conky闪烁问题use_xft yes # 自定义字体xftfont DejaVu San ...
- [Functional Programming Monad] Substitute State Using Functions With A State Monad (get, evalWith)
We take a closer look at the get construction helper and see how we can use it to lift a function th ...
- Linux C高级编程——网络编程之以太网(2)
Linux网络编程--以太网 宗旨:技术的学习是有限的,分享的精神是无限的. 1.以太网帧格式 源地址和目的地址是指网卡的硬件地址(也叫MAC地址),长度是48位,是在网卡出厂时固化的.用ifconf ...
- Android fragment 切换载入数据卡顿问题
接着上一篇项目的进度.上一篇讲了怎样利用fragment来实现下拉菜单.公用菜单,以实现切换主界面数据的功能,这时候遇到的问题是:使用了fragment的切换界面方法.但载入的数据太多.用户从一个界面 ...
- Java程序的结构
1.由一个或多个独立的类组成: 2.最多一个公有类 3.源代码文件名必须与类名相同 4.类由一个或多个方法组成,其中公有类中的main()方法作为程序的入口. 注:javaSE中一定有main方法. ...
- HBase - 计数器 - 计数器的介绍以及使用 | 那伊抹微笑
博文作者:那伊抹微笑 csdn 博客地址:http://blog.csdn.net/u012185296 itdog8 地址链接 : http://www.itdog8.com/thread-215- ...
- Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别
utf8_unicode_ci和utf8_general_ci对中.英文来说没有实质的差别.utf8_general_ci 校对速度快,但准确度稍差.utf8_unicode_ci 准确度高,但校对速 ...
- ORA-01400: 无法将 NULL 插入 ("CHARGE_WQRL"."SF_JMQTFY_T"."BH")
[ERROR] JmCheckManageDaoImpl:901 - java.sql.SQLException: ORA-01400: 无法将 NULL 插入 ("CHARGE_WQRL& ...
- Python-深入理解元类(metaclass)
1.使用 type 动态创建类(type 是一个类, 用来创建类对象的元类, 所以也可以继承) type("Person", (), {"name": &quo ...