Installation of MongoDB under Mac
I haven't posted a blog for a long time ~ one today ~ less nonsense ~ GoOn.
Introduction and installation of HomeBrew
Introduction: it is a software package management tool on mac to facilitate installation and uninstallation.
Installation: open the terminal and enter the following command, during which you will enter one enter + two boot passwords.
Ruby-e "$(curl-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Two: MongoDB installation
1: open the terminal and enter the following instructions
Brew update
2: continue to enter the following instructions, during which the progress bar will appear about twice (forget the screenshot)
Brew install mongodb
3: enter instructions to start Mongodb
Mongod
The error appears as follows: there is no / data/db directory.
2016-08-02T18:19:16.825+0800 I CONTROL [initandlisten] MongoDB starting: pid=37113 port=27017 dbpath=/data/db 64-bit host=C02Q6N1GFVH5-3.local
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] db version v3.2.8
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] allocator: system
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] modules: none
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] build environment:
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] distarch: x86
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] target_arch: x86
2016-08-02T18:19:16.826+0800 I CONTROL [initandlisten] options: {}
2016-08-02T18:19:16.828+0800 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory / data/db not found., terminating
2016-08-02T18:19:16.828+0800 I CONTROL [initandlisten] dbexit: rc: 100
4: continue to enter instructions and create / data/db to solve the above problems. During this period, there will be a boot password.
Sudo mkdir-p / data/db
5: try starting Mongodb again
Mongod
There is an error as follows: it means that there is no permission.
2016-08-02T19:15:14.592+0800 I CONTROL [initandlisten] MongoDB starting: pid=38311 port=27017 dbpath=/data/db 64-bit host=C02Q6N1GFVH5-3.local
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] db version v3.2.8
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] allocator: system
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] modules: none
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] build environment:
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] distarch: x86
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] target_arch: x86
2016-08-02T19:15:14.593+0800 I CONTROL [initandlisten] options: {}
2016-08-02T19:15:14.595+0800 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: / data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2016-08-02T19:15:14.595+0800 I CONTROL [initandlisten] dbexit: rc: 100
6: execute the following instructions, solve the above problems, and give authority (hehe, there is no response after execution)
Sudo chown-R user name / data/db
7: try starting Mongodb again
Mongod
Waitting 27017 . It worked!
2016-08-02T19:16:06.621+0800 I CONTROL [initandlisten] MongoDB starting: pid=38338 port=27017 dbpath=/data/db 64-bit host=C02Q6N1GFVH5-3.local
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] db version v3.2.8
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] allocator: system
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] modules: none
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] build environment:
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] distarch: x86
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] target_arch: x86
2016-08-02T19:16:06.622+0800 I CONTROL [initandlisten] options: {}
2016-08-02T19:16:06.622+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=4G,session_max=20000,eviction= (threads_max=4), config_base=false,statistics= (fast), log= (enabled=true,archive=true,path=journal,compressor=snappy), file_manager= (close_idle_time=100000), checkpoint= (wait=60,log_size=2GB), statistics_log= (wait=0)
2016-08-02T19:16:07.239+0800 I CONTROL [initandlisten]
2016-08-02T19:16:07.239+0800 I CONTROL [initandlisten] * * WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2016-08-02T19:16:07.239+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory'/ data/db/diagnostic.data'
2016-08-02T19:16:07.239+0800 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-08-02T19:16:07.390+0800 I NETWORK [initandlisten] waiting for connections on port 27017
8: open a browser at this time and enter the following address:
Http://127.0.0.1:27017/
The page shown below also indicates a successful startup.
It looks like you are trying to access MongoDB over HTTP on the native driver port.
Oh, my God, that's all.