MongoDB server selection and basic optimization reference

Source: Internet
Author: User
Tags mongodb server

I haven't posted any articles for a long time!

Hard Disk Selection

1. Try to select a SAS disk if possible on the hard disk. If there is no bad money, you can choose SSD, funsion-io, and so on. You can also consider SATA Disks Based on the selected application environment.

2. For RAID, you can select RAID 10 and RAID 5. We recommend that you use RAID 10, which is fast and secure. If RAID 5 is used, it is suitable for reading more businesses. However, we recommend that you use RAID10 in exchange for time. RAID5's performance degrades rapidly when a disk encounters a problem!

3. Select a large brand of RAID card as much as possible to reduce various RAID card faults. In addition, the RAID cache should be relatively large!

Memory Selection

Now the memory is the price of cabbage, and now it is generally used in laptops 16 GB No company will be entangled in memory. Theoretically, the larger the memory size of any server, the better, especially the database server, at least 16 GB Above.

CPU Selection

The 64-bit CPU should be used. In addition, the cache should be large and the CPU should be multi-core and multi-thread. However, some databases do not have strict requirements on multi-core CPU, such as: MongoDB, mongoDB has high memory requirements! MySQL's InnoDB engine has a high CPU utilization rate. Try to use a powerful CPU!

System Selection

1. The system must be a 64-bit system, either linux or unix. linux has many options, and CentOS Ubuntu kernel is commonly used. Unix can choose the open-source FreeBSD system.

2. kernel selection. We recommend more than 2.6 of the kernel, which is not too high.

3. file System Selection: EXT3/EXT4/XFS, EXT4 and XFS are more suitable for databases. In fact, XFS is more suitable for MySQL database file systems, you can increase the performance by 1.5 times based on EXT3.

Other aspects:

The Network Adapter should be at least M, and M is better. bonding can be used if there are no M.

In short, we recommend that you select a server that is not applicable to different applications, especially data.


The following describes how to select the MongoDB server hardware:

1. Related hardware level

2. The network is at least M Nic, and it is better to have M!

2. Large memory can be set based on the index size. In principle, the larger the memory, the better .)

2. Dual-core high-speed CPU, mongodb instances do not need to be multi-core, because mongodb does not support CPU multi-core, but as a mongos Routing Server, it consumes a lot of CPU resources!

2. Mongodb instances have independent Mount disks for mongodb to store data to isolate io operations.

2. You can use RAID 10 or RAID 5 to save disks.  

2. System Level

2. The 64-bit system supports more memory and enables greater data storage.

2. Number of times the file system is prohibited from reading updates (modifying the/etc/fstab file)

Mount-o remount, noatime/data

2. If the stored data contains large files, we recommend that you use a file system such as ext4/xfs.

Here we can consider separating the data directory from the log file and the related middleware directory (if any) to isolate IO

2. Ulimit settings

Set the maximum open file descriptor

Cat/etc/security/limits. conf

Soft nofile 102400

Hard nofile 102400

Increase the number of threads in the system process) --> max user processes
The difference between centos 5 and centos 6 is as long as it is in/etc/security/limits. conf sets the root soft nofile 102400 and root hard nofile102400, and the result of the corresponding uilmit-u is 102400. Pay attention to the difference here!

Therefore, cetos 6 must also be set as follows: sed-I's/1024. */102400/'/etc/security/limits. d/90-nproc.conf

2. TCP connection Memory Optimization

Cat/etc/sysctl. conf

Net. ipv4.tcp _ syncookies = 1

Net. ipv4.tcp _ tw_reuse = 1

Net. ipv4.tcp _ tw_recycle = 1

Net. ipv4.tcp _ timestsmps = 0

Net. ipv4.tcp _ synack_retries = 2

Net. ipv4.tcp _ syn_retries = 2

Net. ipv4.tcp _ wmem = 8192 436600 873200

Net. ipv4.tcp _ rmem = 32768 436600 873200

Net. ipv4.tcp _ mem = 94500000 91500000 92700000

Net. ipv4.tcp _ max_orphans = 3276800

Net. ipv4.tcp _ fin_timeout = 30

Effective directly

/Sbin/sysctl-p

You can add startup parameters when starting a multi-core server:

Numactl -- interleave = all

Start an instance: umactl -- interleave = all/opt/mongodb/bin/mongod-shardsvr-replSet shard1-port 27021-dbpath/data0/mongodb/db/shard13-oplogSize 1000-logpath/data1/mongodb /logs/shard13.log-logappend -- maxConns 10000 -- quiet-fork -- directoryperdb

The last note is that MongoDB is recommended to use a stable version of 2.2.0, which is more comprehensive! Another point is that the Linux kernel has a certain impact on MongoDB!

 

This article is not a standard and may not be suitable for every reader. You can refer to it based on your actual situation!

 

 

This article is from the "->" blog, please be sure to keep this source http://opsmysql.blog.51cto.com/2238445/1083431

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.