centos6.5 安装mongodb 服务端解析

你猜 阅读:301 2021-03-31 21:50:56 评论:0

CentOS6.5 安装NoSQL(Mongodb)

第一步:下载Mongodb

第二步:安装Mongodb(安装/usr/local 目录下)

# tar zxvf mongodb-linux-x86_64-2.4.9.tgz 
# mv mongodb-linux-x86_64-2.4.9 mongodb 
# cd mongodb 
# mkdir db 
# mkdir logs 
# cd bin 
# vi mongodb.conf

mongodb.conf 配置文件内容

dbpath=/usr/local/mongodb/db 
logpath=/usr/local/mongodb/logs/mongodb.log 
port=27017 
fork=true 
nohttpinterface=true


为了便于命令启动,需要编辑全局变量PATH

# vim /etc/profile.d/mongo.sh 
export PATH=$PATH:/home/mongodb/bin
source /etc/profile.d/mongo.sh

第三步: 重新绑定mongodb的配置文件地址和访问IP

# mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf 


第四步:启动mongodb 服务

首先查看mongod的帮助信息

 1 [root@test ~]# mongod --help 
  2 Options: 
  3  
  4 General options: 
  5   -h [ --help ]                         show this usage information 
  6   --version                             show version information 
  7   -f [ --config ] arg                   configuration file specifying  
  8                                         additional options 
  9   -v [ --verbose ] [=arg(=v)]           be more verbose (include multiple times 
 10                                         for more verbosity e.g. -vvvvv) 
 11   --quiet                               quieter output 
 12   --port arg                            #指定mongodb服务的端口号,默认为:27017  
 13   --bind_ip arg                         #在多网卡的机器上指定mongodb服务绑定到哪一个ip上  
 15   --ipv6                                enable IPv6 support (disabled by  
 16                                         default) 
 17   --maxConns arg                        #指定最大客户端连接数  
 19   --logpath arg                         #指定日志文件路径,必须是一个文件,而不是目录  
 20   --syslog                              log to system's syslog facility instead 
 23                                         of file or stdout 
 24   --syslogFacility arg                  syslog facility used for mongodb syslog 
 25                                         message 
 26   --logappend                           #以追加的方式打印日志到--logpath参数指定的日志文件中  
 28   --logRotate arg                       set the log rotation behavior  
 29                                         (rename|reopen) 
 30   --timeStampFormat arg                 Desired format for timestamps in log  
 31                                         messages. One of ctime, iso8601-utc or  
 32                                         iso8601-local 
 33   --pidfilepath arg                     full path to pidfile (if not set, no  
 34                                         pidfile is created) 
 35   --keyFile arg                         private key for cluster authentication 
 36   --setParameter arg                    Set a configurable parameter 
 37   --httpinterface                       enable http interface 
 38   --clusterAuthMode arg                 Authentication mode used for cluster  
 39                                         authentication. Alternatives are  
 40                                         (keyFile|sendKeyFile|sendX509|x509) 
 41   --nounixsocket                        disable listening on unix sockets 
 42   --unixSocketPrefix arg                alternative directory for UNIX domain  
 43                                         sockets (defaults to /tmp) 
 44   --filePermissions arg                 permissions to set on UNIX domain  
 45                                         socket file - 0700 by default 
 46   --fork                                #以daemon的形式运行服务进程 
 47   --auth                                run with security 
 48   --noauth                              run without security 
 49   --jsonp                               allow JSONP access via http (has  
 50                                         security implications) 
 51   --rest                                turn on simple rest api 
 52   --slowms arg (=100)                   value of slow for profile and console  
 53                                         log 
 54   --profile arg                         0=off 1=slow, 2=all 
 55   --cpu                                 periodically show cpu and iowait  
 56                                         utilization 
 57   --sysinfo                             print some diagnostic system  
 58                                         information 
 59   --noIndexBuildRetry                   don't retry any index builds that were  
 60                                         interrupted by shutdown 
 61   --noscripting                         disable scripting engine 
 62   --notablescan                         do not allow table scans 
 63   --shutdown                            kill a running server (for init  
 64                                         scripts) 
 65  
 66 Replication options: 
 67   --oplogSize arg                       size to use (in MB) for replication op  
 68                                         log. default is 5% of disk space (i.e.  
 69                                         large is good) 
 70  
 71 Master/slave options (old; use replica sets instead): 
 72   --master                              master mode 
 73   --slave                               slave mode 
 74   --source arg                          when slave: specify master as  
 75                                         <server:port> 
 76   --only arg                            when slave: specify a single database  
 77                                         to replicate 
 78   --slavedelay arg                      specify delay (in seconds) to be used  
 79                                         when applying master ops to slave 
 80   --autoresync                          automatically resync if slave data is  
 81                                         stale 
 82  
 83 Replica set options: 
 84   --replSet arg                         arg is <setname>[/<optionalseedhostlist 
 85                                         >] 
 86   --replIndexPrefetch arg               specify index prefetching behavior (if  
 87                                         secondary) [none|_id_only|all] 
 88   --enableMajorityReadConcern           enables majority readConcern 
 89  
 90 Sharding options: 
 91   --configsvr                           declare this is a config db of a  
 92                                         cluster; default port 27019; default  
 93                                         dir /data/configdb 
 94   --configsvrMode arg                   Controls what config server protocol is 
 95                                         in use. When set to "sccc" keeps server 
 96                                         in legacy SyncClusterConnection mode  
 97                                         even when the service is running as a  
 98                                         replSet 
 99   --shardsvr                            declare this is a shard db of a  
100                                         cluster; default port 27018 
101  
102 Storage options: 
103   --storageEngine arg                   what storage engine to use - defaults  
104                                         to wiredTiger if no data files present 
105   --dbpath arg                          #指定数据目录路径 
107   --directoryperdb                      each database will be stored in a  
108                                         separate directory 
109   --noprealloc                          disable data file preallocation - will  
110                                         often hurt performance 
111   --nssize arg (=16)                    .ns file size (in MB) for new databases 
112   --quota                               limits each database to a certain  
113                                         number of files (8 default) 
114   --quotaFiles arg                      number of files allowed per db, implies 
115                                         --quota 
116   --smallfiles                          use a smaller default file size 
117   --syncdelay arg (=60)                 seconds between disk syncs (0=never,  
118                                         but not recommended) 
119   --upgrade                             upgrade db if needed 
120   --repair                              run repair on all dbs 
121   --repairpath arg                      root directory for repair files -  
122                                         defaults to dbpath 
123   --journal                             enable journaling 
124   --nojournal                           disable journaling (journaling is on by 
125                                         default for 64 bit) 
126   --journalOptions arg                  journal diagnostic options 
127   --journalCommitInterval arg           how often to group/batch commit (ms) 
128  
129 WiredTiger options: 
130   --wiredTigerCacheSizeGB arg           maximum amount of memory to allocate  
131                                         for cache; defaults to 1/2 of physical  
132                                         RAM 
133   --wiredTigerStatisticsLogDelaySecs arg (=0) 
134                                         seconds to wait between each write to a 
135                                         statistics file in the dbpath; 0 means  
136                                         do not log statistics 
137   --wiredTigerJournalCompressor arg (=snappy) 
138                                         use a compressor for log records  
139                                         [none|snappy|zlib] 
140   --wiredTigerDirectoryForIndexes       Put indexes and data in different  
141                                         directories 
142   --wiredTigerCollectionBlockCompressor arg (=snappy) 
143                                         block compression algorithm for  
144                                         collection data [none|snappy|zlib] 
145   --wiredTigerIndexPrefixCompression arg (=1) 
146                                         use prefix compression on row-store  
147                                         leaf pages
第五步:查看mongodb是否启动

# netstat -tnlp | grep mongod 


至此,MongoDB安装完毕。

声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
排行榜
KIKK导航

KIKK导航

关注我们