下载安装完成后启动服务:
suchaowangdeMacBook-Pro:~ suchaowang$mongod
报错:
2019-03-07T17:19:28.347+0800 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] MongoDB starting : pid=96403 port=27017 dbpath=/data/db 64-bit host=suchaowangdeMacBook-Pro.local
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] db version v4.0.6
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] git version: caa42a1f75a56c7643d0b68d3880444375ec42e3
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] allocator: system
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] modules: none
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] build environment:
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] distarch: x86_64
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] target_arch: x86_64
2019-03-07T17:19:28.397+0800 I CONTROL [initandlisten] options: {}
2019-03-07T17:19:28.400+0800 I STORAGE [initandlisten] exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db, terminating
2019-03-07T17:19:28.400+0800 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-03-07T17:19:28.400+0800 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-03-07T17:19:28.401+0800 I CONTROL [initandlisten] now exiting
2019-03-07T17:19:28.401+0800 I CONTROL [initandlisten] shutting down with code:100
文件夹权限问题,设置文件夹权限
suchaowangdeMacBook-Pro:~ suchaowang$ sudo chmod 777 /data/db
Password:
设置完成,再次启动
suchaowangdeMacBook-Pro:~ suchaowang$ mongod
2019-03-07T17:27:14.495+0800 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] MongoDB starting : pid=96438 port=27017 dbpath=/data/db 64-bit host=suchaowangdeMacBook-Pro.local
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] db version v4.0.6
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] git version: caa42a1f75a56c7643d0b68d3880444375ec42e3
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] allocator: system
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] modules: none
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] build environment:
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] distarch: x86_64
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] target_arch: x86_64
2019-03-07T17:27:14.656+0800 I CONTROL [initandlisten] options: {}
2019-03-07T17:27:14.661+0800 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2019-03-07T17:27:14.662+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2019-03-07T17:27:15.535+0800 I STORAGE [initandlisten] WiredTiger message [1551950835:535087][96438:0x10e3935c0], txn-recover: Main recovery loop: starting at 1/22400 to 2/256
2019-03-07T17:27:15.663+0800 I STORAGE [initandlisten] WiredTiger message [1551950835:663679][96438:0x10e3935c0], txn-recover: Recovering log 1 through 2
2019-03-07T17:27:15.774+0800 I STORAGE [initandlisten] WiredTiger message [1551950835:774174][96438:0x10e3935c0], txn-recover: Recovering log 2 through 2
2019-03-07T17:27:15.843+0800 I STORAGE [initandlisten] WiredTiger message [1551950835:843378][96438:0x10e3935c0], txn-recover: Set global recovery timestamp: 0
2019-03-07T17:27:15.910+0800 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten]
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten]
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten]
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten]
2019-03-07T17:27:15.923+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2019-03-07T17:27:16.017+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2019-03-07T17:27:16.021+0800 I NETWORK [initandlisten] waiting for connections on port 27017
启动成功,打开地址:http://localhost:27017/