当前位置:网站首页>Deployment and operation of mongodb partitioned cluster
Deployment and operation of mongodb partitioned cluster
2022-06-26 16:53:00 【JayDen2001】
preparation : Three servers are used for partition cluster planning , Fill in the relevant information in the table below , Test whether the communication is interconnected , If there is no interworking , Configure communication interworking . see Linux Firewall status , Check if it is closed , If not closed , Turn off the firewall . see Linux in SELinux Whether it is invalid , If not , Then it is modified as invalid .
virtual machine name | Host name | IP Address | Shard1 | Shard2 | Shard3 | mongos | Config Server |
Hadoop01 | Hadoop01 | 192.168.121.134 | 27018 The main node | 27020 Arbitration node | 27019 Secondary node | 27021 | 27022 The main node |
Hadoop02 | Hadoop02 | 192.168.121.135 | 27019 Secondary node | 27018 The main node | 27020 Arbitration node | 27021 | 27022 Secondary node |
Hadoop03 | Hadoop03 | 192.168.121.136 | 27020 Arbitration node | 27019 Secondary node | 27018 The main node | 27022 Secondary node |
1、 Create related folders and files , install mongodb. Create related folders and files on the first server , install mongodb, And distribute the relevant directories to the other two , Make the directory and installation of the three servers the same .(20 branch )
# Create a folder to use later
[[email protected]~]#touch/opt/servers/mongodb_demo/shardcluster/configServer/logs/config_server.log
[[email protected] ~]# touch /opt/servers/mongodb_demo/shardcluster/shard/logs/shard1.log
[[email protected] ~]# touch /opt/servers/mongodb_demo/shardcluster/shard/logs/shard2.log
[[email protected] ~]# touch /opt/servers/mongodb_demo/shardcluster/shard/logs/shard3.log
[[email protected] ~]# touch /opt/servers/mongodb_demo/shardcluster/mongos/logs/mongos.log
[[email protected] ~]# tar -zxvf /opt/software/mongodb-linux-x86_64-rhel62-3.6.23.tgz -C /opt/servers/mongodb_demo/shardcluster/
# Copy the folder to the other two virtual machines
scp -r /opt/servers/mongodb_demo/shardcluster/ [email protected]:/opt/servers/mongodb_demo/
scp -r /opt/servers/mongodb_demo/shardcluster/ [email protected]:/opt/servers/mongodb_demo/



2、 Deploy configuration server .(20 branch )



3、 Deploy the shard server .(20 branch )



Configure the partitioned master node 、 Secondary node 、 Arbitration node
./mongo --host hadoop01 --port 27018
rs.initiate()
rs.add("hadoop02:27019")
rs.addArb("hadoop03:27020")
rs.status()

./mongo --host hadoop02 --port 27018
rs.initiate()
rs.add("hadoop03:27019")
rs.addArb("hadoop01:27020")
rs.status()

./mongo --host hadoop03 --port 27018
rs.initiate()
rs.add("hadoop01:27019")
rs.addArb("hadoop03:27020")
rs.status()

4、 Deploy routing server .(20 branch )
./mongos -f /opt/servers/mongodb_demo/shardcluster/mongos/configFile/mongodb_mongos.conf


5、 Start the fragmentation function , On the server nosql01 In the login mongos Of MongoDB client , Switch to database gateway, Add... To a sharded cluster 3 A shard .(20 branch )
./mongo --host hadoop01 --port 27021
use gateway
sh.addShard("shard1/hadoop01:27018,hadoop02:27019,hadoop03:27020")
sh.addShard("shard2/hadoop01:27020,hadoop02:27018,hadoop03:27019")
sh.addShard("shard3/hadoop01:27019,hadoop02:27020,hadoop03:27018")

MongoDB Shard operation
- Sign in 01 The server MongoDB client
./mongo --host hadoop01 --port 27021

2、 Switch to database config, Set partition block (chunk) The size is 1M. It is mainly to facilitate the display of slicing operation , And we'll slice chunk( block ) Set to 1M, So that inserting a small amount of data can reflect the effect of fragmentation .


3、 Create a test database , Simulate inserting... Into a collection of databases 50000 Documents ( Documentation except for the default _id Field , It also includes id and name Field , Default _id Fields do not need to insert values , Automatic system generation , You can use for Cycle generation id and name value ).
for(i=1;i<=50000;i++){db.user.insert({"id":i,"name":"jack"+i})}

4、 Partition the database : Switch to database gateway, Slice the test database
Use gateway
sh.enableSharding("school")

5、 Slice the set : Switch to database school, The collection of test databases is based on sharding keys id Create index , Switch to database gateway, With "id" As a set of partitioned key pairs user Slice .


6、 Switch to database gateway, Check the slice information .

边栏推荐
- Can Luo Yonghao succeed in entering the AR field this time?
- proxy
- MS | Xie Liwei group found that mixed probiotics and their metabolites could alleviate colitis
- Several forms of buffer in circuit
- Use the array to calculate the average of N numbers, and output the numbers greater than the average
- TCP拥塞控制详解 | 1. 概述
- Niuke Xiaobai monthly race 50
- Calculate the average of N numbers in the group indexed by the formal parameter x, move the data less than the average in the group indexed to the front of the array, and move the data greater than or
- Constructors and Destructors
- Find all primes less than or equal to Lim, store them in AA array, and return the number of primes
猜你喜欢

基于STM32+华为云IOT设计的云平台监控系统

R329 (maix-ii-a (M2A) data summary

Leetcode 1170. Frequency of occurrence of the minimum letter of the comparison string (yes, solved)

C language --- basic function realization of push box 01

# 补齐短板-开源IM项目OpenIM关于初始化/登录/好友接口文档介绍

C语言所有知识点小结

What does the inner structure of the neural network "alchemy furnace" look like? An interpretation of the thesis by the doctor of Oxford University

我把它当副业月入3万多,新手月入过万的干货分享!

架构实战营毕业设计

Web3 decentralized storage ecological landscape
随机推荐
# 补齐短板-开源IM项目OpenIM关于初始化/登录/好友接口文档介绍
108. simple chat room 11: realize client group chat
[matlab project practice] prediction of remaining service life of lithium ion battery based on convolutional neural network and bidirectional long short time (cnn-lstm) fusion
【从删库到跑路】MySQL基础 完结篇(入个门先跑路了。。)
Count the number of each vowel letter in the string
Scala 基础 (二):变量和数据类型
Interpretation of cloud native microservice technology trend
知道这几个命令让你掌握Shell自带工具
MS | Xie Liwei group found that mixed probiotics and their metabolites could alleviate colitis
The student record consists of student number and academic performance. The data of n students have been stored in the a structure array to find out the student record with the lowest performance
Knowing these commands allows you to master shell's own tools
MS|谢黎炜组发现混合益生菌制剂及其代谢产物可缓解结肠炎
7 views on NFT market prospect
Structure the graduation project of actual combat camp
[机缘参悟-31]:鬼谷子-抵巇[xī]篇-危机是危险与机会并存
Swap two numbers
When a programmer is disturbed 10 times a day, the consequences are amazing!
Discussion: the next generation of stable coins
Constructors and Destructors
Teach you to learn dapr - 6 Publish subscription