A, zookeeper introduced?
A, zookeeper brief? 1 What is a cluster? // Many servers maintain the intercellular communication state, and all do the same thing on the call server cluster 2 . What is the zookeeper? Registry is the zookeeper (eureka, consul) alias zookeeper is a top open source project under the apache Foundation zookeeper is a commitment to the development and maintenance of open source server, the role of the project in coordination and control functions Scene: air conditioning is broken, students went to the class teacher, said air conditioning is broken, it will not repair the air conditioner teacher, class teacher that Bangladesh will repair air conditioning, the teacher will not result Meng, Meng teacher final call to after-sales, after-sales assuming that the air conditioning repaired, eventually reaching students the expected results of students is a demand, after-sales service person, Meng teacher and class teacher is the facilitator zookeeper zoo administrator logo from the point of view, all the animals in the zoo zookeeper by management, management of the basic necessities of animals, zookeeper at the earliest when only applies to the Hadoop ecosystem, all frames are animals, zookeeper for their health management, management framework (heartbeat) in the Hadoop ecosystem, the caller server and server producers, that is to say the final services directly to the client no longer The server sends data service, the first client to find zookeeper, based on feedback from the server side to find the zookeeper hadoop is the elephant hbase whales pig is a pig .... storing large amounts of data in a zookeeper in the (very useful), but the developers do not see the data, and zookeeper will be in accordance with the time that has been registered with the services they ask for a heartbeat, according to the observer mode, upon detecting a status change, eventually registered to the zookeeper observer (server) to deal with action! / * The observed object is -------------> zookeeper observation target is ----------------> server * / . 3 .zookeeper application scenario : prior to apply only to large data, but with the growing web project, the development of faster and faster, zookeeper has been fully applicable to the entire web project, still plays a coordinating and controlling role in the web project zookeeper based cluster the form, that is to say three zookeeper do the same thing, / * in the official documentation instructions, zookeeper odd stage as stable, and in the middle of the table as the leader, that is to say zookeeper at least three (not a Taiwan, called a single-node) * / why Taiwan is an odd stable? ? zookeeper is a leader led many a follower complete cluster, and odd and electoral mechanisms
Two, Linux configuration zookeeper?
Second, the configuration zookeeper? 1 . New three virtual machines five steps Vim / etc / sysconfig / Network Vim / etc / the hosts -Service iptables STOP the chkconfig iptables OFF reboot 2 . Configuration JDK 2 .1 introduced jdkjar package. 2 .2 Configuration java environment variables. 3 . Configure a free login keys to generate their own public four times a carriage return (can not enter your password) / * SSH-keygen -t rsa SSH-keygen -t rsa SSH-keygen -t rsa SSH-keygen -t rsa SSH-keygen rsa -t * / His own public copy on another server other two need to copy !!! / * SSH-copy the above mentioned id ip-address / hostname SSH-copy the above mentioned id ip- SSH-copy-the above mentioned id 192.168.11.116 SSH-copy-haha the above mentioned id * / after successful configuration, ssh connection to access. / ** SSH + another ip address of the virtual machine / name SSH haha SSH ZooKeeper SSH ZooKeeper * / 4-extracting ZooKeeper tar - zxvf XXXXX 5 . The conf directory [Zoo - renamed sample.cfg file zoo.cfg] modification command file: mv + filename of the file name box modify as needed. / * Zoo-sample.cfg zoo.cfg Music Videos Music Videos Zoo-sample.cfg zoo.cfg Music Videos Zoo-sample.cfg zoo.cfg Music Videos Zoo-sample.cfg zoo.cfg Music Videos Zoo-sample.cfg zoo.cfg Music Videos Zoo-Sample. zoo.cfg CFG * / 6. the parameter modification dataDir (not necessarily to be modified, but requires modification) refers to a file that is unique identification (id) zookeeper each node, and the unique identification can not be duplicated !!!! 1 . create a folder data acquired in the data path pwd zookeeper directory. (pwd) / * mkdir data cd data pwd get the path * / 2 . withdraw, modify dataDir modify the absolute path to data directory just created the dataDir modify the data directory just created absolute path in the conf / * vim dataDir DataDir dataDir absolute path to modify the data directory just created = / Home / Apps / ZooKeeper-3.4.6 / data * / 7 at the end of the file add zoo.cfg. / ** server.1 = zookeeper01: 2888: 3888 server.2 = zookeeper02: 2888: 3888 server.3 = zookeeper03: 2888: 3888 . 7.1 Server data that uniquely identifies each zookeeper 7.2 zookeeper01: HOSTNAME or IP address can be configured 7.3 2888: cluster communication used between the zookeeper port number 7.4 3888: election leader zookeeper cluster port number * / 8 . before you create a data file created myid folder Touch myid 9 written myid file. vim myid 1 10 transmits to the server through the other two SCP. Syntax scp -r / home / apps / (path needs to be sent) space zookeeper02 (target ip / hostname): / Home / (needs to be sent to the target location) put on zookeeper01 virtual machine / home / apps / sent to zookeeper02 in: home / directory. / * Scp -r / Home / Apps / zookeeper02: / Home / scp -r / Home / Apps / zookeeper03: / Home / scp -r / Home / Apps / zookeeper02: / Home / * / will be equipped with java configuration environment copy the past. SCP -R & lt / etc / Profile zookeeper01: / etc / SCP / etc /: -R & lt / etc / Profile zookeeper01 SCP IP -R & lt / etc / proflie virtual machine requires: / etc / (the unit is required to copy the address) ( address the need to copy the virtual machine) / * -r scp / etc / proflie zookeeper02: / etc / scp -r / etc / proflie zookeeper03: / etc / scp -r / etc / proflie haha: / etc / * / effect immediately command Source / etc / Profile tried it without It is also available. No promises. . . 4.10 . According server. Myid digital files are modified to modify zookeeper02 2 to 3 zookeeper03 modified 4.11 . Zookeeper start start bin directory / * ./zkServer.sh Start ./zkServer.sh Start ./zkServer.sh Start start ./zkServer.sh * / see the following instructions to start successfully: Enabled by JMX default ZooKeeper election mechanism is used in Paxos algorithm implemented Config the Using: /home/apps/zookeeper-3.4.6/bin/../conf/ zoo.cfg Starting zookeeper ... the STARTED 4.12 detect the state of the three zookeeper server. In the bin directory / * ./zkServer. Status SH ./zkServer.sh Status * / close / * ./zkServer.sh STOP ./zkServer.sh STOP ./zkServer.sh STOP * / Leader and follower eldest brother 5 election mechanism .zookeeper of 5.1 in other words half of the election mechanism whose server id who is the big brother! ! ! Half of the election leader node generates high 32 change. 5Id .2zid things, a total of 64-bit, 32-bit high and low 32-bit, respectively. When the leader is down. Zid all servers will automatically increase. Low 32 increment according to a rule high increase 32 unchanged. 32 zid low to be smaller, the greater the likelihood to be elected, the greater the possibility of being operated / * zxid (Low 32 High 32 + combined) may be larger the greater the operation. * /