CentOS中使用yum安装配置MongoDB

来源:互联网 发布:阿里云 鹰眼 编辑:程序博客网 时间:2024/04/29 18:07

1.运行yum命令查看MongoDB的包信息

 [root@vm ~]# yum info mongo-10gen 

2.若无相关匹配信息,则需在 /etc/yum.repos.d/目录中增加 *.repo yum源配置文件

3.配置合适的yum源

    vi /etc/yum.repos.d/10gen.repo 

  64位系统yum源配置

  1. [10gen]  
  2. name=10gen Repository  
  3. baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64  
  4. gpgcheck=0  

 32位系统yum源配置

  1. [10gen]  
  2. name=10gen Repository  
  3. baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686  
  4. gpgcheck=0  
4.查看mongoDB的服务器包的信息 

[root@localhost Desktop]# yum info  mongo-10gen-server
Loaded plugins: fastestmirror, refresh-packag

       .....................................................................................

       Available Packages
Name        : mongo-10gen-server
Arch        : x86_64
Version     : 2.4.14
Release     : mongodb_1
Size        : 12 M
Repo        : 10gen
Summary     : mongo server, sharding server, and support scripts
URL         : http://www.mongodb.org
License     : AGPL 3.0
Description : Mongo (from "huMONGOus") is a schema-free document-oriented database.
            : 
            : This package provides the mongo server software, mongo sharding server
            : softwware, default configuration files, and init.d scripts.

5.查看客户端工具的信息

[root@localhost Desktop]# yum info mongo-10gen 
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile

   .....................................................................................

Name        : mongo-10gen
Arch        : x86_64
Version     : 2.4.14
Release     : mongodb_1
Size        : 72 M
Repo        : 10gen
Summary     : mongo client shell and tools
URL         : http://www.mongodb.org
License     : AGPL 3.0
Description : Mongo (from "huMONGOus") is a schema-free document-oriented database.
            : It features dynamic profileable queries, full indexing, replication
            : and fail-over support, efficient storage of large binary data objects,
            : and auto-sharding.
            : 
            : This package provides the mongo shell, import/export tools, and other
            : client utilities.

6.安装服务器端:

   [root@localhost Desktop]# yum install mongo-10gen-server
   Loaded plugins: fastestmirror, refresh-packagekit, security
   Setting up Install Process

7.安装客户端:

 [root@localhost Desktop]# yum install  mongo-10gen -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile

8.服务器配置: /etc/mongod.conf  

  1.  
  2.   
  3. [root@vm ~]# cat /etc/mongod.conf  
  4. # mongo.conf  
  5.   
  6. #where to log  
  7. logpath=/var/log/mongo/mongod.log  
  8.   
  9. logappend=true #以追加方式写入日志  
  10.   
  11. # fork and run in background  
  12. fork = true  
  13.   
  14. #port = 27017 #端口  
  15.   
  16. dbpath=/var/lib/mongo #数据库文件保存位置  
  17.   
  18. # Enables periodic logging of CPU utilization and I/O wait  
  19. #启用定期记录CPU利用率和 I/O 等待  
  20. #cpu = true  
  21.   
  22. # Turn on/off security.  Off is currently the default  
  23. # 是否以安全认证方式运行,默认是不认证的非安全方式  
  24. #noauth = true  
  25. #auth = true  
  26.   
  27. # Verbose logging output.  
  28. # 详细记录输出  
  29. #verbose = true  
  30.   
  31. # Inspect all client data for validity on receipt (useful for  
  32. # developing drivers)用于开发驱动程序时的检查客户端接收数据的有效性  
  33. #objcheck = true  
  34.   
  35. # Enable db quota management 启用数据库配额管理,默认每个db可以有8个文件,可以用quotaFiles参数设置  
  36. #quota = true  
  37. # 设置oplog记录等级  
  38. # Set oplogging level where n is  
  39. #   0=off (default)  
  40. #   1=W  
  41. #   2=R  
  42. #   3=both  
  43. #   7=W+some reads  
  44. #oplog = 0  
  45.   
  46. # Diagnostic/debugging option 动态调试项  
  47. #nocursors = true  
  48.   
  49. # Ignore query hints 忽略查询提示  
  50. #nohints = true  
  51. # 禁用http界面,默认为localhost:28017  
  52. # Disable the HTTP interface (Defaults to localhost:27018).这个端口号写的是错的  
  53. #nohttpinterface = true  
  54.   
  55. # 关闭服务器端脚本,这将极大的限制功能  
  56. # Turns off server-side scripting.  This will result in greatly limited  
  57. # functionality  
  58. #noscripting = true  
  59. # 关闭扫描表,任何查询将会是扫描失败  
  60. # Turns off table scans.  Any query that would do a table scan fails.  
  61. #notablescan = true  
  62. # 关闭数据文件预分配  
  63. # Disable data file preallocation.  
  64. #noprealloc = true  
  65. # 为新数据库指定.ns文件的大小,单位:MB  
  66. # Specify .ns file size for new databases.  
  67. # nssize = <size>  
  68.   
  69. # Accout token for Mongo monitoring server.  
  70. #mms-token = <token>  
  71. # mongo监控服务器的名称  
  72. # Server name for Mongo monitoring server.  
  73. #mms-name = <server-name>  
  74. # mongo监控服务器的ping 间隔  
  75. # Ping interval for Mongo monitoring server.  
  76. #mms-interval = <seconds>  
  77.   
  78. # Replication Options 复制选项  
  79.   
  80. # in replicated mongo databases, specify here whether this is a slave or master 在复制中,指定当前是从属关系  
  81. #slave = true  
  82. #source = master.example.com  
  83. # Slave only: specify a single database to replicate  
  84. #only = master.example.com  
  85. # or  
  86. #master = true  
  87. #source = slave.example.com  

  88. [root@vm ~]# mongod -h  
  89. Allowed options:  
  90.   
  91. General options:  
  92.   -h [ --help ]          show this usage information  
  93.   --version              show version information  
  94.   -f [ --config ] arg    configuration file specifying additional options 指定启动配置文件路径  
  95.   -v [ --verbose ]       be more verbose (include multiple times for more  
  96.                          verbosity e.g. -vvvvv)  
  97.   --quiet                quieter output  
  98.   --port arg             specify port number 端口  
  99.   --bind_ip arg          comma separated list of ip addresses to listen on -  
  100.                          all local ips by default 绑定ip,可以多个  
  101.   --maxConns arg         max number of simultaneous connections 最大并发连接数  
  102.   --logpath arg          log file to send write to instead of stdout - has to  
  103.                          be a file, not directory 日志文件路径  
  104.   --logappend            append to logpath instead of over-writing 日志写入方式  
  105.   --pidfilepath arg      full path to pidfile (if not set, no pidfile is  
  106.                          created) pid文件路径  
  107.   --keyFile arg          private key for cluster authentication (only for  
  108.                          replica sets)集群认证私钥,仅适用于副本集  
  109.   --unixSocketPrefix arg alternative directory for UNIX domain sockets  
  110.                          (defaults to /tmp)替代目录  
  111.   --fork                 fork server process  
  112.   --auth                 run with security 使用认证方式运行  
  113.   --cpu                  periodically show cpu and iowait utilization 定期显示的CPU和IO等待利用率  
  114.   --dbpath arg           directory for datafiles 数据库文件路径  
  115.   --diaglog arg          0=off 1=W 2=R 3=both 7=W+some reads oplog记录等级  
  116.   --directoryperdb       each database will be stored in a separate directory  
  117.                          每个数据库存储到单独目录  
  118.   --journal              enable journaling 记录日志,建议开启,在异常宕机时可以恢复一些数据  
  119.   --journalOptions arg   journal diagnostic options  
  120.   --ipv6                 enable IPv6 support (disabled by default)  
  121.   --jsonp                allow JSONP access via http (has security  
  122.                          implications)允许JSONP通过http访问,该方式存在安全隐患  
  123.   --noauth               run without security 不带安全认证的方式  
  124.   --nohttpinterface      disable http interface 禁用http接口  
  125.   --noprealloc           disable data file preallocation - will often hurt  
  126.                          performance 禁用数据文件的预分配,往往会损害性能  
  127.   --noscripting          disable scripting engine 禁用脚本引擎  
  128.   --notablescan          do not allow table scans 不允许表扫描  
  129.   --nounixsocket         disable listening on unix sockets禁止unix sockets监听  
  130.   --nssize arg (=16)     .ns file size (in MB) for new databases 为新数据设置.ns文件的大小  
  131.   --objcheck             inspect client data for validity on receipt 检查在收到客户端的数据的有效性  
  132.   --profile arg          0=off 1=slow, 2=all  
  133.   --quota                limits each database to a certain number of files (8  
  134.                          default)启用数据库配额管理,默认每个db可以有8个文件,可以用quotaFiles参数设置  
  135.   --quotaFiles arg       number of files allower per db, requires --quota  
  136.   --rest                 turn on simple rest api 开启rest api  
  137.   --repair               run repair on all dbs 修复所有数据库  
  138.   --repairpath arg       root directory for repair files - defaults to dbpath修复文件的根目录,默  
  139.                          认为dbpath指定的目录  
  140.   --slowms arg (=100)    value of slow for profile and console log  
  141.   --smallfiles           use a smaller default file size  
  142.   --syncdelay arg (=60)  seconds between disk syncs (0=never, but not  
  143.                          recommended)与硬盘同步数据的时间,默认60秒,0表示不同步到硬盘(不建议)  
  144.   --sysinfo              print some diagnostic system information打印一些诊断系统信息  
  145.   --upgrade              upgrade db if needed 如果必要,将数据库文件升级到新的格式  
  146.                         (<=1.01.1+升级时所需的)  
  147.   
  148. Replication options:    复制选项  
  149.   --fastsync            indicate that this instance is starting from a dbpath  
  150.                         snapshot of the repl peer 从一个dbpath快照开始同步  
  151.   --autoresync          automatically resync if slave data is stale 自动同步,如果从机的数据不是新的  
  152.                         自动同步  
  153.   --oplogSize arg       size limit (in MB) for op log oplog的大小  
  154.   
  155. Master/slave options:   主/从配置选项  
  156.   --master              master mode 主模式  
  157.   --slave               slave mode  从属模式  
  158.   --source arg          when slave: specify master as <server:port>从属服务器上指定主服务器地址  
  159.   --only arg            when slave: specify a single database to replicate从属服务器上指定要复制的  
  160.                         数据库  
  161.   --slavedelay arg      specify delay (in seconds) to be used when applying  
  162.                         master ops to slave 指定从主服务器上同步数据的时间间隔 单位秒  
  163.   
  164. Replica set options:    副本集选项  
  165.   --replSet arg         arg is <setname>[/<optionalseedhostlist>]  
  166.                         参数:<名称>[<种子主机列表>]  
  167.   
  168. Sharding options:       分片设置选项  
  169.   --configsvr           declare this is a config db of a cluster; default port  
  170.                         27019default dir /data/configdb 声明这是一个集群的配置数据库,  
  171.                         默认的端口是27019 默认的路径是/data/configdb  
  172.   --shardsvr            declare this is a shard db of a cluster; default port  
  173.                         27018 声明这是集群的一个分片数据库,默认端口为27018  
  174.   --noMoveParanoia      turn off paranoid saving of data for moveChunk.  this  
  175.                         is on by default for now, but default will switch  
  176.                         关闭偏着保存大块数据。现在它是默认的,但是会变换  


















0 0
原创粉丝点击