1. 获取mongodb-3.4.6
[thomaschen@localhost Downloads]$ curl -o mongodb-linux-x86_64-3.4.6.tgz https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.6.tgz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 82.7M 0 591k 0 0 33043 0 0:43:45 0:00:18 0:43:27 24721
2. 解压压缩包至安装目录(/usr/local/mongodb)
[thomaschen@localhost Downloads]$ su [root@localhost Downloads]# tar zxvf mongodb-linux-x86_64-3.4.6.tgz -C /usr/local [root@localhost Downloads]# cd /usr/local [root@localhost local]# mv mongodb-linux-x86_64-3.4.6 mongodb
3. 建立log目录和data目录
[root@localhost local]# cd mongodb [root@localhost mongodb]# mkdir data/log && mkdir data/db
4. 在/usr/local/mongodb/bin下建立文件mongodb.conf,内容如下:
systemLog: destination: file path: "/usr/local/mongodb/data/log/mongodb.log" logAppend: true storage: journal: enabled: true dbPath: "/usr/local/mongodb/data/db" directoryPerDB: false engine: wiredTiger wiredTiger: engineConfig: cacheSizeGB: 4 directoryForIndexes: false journalCompressor: zlib collectionConfig: blockCompressor: zlib indexConfig: prefixCompression: true net: port: 27017 processManagement: fork: true security: authorization: disabled
5.. 启动mongodb服务器
[root@localhost mongodb]# bin/mongod -f /usr/local/mongodb/bin/mongodb.conf
6. 检查mongodb启动端口27017
[root@localhost mongodb]# lsof -i :27017 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mongod 5636 root 7u IPv4 42745 0t0 TCP *:27017 (LISTEN)
7. 检查http服务端口28017(在mongodb的27017中的第一个7加上1,即28018即HTTP服务端口)
http://192.168.179.131:28017
8. 启动mongodb的客户端
[root@localhost mongodb]# bin/mongo MongoDB shell version v3.4.6 connecting to: mongodb://127.0.0.1:27017 MongoDB server version: 3.4.6 Server has startup warnings: 2017-07-12T06:35:41.076-0700 I STORAGE [initandlisten] 2017-07-12T06:35:41.076-0700 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2017-07-12T06:35:41.076-0700 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2017-07-12T06:35:41.176-0700 I CONTROL [initandlisten] 2017-07-12T06:35:41.176-0700 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2017-07-12T06:35:41.176-0700 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2017-07-12T06:35:41.176-0700 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2017-07-12T06:35:41.176-0700 I CONTROL [initandlisten] 2017-07-12T06:35:41.177-0700 I CONTROL [initandlisten] 2017-07-12T06:35:41.177-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2017-07-12T06:35:41.177-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-07-12T06:35:41.177-0700 I CONTROL [initandlisten] 2017-07-12T06:35:41.177-0700 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2017-07-12T06:35:41.177-0700 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-07-12T06:35:41.177-0700 I CONTROL [initandlisten] >