MongoDB警告信息: 1. WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine? 2. WARNING: Access control is not enabled for the database.? 3. WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.? 4. WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
1.WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine(強烈建議使用帶WiredTiger存儲引擎的XFS文件系統)
root@localhost ~]# mongod --dbpath /var/lib/mongo
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] MongoDB starting : pid=2421 port=27017 dbpath=/var/lib/mongo 64-bit host=localhost.localdomain
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] db version v3.4.92017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 20132017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] allocator: tcmalloc
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] modules: none
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] build environment:
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] distmod: rhel70
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] distarch: x86_64
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-09-27T03:06:14.853+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "/var/lib/mongo" } }
2017-09-27T03:06:14.971+0800 I - [initandlisten] Detected data files in /var/lib/mongo created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-09-27T03:06:14.971+0800 I STORAGE [initandlisten]
2017-09-27T03:06:14.971+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-09-27T03:06:14.971+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem2017-09-27T03:06:14.971+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1455M,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is'always'.
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is'always'.
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.634+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data'2017-09-27T03:06:16.635+0800 I NETWORK [thread1] waiting for connections on port 270172017-09-27T03:06:33.704+0800 I NETWORK [thread1] connection accepted from127.0.0.1:34808 #1 (1 connection now open)
2017-09-27T03:06:33.705+0800 I NETWORK [conn1] received client metadata from127.0.0.1:34808 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.9" }, os: { type: "Linux", name: "CentOS Linux release 7.3.1611 (Core) ", architecture: "x86_64", version: "Kernel 3.10.0-514.26.2.el7.x86_64" } }
2017-09-27T03:07:15.311+0800 I COMMAND [conn1] command admin.system.users appName: "MongoDB Shell" command: insert { insert: "system.users", documents: [ { _id: "admin.myUserAdmin", user: "myUserAdmin", db: "admin", credentials: { SCRAM-SHA-1: { iterationCount: 10000, salt: "pUdmLObMsG3wKU7MZDFU1g==", storedKey: "wlCaAzPOS+u7CUqzMKxeZB+DFkE=", serverKey: "KwP12FF1ASziFPVstN8mLrPLg+A=" } }, roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ] } ninserted:1 keysInserted:1 numYields:0 reslen:44 locks:{ Global: { acquireCount: { r: 4, w: 4 } }, Database: { acquireCount: { W: 4 } }, Collection: { acquireCount: { w: 3 } } } protocol:op_query 145ms
2017-09-27T03:07:15.311+0800 I COMMAND [conn1] command admin.$cmd appName: "MongoDB Shell" command: createUser { createUser: "myUserAdmin", pwd: "xxx", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 600000.0 } } numYields:0 reslen:22 locks:{ Global: { acquireCount: { r: 4, w: 4 } }, Database: { acquireCount: { W: 4 } }, Collection: { acquireCount: { w: 3 } } } protocol:op_command 202ms
?
連接到instance
[root@localhost ~]# mongo
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.9
Server has startup warnings:
2017-09-27T03:06:14.971+0800 I STORAGE [initandlisten]
2017-09-27T03:06:14.971+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-09-27T03:06:14.971+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-09-27T03:06:16.364+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is'always'.
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten]
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is'always'.
2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'2017-09-27T03:06:16.365+0800 I CONTROL [initandlisten]
>
使用Ctrl+c退出原mongodq^H
^C2017-09-27T03:07:25.685+0800 I CONTROL [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends
2017-09-27T03:07:25.685+0800 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2017-09-27T03:07:25.685+0800 I NETWORK [signalProcessingThread] closing listening socket: 62017-09-27T03:07:25.685+0800 I NETWORK [signalProcessingThread] closing listening socket: 72017-09-27T03:07:25.685+0800 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2017-09-27T03:07:25.685+0800 I NETWORK [signalProcessingThread] shutdown: going to flush diaglog...
2017-09-27T03:07:25.685+0800 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2017-09-27T03:07:25.687+0800 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2017-09-27T03:07:25.770+0800 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2017-09-27T03:07:25.770+0800 I CONTROL [signalProcessingThread] now exiting
2017-09-27T03:07:25.770+0800 I CONTROL [signalProcessingThread] shutting down with code:0
?
開啟訪問控制啟動Mongod
[root@localhost ~]# mongod --auth --dbpath /var/lib/mongo
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] MongoDB starting : pid=2508 port=27017 dbpath=/var/lib/mongo 64-bit host=localhost.localdomain
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] db version v3.4.92017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 20132017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] allocator: tcmalloc
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] modules: none
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] build environment:
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] distmod: rhel70
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] distarch: x86_64
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-09-27T03:07:40.034+0800 I CONTROL [initandlisten] options: { security: { authorization: "enabled" }, storage: { dbPath: "/var/lib/mongo" } }
2017-09-27T03:07:40.054+0800 I - [initandlisten] Detected data files in /var/lib/mongo created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-09-27T03:07:40.054+0800 I STORAGE [initandlisten]
2017-09-27T03:07:40.054+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-09-27T03:07:40.054+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem2017-09-27T03:07:40.054+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1455M,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten]
2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten]
2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is'always'.
2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten]
2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is'always'.
2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'2017-09-27T03:07:40.420+0800 I CONTROL [initandlisten]
2017-09-27T03:07:40.422+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data'2017-09-27T03:07:40.422+0800 I NETWORK [thread1] waiting for connections on port 270172017-09-27T03:08:07.458+0800 I NETWORK [thread1] connection accepted from127.0.0.1:34810 #1 (1 connection now open)
2017-09-27T03:08:07.458+0800 I NETWORK [conn1] received client metadata from127.0.0.1:34810 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.9" }, os: { type: "Linux", name: "CentOS Linux release 7.3.1611 (Core) ", architecture: "x86_64", version: "Kernel 3.10.0-514.26.2.el7.x86_64" } }
2017-09-27T03:08:07.477+0800 I ACCESS [conn1] Successfully authenticated as principal myUserAdmin on admin
2017-09-27T03:08:07.478+0800 I ACCESS [conn1] Unauthorized: not authorized on admin to execute command { getLog: "startupWarnings" }
2017-09-27T03:08:07.665+0800 I ACCESS [conn1] Unauthorized: not authorized on admin to execute command { replSetGetStatus: 1.0, forShell: 1.0 }
2017-09-27T03:08:26.104+0800 I - [conn1] end connection 127.0.0.1:34810 (1 connection now open)
2017-09-27T03:08:29.697+0800 I NETWORK [thread1] connection accepted from127.0.0.1:34812 #2 (1 connection now open)
2017-09-27T03:08:29.697+0800 I NETWORK [conn2] received client metadata from127.0.0.1:34812 conn2: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.9" }, os: { type: "Linux", name: "CentOS Linux release 7.3.1611 (Core) ", architecture: "x86_64", version: "Kernel 3.10.0-514.26.2.el7.x86_64" } }
2017-09-27T03:08:29.713+0800 I ACCESS [conn2] Successfully authenticated as principal myTester on test
2017-09-27T03:08:29.714+0800 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { getLog: "startupWarnings" }
2017-09-27T03:08:29.715+0800 I ACCESS [conn2] Unauthorized: not authorized on admin to execute command { replSetGetStatus: 1.0, forShell: 1.0 }
[root@localhost ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
[root@localhost ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
修改系統配置
[root@localhost ~]# vim /etc/rc.d/rc.local#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of usingthis file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.touch /var/lock/subsys/localif test -f /sys/kernel/mm/transparent_hugepage/enabled; thenecho never > /sys/kernel/mm/transparent_hugepage/enabledfiif test -f /sys/kernel/mm/transparent_hugepage/defrag; thenecho never > /sys/kernel/mm/transparent_hugepage/defragfi[root@localhost ~]# chmod +x /etc/rc.d/rc.local
[root@localhost ~]# mongod --auth --dbpath /var/lib/mongo
2017-09-27T03:40:50.174+0800 I CONTROL [initandlisten] MongoDB starting : pid=2381 port=27017 dbpath=/var/lib/mongo 64-bit host=localhost.localdomain
2017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] db version v3.4.92017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
2017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 20132017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] allocator: tcmalloc
2017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] modules: none
2017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] build environment:
2017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] distmod: rhel70
2017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] distarch: x86_64
2017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-09-27T03:40:50.175+0800 I CONTROL [initandlisten] options: { security: { authorization: "enabled" }, storage: { dbPath: "/var/lib/mongo" } }
2017-09-27T03:40:50.195+0800 I - [initandlisten] Detected data files in /var/lib/mongo created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-09-27T03:40:50.195+0800 I STORAGE [initandlisten]
2017-09-27T03:40:50.195+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-09-27T03:40:50.195+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem2017-09-27T03:40:50.195+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1455M,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-09-27T03:40:50.689+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-09-27T03:40:50.689+0800 I CONTROL [initandlisten]
2017-09-27T03:40:50.692+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data'2017-09-27T03:40:50.693+0800 I NETWORK [thread1] waiting for connections on port 27017
進入數據庫
[root@localhost ~]# mongo
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.9
>