1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| ========== 普通格式 ========== [root@test ~]# vim /usr/local/mongodb/conf/mongod1.conf port=27017 bind_ip = 192.168.251.129 # 这个最好配置成本机的ip地址。否则后面进行副本集初始化的时候可能会失败! dbpath=/usr/local/mongodb/data logpath=/usr/local/mongodb/log/mongo.log pidfilepath=/usr/local/mongodb/mongo.pid fork=true logappend=true shardsvr=true directoryperdb=true # auth=true # keyFile =/usr/local/mongodb/keyfile # replSet =hqmongodb [root@test ~]# mongod -f /usr/local/mongodb/conf/mongod1.conf about to fork child process, waiting until server is ready for connections. forked process: 5201 child process started successfully, parent exiting # 启动 [root@test ~]# mongod -f /usr/local/mongodb/conf/mongod1.conf --shutdown killing process with pid: 5201 # 关闭
========== YAML格式 ========== # 3.X 版本官方推荐使用 [root@test ~]# vim /usr/local/mongodb/conf/mongod.conf systemLog: destination: file path: "/usr/local/mongodb/log/mongod.log" logAppend: true storage: journal: enabled: true dbPath: "/usr/local/mongodb/data" processManagement: fork: true net: port: 27017 # 注意有空格的行,都是四个空格或八个空格,不要使用Tab键,启动时可能会报错:"Error parsing YAML config file: yaml-cpp: error at line 7, column 2: end of map not found" [root@test ~]# mongod -f /usr/local/mongodb/conf/mongod.conf about to fork child process, waiting until server is ready for connections. forked process: 5250 child process started successfully, parent exiting
|