#linux Network optimization 1. File in/etc/sysctl.conf, join
Net.core.somaxconn = 2048
Fs.file-max = 2000000
Fs.nr_open = 2000000
Net.ipv4.ip_local_port_range = 1024 65535
- Hard Nofile 1000000
- Soft Nofile 1000000
2. 文件/etc/security/limits.conf中加入:
- Disable Senux
/etc/selinux/config
Selinux=disabled
- Firewall section, temporarily stop FIREWALLD
Firewall
Systemctl Start Firewalld.service #启动firewall
Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable Firewalld.service #禁止firewall开机启动
- MongoDB Installation
If the decompression is installed, the default is put to/tools
1. Unzip to
/root/tools/mongodb
CD/
Ln-s/root/tools2. Join path
Vim/etc/profile
Export path= $PATH:/tools/mongodb/bin
For RPM packages, run the following command
RPM-IVH *.rpm
- Configure MongoDB
Mkdir/data/mongodb
Cd/data/mongodb
mkdir DB LogCommon configuration file and start
Mongod--config configdb.conf
=====================================
https://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/
- Configuration Instructions
234 on the machine:
Shard0 192.168.1.234:27018
Shard1 192.168.1.234:27019
Configsrv 192.168.1.234:30001
- Configure Configserver
1. Examples of file configurations
Sharding:
Clusterrole:configsvr
Replication
Replsetname:configreplset
Net
Port: <port>
Storage
DBPath: <path>2. Start
Mongod--config configsrv1.conf
Non-file mode
Mongod--configsvr--replset configreplset--port <port>--dbpath <path>
- Initialize Configserver, configure two configure here
1. Enter MONGO Shell
MONGO 192.168.1.234:30001
Rs.initiate ({
_id: "Configreplset",
Configsvr:true,
Members: [{_id:0, Host: ' 192.168.1.55:30001 '}, {_id:1, Host: ' 192.168.1.234:30001 '}
]
} )2. View status
Rs.status ()
- Start MONGOs
MONGOs--configdb configreplset/192.168.1.55:30001,192.168.1.234:30001--port 37017&
MONGOs--configdb configrs/192.168.1.234:30001--port 37017--logappend--logpath/data/mongodb/log/route.log&
- Connect to MONGOs
MONGO--host 192.168.1.234--port 37017
- Add sharding
1. Create an example
mkdir DB2 DB3
Modify the corresponding configuration file
Note: This place needs to set the maximum memory
Ulimit-v 10000000 Modify maximum virtual address space to 10G
--WIREDTIGERCACHESIZEGB 52. Adding shards
Sh.addshard ("rs1/192.168.1.234:27018")//Add a shard for a replica set named Rs1
Sh.addshard ("192.168.1.234:27018")
Sh.addshard ("192.168.1.234:27019")
3. Activating shards
Sh.enablesharding ("<database>")//Db.runcommand ({enablesharding: <database>})
Sh.enablesharding ("MyDB")
4. View status
Sh.status ()
#########################
Pre-insertion Preparation
Sh.enablesharding ("<database>")//Db.runcommand ({enablesharding: <database>})
Sh.enablesharding ("Gwgps")
Db.location.ensureIndex ({"HostID": 1})
Db.location.ensureIndex ({"Postime": 1})
Sh.shardcollection ("Gwgps.location", {"HostID": 1})
MongoDB 3.2 Shard Deployment steps