设为首页 收藏本站
查看: 1031|回复: 0

[经验分享] mongodb的安装/配置(文件)/启动 问题

[复制链接]

尚未签到

发表于 2018-10-26 12:48:58 | 显示全部楼层 |阅读模式
  mongodb的安装/配置(文件)/启动 问题
  下载地址:http://www.mongodb.org/downloads
  [root@centos-1 software]# ll | grep   mongodb-linux-x86_64-2.4.12.tar
  -rw-r--r--.  1 root root 95267358 1月   6 11:02 mongodb-linux-x86_64-2.4.12.tar
  [root@centos-1 software]# tar  -xvf  mongodb-linux-x86_64-2.4.12.tar
  [root@centos-1 software]# cd  mongodb-linux-x86_64-2.4.12
  [root@centos-1 mongodb-linux-x86_64-2.4.12]# ll
  总用量 64
  drwxr-xr-x. 2 root   root    4096 1月   7 13:13 bin
  -rw-------. 1 nagios nagios 34520 8月   4 2013 GNU-AGPL-3.0
  -rw-------. 1 nagios nagios  1359 8月   4 2013 README
  -rw-------. 1 nagios nagios 18436 8月   4 2013 THIRD-PARTY-NOTICES
  将ongodb-linux-x86_64-2.4.12 文件全部cp到 /usr/local/mongodb
  [root@centos-1 mongodb-linux-x86_64-2.4.12]# cp -rf  *  /usr/local/mongodb/
  [root@centos-1 mongodb]# cd  /usr/local/mongodb
  创建数据目录:
  [root@centos-1 mongodb]# mkdir  data
  创建日志文件:
  [root@centos-1 mongodb]# touch  logs
  [root@centos-1 mongodb]# cd  bin
  [root@centos-1 bin]# pwd
  /usr/local/mongodb/bin
  [root@centos-1 bin]# ll
  总用量 237824
  -rwxr-xr-x. 1 root root 18316272 1月   6 14:30 bsondump
  -rwxr-xr-x. 1 root root  9537192 1月   6 14:30 mongo
  -rwxr-xr-x. 1 root root 18376872 1月   6 14:30 mongod
  -rwxr-xr-x. 1 root root 18373328 1月   6 14:30 mongodump
  -rwxr-xr-x. 1 root root 18328816 1月   6 14:30 mongoexport
  -rwxr-xr-x. 1 root root 18377760 1月   6 14:30 mongofiles
  -rwxr-xr-x. 1 root root 18340944 1月   6 14:30 mongoimport
  -rwxr-xr-x. 1 root root 18320432 1月   6 14:30 mongooplog
  -rwxr-xr-x. 1 root root 18320080 1月   6 14:30 mongoperf
  -rwxr-xr-x. 1 root root 18381296 1月   6 14:30 mongorestore
  -rwxr-xr-x. 1 root root 13868984 1月   6 14:30 mongos
  -rwxr-xr-x. 1 root root 18286728 1月   6 14:30 mongosniff
  -rwxr-xr-x. 1 root root 18366064 1月   6 14:30 mongostat
  -rwxr-xr-x. 1 root root 18320944 1月   6 14:30 mongotop
  将文件 mongo(客服端命令)/mongod(mongo启动命令)cp到/usr/bin(是这两个命令成为全局命令)
  [root@centos-1 bin]# cp  mongod /usr/bin/
  [root@centos-1 bin]# cp  mongo /usr/bin/
  创建mongo的配置文件:
  [root@centos-1 bin]# touch  /etc/mongodb.conf
  文件中配置一下参数即可。
  # 配置文件存放在/etc/mongod.conf
  # ------------------------------一下是内容---------------------------------------
  # mongo.conf
  # 数据库文件保存位置
  dbpath=/usr/local/mongodb/data
  # 日志文件的保存位置
  logpath=/usr/local/mongodb/logs
  # 日志的记录方式,日志以添加的方式保存
  logappend=true
  # 需要身份验证
  auth=true
  # 运行端口
  port=27017
  # 在后台运行
  fork=true
  # pid 文件路径
  pidfilepath=/usr/local/mongodb/mongodb.pid
  启动mongodb服务:
  [root@centos-1 bin]# mongod  --config=/etc/mongodb.conf
  about to fork child process, waiting until server is ready for connections.
  forked process: 30913
  all output going to: /usr/local/mongodb/logs
  child process started successfully, parent exiting
  查看服务是否成功启动:
  [root@centos-1 bin]# netstat -lanp | grep "27017"
  unix  2      [ ACC ]     STREAM     LISTENING     211915 30932/mongod        /tmp/mongodb-27017.sock
  关闭mongodb服务:
  [root@centos-1 bin]# mongod  --dbpath=/usr/local/mongodb/data  --shutdown
  killing process with pid: 30913
  配置mongodb服务为开机启动:将 mongod  --config=/etc/mongodb.conf 添加到/etc/rc.local
  [root@centos-1 bin]# vi /etc/rc.local
  #!/bin/sh
  #
  # This script will be executed *after* all the other init scripts.
  # You can put your own initialization stuff in here if you don't
  # want to do the full Sys V style init stuff.
  mongod  --config=/etc/mongodb.conf
  touch /var/lock/subsys/local
  /usr/local/net-snmp/sbin/snmpd -c /etc/snmpd.con
  =======以上就是mongodb的配置和安装===============================================================
  mongodb.conf启动参数
  配置文件存放在/etc/mongod.conf
  #------------------------------一下是内容---------------------------------------
  # mongo.conf
  # 日志文件存放位置
  logpath=/var/log/mongo/mongod.log
  # 以追加方式写入日志
  logappend=true
  # 是否已守护进程方式运行(后台运行)
  fork = true
  # 设置端口(默认27017)
  #port = 27017
  # 数据库文件保存位置
  dbpath=/var/lib/mongo
  # Enables periodic logging of CPU utilization and I/O wait
  # 启用定期记录CPU利用率和 I/O 等待
  #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
  # 启用数据库配额管理,默认每个db可以有8个文件,可以用quotaFiles参数设置
  #quota = true
  # 设置oplog记录等级
  # Set oplogging level where n is
  #   0=off (default)
  #   1=W
  #   2=R
  #   3=both
  #   7=W+some reads
  #oplog = 0
  # Diagnostic/debugging option 动态调试项
  #nocursors = true
  # Ignore query hints 忽略查询提示
  #nohints = true
  # 禁用http界面,默认为localhost:28017
  # Disable the HTTP interface (Defaults to localhost:27018).这个端口号写的是错的
  #nohttpinterface = 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
  # 为新数据库指定.ns文件的大小,单位:MB

  # Specify .ns file>  # nssize =
  # Accout token for Mongo monitoring server.
  #mms-token =
  # mongo监控服务器的名称
  # Server name for Mongo monitoring server.
  #mms-name =
  # mongo监控服务器的ping 间隔
  # Ping interval for Mongo monitoring server.
  #mms-interval =
  # Replication Options 复制选项
  # in replicated mongo databases, specify here whether this is a slave or master 在复制中,指定当前是从属关系
  #slave = true
  #source = master.example.com
  # Slave only: specify a single database to replicate
  #only = master.example.com
  # or
  #master = true
  #source = slave.example.com
  =====================================
  个人对部分分重要参数的理解:
  --dbpath:数据存放目录,mongodb启动的必带参数。
  –logpath:日志存放文件,mongodb启动时如果没有带这个参数。
  --logappend:日志以追加的方式写入日志文件。
  --auth:登陆到mongo的用户必须验证身份(提供密码和账号),空账号可登陆但是无权限操作DB,
  启动的时候如果没有指定此参数,那么登陆到mongo的用户具有所有的权限(不安全),
  admin架构中的用户权限最大,可以查询其他任何架构中的信息,其他架构中的用户只能查看自己架构中的信息。
  –-port:指定端口
  --shutdown:关闭mongo服务
  --fork:在后台运行,此参数必须同--logpath一起使用。
  参考链接:
  http://blog.csdn.net/yuwenruli/article/details/8529192
  http://www.it165.net/database/html/201402/5303.html


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-626789-1-1.html 上篇帖子: MongoDB Sharding学习理论篇 下篇帖子: MongoDB Sharding学习操作篇
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表