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. ...
随机推荐
- [Python爬虫] 之十六:Selenium +phantomjs 利用 pyquery抓取一点咨询数据
本篇主要是利用 pyquery来定位抓取数据,而不用xpath,通过和xpath比较,pyquery效率要高. 主要代码: # coding=utf-8 import os import re fro ...
- java 获取进程的processId
package us.mine.demo.jvm.util; import java.lang.management.ManagementFactory; import java.lang.manag ...
- android适配的努力
1. 优测 http://utest.qq.com/ 2. 云测 3. 阿里云移动 4. 百度移动测试.
- JMS之——ActiveMQ高可用+负载均衡集群
一.高可用集群 从ActiveMQ5.9开始,ActiveMQ的集群实现方式取消了传统的Master-Slave方式,增加了基于ZooKeeper+LevelDB的Master-Slave实现方式,其 ...
- [HTML5] Track First Contentful Paint with PerformanceObserver and Google Analytics
"If you can't measure it, you can't improve it." The first step when doing performance wor ...
- Ubuntu安装Mac皮肤
如果是ubuntu的PC版,在稳定性方面的要求不是非常高,而又想换换界面养养眼,像我一般只用我的Ubuntu12.04来写写代码,娱乐娱乐的,可以试试Ubuntu的Mac皮肤. 好了,废话不多说,上图 ...
- 如何让你的webapp也能跳窗口搜索
目前很多手机app或者一些webapp,搜索栏基本采用跳窗口的搜索方式 怎么做 实现方式: 1.在触发外层的input的时候打开个modal层,默认打开该modal层的时候就触发了moda里面的inp ...
- 让你的 wowza server提供 RESTful web 服务
有时我们 nginx 须要和 wowza 服务器交互以进行一些 LB 事宜:有时我们的管理员须要实时了解 wowza 服务器的一些其它状态信息(比方一些自己定义对象的状态等等).而用 ...
- STL源码剖析(set/map)
SGI STL中set/map底层都是通过RB-tree实现的. 首先看看RB-tree结点的定义 typedef bool __rb_tree_color_type; const __rb_tree ...
- RandomForest&ROC
# -*- coding: utf-8 -*- # __author__ = 'JieYao' from biocluster.agent import Agent from biocluster.t ...