2017-08-16T18:33:42.985+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2017-08-16T18:33:42.985+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2017-08-16T18:33:43.024+0800 I CONTROL [initandlisten] 2017-08-16T18:33:43.024+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2017-08-16T18:33:43.024+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2017-08-16T18:33:43.024+0800 I CONTROL [initandlisten] 2017-08-16T18:33:43.025+0800 I CONTROL [initandlisten] 2017-08-16T18:33:43.025+0800 I CONTROL [initandlisten] ** WARNING: You are running on a NUMA machine. 2017-08-16T18:33:43.025+0800 I CONTROL [initandlisten] ** We suggest launching mongod like this to avoid performance problems: 2017-08-16T18:33:43.025+0800 I CONTROL [initandlisten] ** numactl --interleave=all mongod [other options] 2017-08-16T18:33:43.026+0800 I CONTROL [initandlisten] 2017-08-16T18:33:43.026+0800 I CONTROL [initandlisten] ** WARNING: /proc/sys/vm/zone_reclaim_mode is 1 2017-08-16T18:33:43.026+0800 I CONTROL [initandlisten] ** We suggest setting it to 0 2017-08-16T18:33:43.026+0800 I CONTROL [initandlisten] ** http://www.kernel.org/doc/Documentation/sysctl/vm.txt 2017-08-16T18:33:43.026+0800 I CONTROL [initandlisten] 2017-08-16T18:33:43.027+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2017-08-16T18:33:43.027+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-08-16T18:33:43.027+0800 I CONTROL [initandlisten] 2017-08-16T18:33:43.027+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2017-08-16T18:33:43.027+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2017-08-16T18:33:43.027+0800 I CONTROL [initandlisten]
这其实是六条建议,下来我们分别来进行解读;
第一条,“Using the XFS filesystem is strongly recommended with the WiredTiger storage engine” ,意思就是强烈建议启用XFS文件系统,启用XFS文件系统会对性能有比较好的提升,我们使用的系统是centos6.9,重新格式化磁盘就可以。
第二条,“Access control is not enabled for the database. Read and write access to data and configuration is unrestricted.”,就是说数据安全很重要,该配置管理员账户、密码、权限的就赶紧配上。
第三条,“ You are running on a NUMA machine.We suggest launching mongod like this to avoid,numactl –interleave=all mongod [other options]”,我们运行的服务器CPU架构是MUMA,因此建议启动的时候加一些参数,可以提高性能,怎么加呢,看下面的命令,想多了解一些可以参考这篇文章:Mongodb NUMA 导致的性能问题
1
numactl --interleave=all mongod [other options]
第四条,“/proc/sys/vm/zone_reclaim_mode is 1,We suggest setting it to 0”,就是系统的这个值现在是1,请修改为0
1
echo 0 > /proc/sys/vm/zone_reclaim_mode
第五条,”sys/kernel/mm/transparent_hugepage/enabled is,We suggest setting it to ‘never’”,建议修改将配置I为”never“
1
echo never > /sys/kernel/mm/transparent_hugepage/enabled
第六条,”/sys/kernel/mm/transparent_hugepage/defrag is,We suggest setting it to ‘never’“,和上面基本相似。
1
echo never > /sys/kernel/mm/transparent_hugepage/defrag
Caused by: com.mongodb.WriteConcernException: Write failed with error code 83 and error message 'write results unavailable from 192.168.0.35:27005 :: caused by :: Location11002: socket exception [CONNECT_ERROR] for 192.168.0.35:27005'
mongos错误信息:
1 2 3
Failed to connect to 192.168.0.35:27005, in(checking socket for error after poll), reason: Connection refused
No primary detected forset shard5
congfig 报错:
1 2 3 4 5 6
No primary detected forset shard5 2017-08-21T11:08:22.709+0800 W NETWORK [Balancer] Failed to connect to 192.168.0.31:27005, in(checking socket for error after poll), reason: Connection refused 2017-08-21T11:08:22.710+0800 W NETWORK [Balancer] Failed to connect to 192.168.0.35:27005, in(checking socket for error after poll), reason: Connection refused 2017-08-21T11:08:22.710+0800 W NETWORK [Balancer] No primary detected forset shard5 2017-08-21T11:08:22.710+0800 I SHARDING [Balancer] caught exception while doing balance: could not find host matching read preference { mode: "primary" } forset shard5 2017-08-21T11:08:22.710+0800 I SHARDING [Balancer] about to log metadata event into actionlog: { _id: "mongodb34.hkrt.cn-2017-08-21T11:08:22.710+0800-599a4ea698ec442a0836e2d5", server: "mongodb34.hkrt.cn", clientAddr: "", time: new Date(1503284902710), what: "balancer.round", ns: "", details: { executionTimeMillis: 20051, errorOccured: true, errmsg: "could not find host matching read preference { mode: "primary" } for set shard5" } }
剩余分片(192.168.0.32)报错:
1 2
not master and slaveOk=false could not find host matching read preference { mode: "primary" } forset shard5
The maximum size of the internal cache that WiredTiger will use for all data.
Changed in version 3.4: Values can range from 256MB to 10TB and can be a float. In addition, the default value has also changed.
Starting in 3.4, the WiredTiger internal cache, by default, will use the larger of either:
50% of RAM minus 1 GB, or 256 MB. Avoid increasing the WiredTiger internal cache size above its default value.
With WiredTiger, MongoDB utilizes both the WiredTiger internal cache and the filesystem cache.
Via the filesystem cache, MongoDB automatically uses all free memory that is not used by the WiredTiger cache or by other processes. Data in the filesystem cache is compressed.
*NOTE* *The storage.wiredTiger.engineConfig.cacheSizeGB limits the size of the WiredTiger internal cache. The operating system will use the available free memory for filesystem cache, which allows the compressed MongoDB data files to stay in memory. In addition, the operating system will use any free RAM to buffer file system blocks and file system cache.*
*To accommodate the additional consumers of RAM, you may have to decrease WiredTiger internal cache size.*
The default WiredTiger internal cache size value assumes that there is a single mongod instance per machine. If a single machine contains multiple MongoDB instances, then you should decrease the setting to accommodate the other mongod instances.
If you run mongod in a container (e.g. lxc, cgroups, Docker, etc.) that does not have access to all of the RAM available in a system, you must set storage.wiredTiger.engineConfig.cacheSizeGB to a value less than the amount of RAM available in the container. The exact amount depends on the other processes running in the container.