标签:
mongodb-org 该包为元数据包,安装时将自动安装以下4个组件包
mongodb-org-server 该包包含mongod守护进程、相关配置和初始脚本 mongodb-org-mongos 该包包含mongos守护进程 mongodb-org-shell 该包包含mongo shell mongodb-org-tools 该包包含以下mongodb工具: mongoimport bsondump, mongodump,mongoexport, mongofiles, mongooplog, mongoperf, mongorestore, mongostat, andmongotop.
vi /etc/yum.repos.d/mongodb-org-3.0.repo
[mongodb-org-3.0] name=MongoDB Repository baseurl=http://repo.mongodb.org/yum/redhat/6/mongodb-org/3.0/x86_64/ gpgcheck=0 enabled=1
2. 安装MongoDB包和相关工具:
yum install -y mongodb-org
要是安装指定版本的MongoDB,应独立指定每个组件包和附加在包名后面的版本号,如:
sudo yum install -y mongodb-org-3.0.2 mongodb-org-server-3.0.2 mongodb-org-shell-3.0.2 mongodb-org-mongos-3.0.2 mongodb-org-tools-3.0.2
也可以定义任何可用的MongoDB版本,当有更新的版本时yum将自动更新Mongodb包。为了防止无意的的更新,可以在/etc/yum.conf中使用exclude指令,如:
exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools
3. 相关配置:
如果开启了防火墙,必须配置SELinux允许MongoDB运行在Red Hat系统或者CentOS Linux。 管理员应该设置以下3个选项: 1. 允许端口27017访问(没有则先下载工具semanage): yum -y install policycoreutils-python semanage port -a -t mongod_port_t -p tcp 27017 2. 在配置文件/etc/selinux/config设置SELinux模式为permissive: vi /etc/selinux/config SELINUX=enforcing 改为 SELINUX=permissive 3. 彻底禁用SELinux: SELINUX=disabled
vi /etc/mongod.conf
# mongod.conf #where to log logpath=/var/log/mongodb/mongod.log logappend=true # fork and run in background fork=true #port=27017 dbpath=/var/lib/mongo # location of pidfile pidfilepath=/var/run/mongodb/mongod.pid # Listen to local interface only. Comment out to listen on all interfaces. bind_ip=127.0.0.1 # Disables write-ahead journaling # nojournal=true # Enables periodic logging of CPU utilization and I/O wait #cpu=true # Turn on/off security. Off is currently the default #noauth=true #auth=true # Verbose logging output. #verbose=true # Inspect all client data for validity on receipt (useful for # developing drivers) #objcheck=true # Enable db quota management #quota=true # Set oplogging level where n is # 0=off (default) # 1=W # 2=R # 3=both # 7=W+some reads #diaglog=0 # Ignore query hints #nohints=true # Enable the HTTP interface (Defaults to port 28017). #httpinterface=true # Turns off server-side scripting. This will result in greatly limited # functionality #noscripting=true # Turns off table scans. Any query that would do a table scan fails. #notablescan=true # Disable data file preallocation. #noprealloc=true # Specify .ns file size for new databases. # nssize=<size> # Replication Options # in replicated mongo databases, specify the replica set name here #replSet=setname # maximum size in megabytes for replication operation log #oplogSize=1024 # path to a key file storing authentication info for connections # between replica set members #keyFile=/path/to/keyfile
4. 运行mongodb
设置Mongodb随系统自启动: chkconfig mongod on 启用Mongodb服务: service mongod start 验证Mongodb已成功启动:(查看日志是否有等待连接的信息) tail -5 /var/log/mongodb/mongod.log [initandlisten] waiting for connections on port <port>
直接在命令行输入 mongo 可进入数据库中:
至此,完成!~
官方参考:Install MongoDB on Red Hat Enterprise or CentOS Linux
MongoDB 基础(四)Red Hat Enterprise 6.4 x64 安装MongDB 3.0及配置
标签:
原文地址:http://blog.csdn.net/kk185800961/article/details/45427367