Installing the Zookeeper cluster _php tutorial on CentOS 7

Source: Internet
Author: User

Installing the Zookeeper cluster on CentOS 7


Install Java software on test machine
$ rpm-qa|grep Java
$ sudo yum install-y java-1.8.0-openjdk.x86_64
$ java-version
OPENJDK Version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-bit Server VM (build 25.65-b01, Mixed mode)

1. Create User: Bjrenrui0001~0003
sudo groupadd zookeeper
sudo useradd-g zookeeper zookeeper
echo "zookeeper@1234" |sudo passwd Zookeeper-stdin

2. Create a working directory
BJRENRUI0001:
sudo mkdir/yanfa/mq
sudo ln-s/yanfa/mq/mq
sudo chown-r dreamjobs.dreamjobs/mq

BJRENRUI0002~0003:
sudo mkdir MQ
sudo chown dreamjobs.dreamjobs MQ
sudo ln-s/home/backupfile/mq/mq
sudo chown dreamjobs.dreamjobs MQ

1. Stand-alone mode (Standalone modes)
Download, unzip
Cd/mq
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.7/zookeeper-3.4.7.tar.gz
Tar zxvf zookeeper-3.4.7.tar.gz-c/mq
Ln-s/mq/zookeeper-3.4.7 Zookeeper

Start
Default is stand-alone mode
cd/mq/zookeeper/
CP./conf/zoo_sample.cfg./conf/zoo.cfg
Sh./bin/zkserver.sh start

Firewall Open Port 2181

Check Service Status:
[dreamjobs@bjrenrui0001 bin]$ sh zkserver.sh status
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Mode:standalone

Using the Java Client Connection zookeeper
./bin/zkcli.sh-server 127.0.0.1:2181
You can then use a variety of commands, similar to the file manipulation commands, and enter Help to see all the commands.

Shut down
SH bin/zkserver.sh stop

2 distributed modes (replicated mode)
In a production environment, you have to configure it as a distributed model to be powerful.
Zookeeper clusters are generally referred to as Zookeeper Ensemble (integrated), or quorum (quorum).

Prepare 3 Machines

Assuming there are three machines, the hostname and IP correspondence are:
192.168.100.200 bjrenrui0001
192.168.100.201 bjrenrui0002
192.168.100.202 bjrenrui0003

Zookeeper there is no obvious master/slave relationship, each node is a server, leader Hung, will immediately follower from the election of one out as leader.
Because there is no master-slave relationship, nor do you have to configure SSH login without password, each ZK server is self-initiated, with each other through the TCP port to Exchange data.

To create a log and data directory:
bjrenrui0001~0003
Cd/mq/zookeeper
Mkdir-p Zookeeperdatadir/{logs,data}

Modify the configuration file for bjrenrui0001 conf/zoo.cfg:
[dreamjobs@bjrenrui0001 conf]$ grep-ve ' ^ ($|#) ' Zoo.cfg
ticktime=2000
initlimit=10
Synclimit=5
Datadir=/mq/zookeeper/zookeeperdatadir/data
Datalogdir=/mq/zookeeper/zookeeperdatadir/logs
clientport=2181
server.1=bjrenrui0001:2888:3888
server.2=bjrenrui0002:2888:3888
server.3=bjrenrui0003:2888:3888
After modification, copy to bjrenrui0002, and bjrenrui0003

myID file:
To create a new myID file under the DataDir of each machine, a number is stored to identify the current host
Bjrenrui0001:echo "1" >>/mq/zookeeper/zookeeperdatadir/data/myid
Bjrenrui0002:echo "2" >>/mq/zookeeper/zookeeperdatadir/data/myid
Bjrenrui0003:echo "3" >>/mq/zookeeper/zookeeperdatadir/data/myid

Start the Zookeeper service on each machine:
bjrenrui0001:sh/mq/zookeeper/bin/zkserver.sh start
bjrenrui0002:sh/mq/zookeeper/bin/zkserver.sh start
bjrenrui0003:sh/mq/zookeeper/bin/zkserver.sh start
Stop the Zookeeper service on each machine:
bjrenrui0001:sh/mq/zookeeper/bin/zkserver.sh stop
bjrenrui0002:sh/mq/zookeeper/bin/zkserver.sh stop
bjrenrui0003:sh/mq/zookeeper/bin/zkserver.sh stop
Since the start of 3 nodes is sequential, so when the start of the three nodes in succession, the node before the start of the node connection is not started when the nodes will report some errors, can be ignored.

The firewall turns on port 2181:
sudo vi/etc/sysconfig/iptables
-A input-p tcp-s 192.168.100.0/24-j ACCEPT
sudo systemctl restart Iptables.service

View status
[dreamjobs@bjrenrui0001 conf]$ gmbjyf.sh bjyfnbserver "Cat/mq/zookeeper/zookeeperdatadir/data/myid"
bjrenrui0001
1
bjrenrui0002
2
bjrenrui0003
3
$ gmbjyf.sh bjyfnbserver "sh/mq/zookeeper/bin/zkserver.sh Restart"
bjrenrui0001
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Starting zookeeper ... STARTED
bjrenrui0002
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Starting zookeeper ... STARTED
bjrenrui0003
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Starting zookeeper ... STARTED

$ gmbjyf.sh bjyfnbserver "sh/mq/zookeeper/bin/zkserver.sh status"
bjrenrui0001
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Mode:follower
bjrenrui0002
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Mode:leader
bjrenrui0003
ZooKeeper JMX enabled by default
Using config:/mq/zookeeper/bin/. /conf/zoo.cfg
Mode:follower

Connecting a zookeeper cluster using a Java client
Find a machine, unzip zookeeper compressed package, without configuration, you can use the Java client to connect zookeeper any server in the cluster.
$ sh/mq/zookeeper/bin/zkcli.sh-server bjrenrui0001:2181
$ sh/mq/zookeeper/bin/zkcli.sh-server bjrenrui0002:2181
$ sh/mq/zookeeper/bin/zkcli.sh-server bjrenrui0003:2181

http://www.bkjia.com/PHPjc/1091523.html www.bkjia.com true http://www.bkjia.com/PHPjc/1091523.html techarticle install Java software on CentOS 7 installation zookeeper cluster test machine $ rpm-qa|grep java $ sudo yum install-y java-1.8.0-openjdk.x86_64 $ java-ve Rsion openjdk Version "1.8.0_6 ...

  • 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.