The tap command allows Homebrew to tap into another repository of formulae. Once you’ve done this you’ve expanded your options of installable software.
$ brew tap mongodb/brew
之后,运行如下命令安装 MongoDB:
$ brew install mongodb-community@4.2
启动
使用 brew 命令运行 MongoDB:
$ brew services start mongodb-community@4.2
建立连接
启动成功后,使用如下命令与 MongoDB 建立连接:
$ mongo
运行命令后发现连接失败,错误如下:
MongoDB shell version v4.2.2 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb 2020-01-31T19:24:23.752+0800 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused : connect@src/mongo/shell/mongo.js:341:17 @(connect):2:6 2020-01-31T19:24:23.768+0800 F - [main] exception: connect failed 2020-01-31T19:24:23.768+0800 E - [main] exiting with code 1
$ cat /usr/local/var/log/mongodb/mongo.log 2020-01-31T20:20:11.840+0800 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] MongoDB starting : pid=44665 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=Jalan-JiangdeMacBook-Pro.local 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] db version v4.2.2 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] allocator: system 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] modules: none 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] build environment: 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] distarch: x86_64 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] target_arch: x86_64 2020-01-31T20:20:11.875+0800 I CONTROL [initandlisten] options: { config: "/usr/local/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/usr/local/var/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/usr/local/var/log/mongodb/mongo.log" } } 2020-01-31T20:20:11.876+0800 I STORAGE [initandlisten] 2020-01-31T20:20:11.877+0800 I STORAGE [initandlisten] ** WARNING: Support for MMAPV1 storage engine has been deprecated and will be 2020-01-31T20:20:11.877+0800 I STORAGE [initandlisten] ** removed in version 4.2. Please plan to migrate to the wiredTiger 2020-01-31T20:20:11.877+0800 I STORAGE [initandlisten] ** storage engine. 2020-01-31T20:20:11.877+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/deprecated-mmapv1 2020-01-31T20:20:11.877+0800 I STORAGE [initandlisten] 2020-01-31T20:20:11.877+0800 I STORAGE [initandlisten] Detected data files in /usr/local/var/mongodb created by the 'mmapv1' storage engine, so setting the active storage engine to 'mmapv1'. 2020-01-31T20:20:11.878+0800 I STORAGE [initandlisten] exception in initAndListen: Location18656: Cannot start server with an unknown storage engine: mmapv1, terminating 2020-01-31T20:20:11.878+0800 I NETWORK [initandlisten] shutdown: going to close listening sockets... 2020-01-31T20:20:11.878+0800 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock 2020-01-31T20:20:11.878+0800 I - [initandlisten] Stopping further Flow Control ticket acquisitions. 2020-01-31T20:20:11.879+0800 I CONTROL [initandlisten] now exiting 2020-01-31T20:20:11.879+0800 I CONTROL [initandlisten] shutting down with code:100
列出关键信息:WARNING: Support for MMAPV1 storage engine has been deprecated and will be removed in version 4.2. Please plan to migrate to the wiredTiger