One, java environment installation
1. Download jdk
Go to jdk to download URL download or download with command in the server
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie "https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
Note that the address of the above jdk-8u191-linux-x64.tar.gz will change, so the download address needs to be replaced with your own.
2. Installation
Create directory
cd /usr/local/< br />mkdir java
cd java
Then upload the installation package to the java folder and unzip
tar zxvf jdk-8u191-linux-x64.tar.gz
Configure environment variables
span class=”code”>vi /etc/profile
Enter at the end of the file
export JAVA_HOME=/usr/local /java/jdk1.8.0_191
export PATH=$PATH:$JAVA_HOME/bin
< span style="background-color: #ffff00">Here pay attention to whether your own is jdk1.8.0_191
Make the environment variable take effect in the current bash
source /etc/profile
Second, zookeeper installation
1. Download
zookeeper download address Download the installation package
or order to download
cd /usr/local
mkdir zookeeper
cd zookeeper
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
tar zxvf zookeeper-3.4.13.tar.gz< /span>
2. Configuration
Create a data folder and open the configuration file
cd zookeeper-3.4.13
mkdir data
cd conf
mv zoo_sample. cfg zoo.cfg
vi zoo.cfg
# The number of milliseconds of each tick
tickTime=2000 span>
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/ usr/local/zookeeper/zookeeper-1/data
dataLogDir=/usr/local/zookeeper/zookeeper-1/log
# the port at which the clients will connect
clientPort=2181< br /># the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns=60 server.1=47.105.232.148:2888:3888 server.2=47.105.232.148:2889:3889 server.3=47.105 .232.148:2890:3890
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain span>in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0< /span>" to disable auto purge feature
#autopurge.purgeInterval=1
quorumListenOnAllIPs=true
The red ones above need attention, because I use one server, so there are three zookeepers here The configuration should be different, otherwise there will be conflicts. The yellow part should also ensure that the ports of server.1, server.2 and server.3 do not conflict. If there are three servers, it is not necessary.
It’s also important to note here that if it is deployed on a cloud server, you need to configure quorumListenOnAllIPs=true to monitor all network cards , This is related to some virtual technologies of the cloud server, otherwise an exception will be thrown
[myid:0 ]-ERROR [/47.94.204.115: 3888:[email protected]763]-Exception while listening
java.net.BindException: Unable to specify the requested address (Bind failed)
at java.net.PlainSocketImpl.socketBind(Native Method)
at java. net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
at java.net .ServerSocket.bind(ServerSocket.java:375)
at java.net. ServerSocket.bind(ServerSocket.java:329)
at org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java: 742)
Back to zookeeper directory
cp -r zookeeper-3.4.13/ zookeeper-1
cp< /span> -r zookeeper-3.4.13/ zookeeper-2
cp -r zookeeper-3.4. 13/ zookeeper-3
Then modify the dataDir dataLogDir clientPort in the configuration file in turn
Finally remember to create their own myid
echo "1"> zookeeper-1/data/ myid
echo "2"> zookeeper-2/data/myid
echo "3"> zookeeper-4/data /myid
Start one by one
./zookeeper-1/bin/zkServer.sh start
./zookeeper-2/bin/zkServer.sh start
./zookeeper-3/bin/zkServer.sh start
View Is it successful?
This is a display failure, here may be a configuration file error or some firewall
I am here because of the cloud The security group of the host is blocked
Close it after modification
./zookeeper-1/bin/zkServer.sh stop
./zookeeper-2/bin/zkServer.sh stop
./zookeeper-3/bin/zkServer.sh stop
Start again, successful
wget --no-check-certificate --no-cookies- -header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz pre>cd /usr/local/
mkdir java
cd javatar zxvf jdk-8u191-linux-x64.tar.gzexport JAVA_HOME=/usr/local/java/jdk1.8.0_191
export PATH=$PATH:$JAVA_HOME/bincd /usr/local
span>mkdir zookeeper
cd zookeeper
wget https ://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper -3.4.13.tar.gz
tar zxvf zookeeper-3.4.13.tar.gzcd zookeeper-3.4.13
mkdir data
cd conf
mv zoo_sample.cfg zoo.cfg
vi zoo.cfg# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# span>do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir= /usr/local/zookeeper/zookeeper-1/data
dataLogDir=/usr/local/zookeeper/zookeeper-1/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
maxClientCnxns=60 server.1=47.105.232.148:2888:3888 server.2=47.105.232.148:2889:3889 server.3=47.105.232.148:2890:3890
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/ zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to"0" to disable auto purge feature
#autopurge.purgeInterval=1
quorumListenOnAllIPs=true< pre> [myid:0]-ERROR [/47.94.204.115:3888:[email protected]763]-Exception while listening
java.net.BindException: Unable to specify the requested address (Bind failed)
At java.net.PlainSocketImpl.socketBind(Native Method)
At java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.ServerSocket.bind(ServerSocket.java:375)
at java.net.ServerSocket.bind(ServerSocket.java:329)
At org.apache.zookeeper.server.quorum.QuorumCnxManager$Listener.run(QuorumCnxManager.java:742)cp -r zookeeper-3.4.13/ zookeeper-1
cp- r zookeeper-3.4.13/ zookeeper- 2
cp -r zookeeper-3.4.13/ zookeeper-3p>
echo "1"> zookeeper-1/data/myid
echo "2"> zookeeper-2/data/ myid
echo " span>3"> zookeeper-4< /span>/data/myid./zookeeper-1/bin/zkServer.sh start
./zookeeper-2/bin/zkServer.shstart
./zookeeper-3/bin/zkServer.sh start./zookeeper-1/bin/zkServer. sh stop
./zookeeper-2/bin/zkServer.sh stop
./zookeeper -3/bin/zkServer.sh stop