当前位置:网站首页>2021-08-30 distributed cluster
2021-08-30 distributed cluster
2022-06-13 03:10:00 【Yiliubei】
1、 Prepare four virtual machines
The user names are node1,node2,node3,node4
Enter the command
cd /etc/sysconfig/network-scripts/
modify vim vim ifcfg-eth0, In order to make IP Different settings are static, as shown in the following figure :
2、 Realize the secret free login of four virtual machines
(1) First, execute on all four servers :
ssh-keygen -t dsa -P ‘’ -f ~/.ssh/id_dsa
(2) stay node1 Admiral node1 Copy the public key of to authorized_keys in :
id_dsa.pub : Public key
known_hosts Private key
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
(3) Copy the file to node2:
scp ~/.ssh/authorized_keys node2:/root/.ssh/
(4) stay node2 Lieutenant general node2 The public key of is appended to authorized_keys in :
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
(5) Copy the file to node3:
scp ~/.ssh/authorized_keys node3:/root/.ssh/
(6) stay node3 Lieutenant general node3 The public key of is appended to authorized_keys in :
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
(7) Copy the file to node4:
scp ~/.ssh/authorized_keys node4:/root/.ssh/
(8) stay node4 Lieutenant general node4 The public key of is appended to authorized_keys in :
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
(9) Copy the file to node1、node2、node3:
scp ~/.ssh/authorized_keys node1:/root/.ssh/
scp ~/.ssh/authorized_keys node2:/root/.ssh/
scp ~/.ssh/authorized_keys node3:/root/.ssh/
Be careful : Use scp When it's time to vim /etc/hosts file , That is, the host that needs to log in without secret IP And the user name
3、JDK Install environment variable configuration
node1-node4
mkdir /opt/apps
take jdk-8u221-linux-x64.rpm Upload to node1/opt/apps
take /opt/apps Under the jdk.rpm scp To node2、node3、node4 In the corresponding directory of
scp jdk-8u221-linux-x64.rpm node2:/opt/apps
scp jdk-8u221-linux-x64.rpm node3:/opt/apps
scp jdk-8u221-linux-x64.rpm node4:/opt/apps
stay node1、node2、node3、node4 Installation on jdk And configuration profile file
rpm -ivh jdk-8u221-linux-x64.rpm
node1 Modify environment variables on
vim /etc/profile
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
take node1 Of /etc/profile copy to node2、node3、node4 Go up and execute . /etc/profile
scp /etc/profile node[234]:`pwd`
4、ZooKeeper Cluster building
take ZooKeeper.tar.gz Upload to node2
b) Unzip to /opt
tar -zxvf ZooKeeper-3.4.6.tar.gz -C /opt
c) Configure environment variables :
export ZOOKEEPER_HOME=/opt/zookeeper-3.4.6
export PATH=$PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin
then ./etc/profile Make the configuration work
Finally, the file scp To node3 and node4 On , And separately ./etc/profile Make the configuration work .
scp /etc/profile node3:/etc/
scp /etc/profile node4:/etc/
d) To $ZooKeeper_HOME/conf Next
Copy zoo_sample.cfg by zoo.cfg
cp zoo_sample.cfg zoo.cfg
e) edit zoo.cfg
Add : Parameter description
tickTime=2000 # The interval between heartbeats , Company : millisecond
dataDir=/opt/zookeeper-3.4.6/data #ZooKeeper The directory where the data is stored
dataLogDir=/var/bjsxt/zookeeper/datalog # Log directory
clientPort=2181
initLimit=5
syncLimit=2
server.1=server2:2881:3881
server.2=server3:2881:3881
server.3=node4:2881:3881 #observer( Indicates that the corresponding node does not participate in voting )
clientPort: Client connection ZooKeeper The port of the server ,ZooKeeper Will listen to this port , Pick up
Access request from client .
initLimit: This configuration item is used for configuration ZooKeeper Accept clients ( The client mentioned here is not a user
Connect ZooKeeper The client side of the server , It is ZooKeeper Connect to the server cluster Leader Of
Follower The server ) The maximum number of heartbeat intervals that can be tolerated when initiating a connection . When it has exceeded 5 A heart
Jump time ( That is to say tickTime) After the length ZooKeeper The server has not received a return message from the client ,
So it indicates that the client connection failed . The total length of time is zero 52000=10 second
syncLimit: This configuration item identity Leader And Follower Sending messages between , Length of request and reply time ,
No more than that tickTime Length of time , The total length of time is zero 22000=4 second
server.A=B:C:D: Its in A It's a number , Which server is this ;B It's this server
Of ip Address ;C It represents the server and the cluster Leader The port on which the server exchanges information ;D It means
In case of Leader The server is down , You need a port to re-election , Pick a new one
Leader, And this port is the port that the servers communicate with each other during the election . If it is the configurator of the pseudo cluster
type , because B Is the same , So different ZooKeeper The instance communication port number cannot be the same , So give them points
With different port numbers .
Add as follows :
server.1=node2:2881:3881
server.2=node3:2881:3881
server.3=node4:2881:3881
modify
dataDir=/opt/ZooKeeper-3.4.6/data
f) establish /opt/ZooKeeper-3.4.6/data Catalog , And put a file in the directory :myid
stay myid Write down the current ZooKeeper The number of
mkdir /opt/zookeeper-3.4.6/data
mkdir /var/bjsxt/zookeeper/datalog
echo 1 > /opt/zookeeper-3.4.6/data/myid
g) Configure the ZooKeeper copy to node3、node4 On
scp -r ZooKeeper-3.4.6/ node3:/opt/
scp -r ZooKeeper-3.4.6/ node4:/opt/
h) stay node3 and node4 I'm going to change :myid
node3
echo 2 > /opt/ZooKeeper-3.4.6/data/myid
node4
echo 3 > /opt/ZooKeeper-3.4.6/data/myid
i) To start, respectively, ZooKeeper
zkServer.sh start start-up zk
zkServer.sh stop stop it zk
zkServer.sh status see zk state
zkServer.sh start|stop|status
j) close ZooKeeper
zkServer.sh stop
l) Connect ZooKeeper
zkCli.sh node2、node3、node4 Fine
m) sign out zkCli.sh command
quit
Provide cluster mode services
Atomicity
Accurate feedback on success or failure
Uniformity
Every server There is a unified data view
Usability
Node failure does not affect the use Less than half the downtime , That's all right.
Network partition / Split brain : More than half pass
Who is older myid:
1 2 3 ( At the same time to start )
1 2 3 ( Start one by one )
Who has new data :
3 3 4 Business id(zxid) Big ones are leaders
3 Taiwan machine Hang one 2>3/2
5 Taiwan machine Hang up 1 platform 4>5/2( Can work ) hang 3 platform 2!>5/2( Clusters don't work )
Sequence :FIFO
The master-slave model
Leader Follower+
Read more than a writing
Leader Responsible for adding, deleting and modifying ,Follower Read and vote
State of the cluster
Election model Anqinei
Broadcast mode Outside
Server state
LOOKING: At present Server I do not know! leader Who is it? , Searching for
LEADING: At present Server It's an elected leader
FOLLOWING:leader It has been elected , At present Server Keep up with it
Division of labor between master and slave
The leader (leader)
Responsible for the initiation and resolution of the vote , Update system status ,( Additions and deletions )
Learners' (learner)
Including followers (follower) And the observer (observer),follower Used to accept clients
Request and return results to the client , Participate in voting during operation
Observer
Can accept client connections , Forward the write request to leader, but observer Not in the voting process ,
Sync only leader The state of ,observer The goal is to extend the system , Improve read speed
client (client)
Request originator
边栏推荐
- Beginner development process_ Project development FAQs
- JVM virtual machine stack (III)
- Mongodb index -index
- Svg filter effect use
- Spoon database insert table operation
- Hash table: the time complexity of insert, delete and random access is O (1)
- SQL execution process in MySQL (3)
- JS deconstruction assignment
- Linked list: delete the penultimate node of the linked list
- Scala implements workcount
猜你喜欢
2019 - sorting out the latest and most comprehensive IOS test questions (including framework and algorithm questions)
Es and kibana deployment and setup
开源-校园论坛和资源共享小程序
【pytorch 記錄】pytorch的變量parameter、buffer。self.register_buffer()、self.register_parameter()
The weight of the input and textarea components of the applet is higher than that of the fixed Z-index
【 enregistrement pytorch】 paramètre et tampon des variables pytorch. Self. Register Buffer (), self. Register Paramètre ()
Prometheus安装并注册服务
When the flutter runs the project, the gradle download fails, and the running gradle task 'assemblydebug' is always displayed
C # simple understanding - method overloading and rewriting
CDN single page reference of indexbar index column in vant framework cannot be displayed normally
随机推荐
Stack information, GC statistics
Prometheus安装并注册服务
Prometheus node_exporter安装并注册为服务
IOS interview · full bat interview record of an IOS programmer (including the true interview questions of Baidu + Netease + Alibaba)
專業的數據庫管理軟件:Valentina Studio Pro for Mac
C# . NET ASP. Net relationships and differences
Introduction to Kestrel_ Introduction to kestrel web server
On the limit problem of compound function
Add Yum source to install php74
Ijkplayer source code ---packetqueue
JMeter quick start
mysql索引
Uni app Foundation
C method parameter: out
Linked list: the first coincident node of two linked lists
Detailed explanation of curl command
Exercise 8-3 rotate array right
In my ten years, every bit has become a landscape?
Wechat applet coordinate location interface usage (II) map interface
Least recently used cache (source force deduction)