1.java version View JDK version.
2.rpm -qa | grep java to find out which java-related packages are available.
3.rpm-e-nodeps tz data-Java-20 15e- 1 . e 16 . no arch? Unload,-nodeps means there is no dependency, and the related dependency is ignored to force unloading.
4.mkdir /export/server creates the installation directory of zookeeper and JDK.
5.
Mvjdk1.8.0 _ 65.tar.gz/export/server moved the JDK installation package to the /export/server folder?
CD/Export/Server? Enter this folder, and ls View can see the installation package.
Tar-zxvf JDK1.8.0 _ 65.tar.gz uploads JDK to linux system, and then performs tar decompression operation?
6.vi /etc/profile Edit the configuration file in the /etc directory, which is used to configure environment variables.
7. After opening the file, press capital G to jump directly to the last line of the file, then press I to enter the file editing state, and finally add these three lines of configuration information.
Export Java _ home =/export/server/JDK.1.8.0 _ 65? Configure a JAVA_HOME variable whose value is the installation directory of jdk. This JAVA_HOME will be used in the following two lines.
Export path =$PATH:$JAVA_HOME/bin
Export classpath =. :$ JAVA _ HOME/lib/dt . jar:$ JAVA _ HOME/lib/tools . jar
After editing, press ESC to exit the file editing state, and then enter the instruction? : wq (colon +wq) Enter to exit and save the file.
8.source /etc/profile refreshes the configuration file to the system memory.
9. Enter? Java -v view JDK version
After installing the above JDK, install zookeeper next.
10. Just like uploading JDK, unzip the zookeeper-3.4. 10.tar.gz file in the /export/server directory. (If you forget, please go to step 5.)
Tar -zxvf city zoo -3.4. 10.tar.gz
? After decompression, relevant configuration is required (software installation is nothing more than decompression+configuration).
There are two important changes here: 1.zookeeper service starts, where is the data file saved? 2. city zoo is usually clustered, that is, several city zoo services are started at the same time, so the ip and ports of other city zoo should be configured in the configuration file of each city zoo service. If you don't understand the second point, just look at the configuration file.
1 1.? First, to achieve the first point, create a zookeeper data storage directory.
Mkdir /export/data/zkdata creates a zkdata folder to store zookeeper data. (If this item is reported incorrectly, it means that mkdir /export/data/ should be executed first to create a data directory. )
12. Next, configure.
cd zookeeper/conf/? Configuration files are placed in this directory, and ll can check which files are available, as shown in the figure below.
There is a zoo_sample.cfg file. This file is an attached template that tells you to copy the configuration file like this. . .
Then there is another important thing: zookeeper will read the configuration file zoo.cfg under the file path by default when it starts, but here I don't have this file by default. Therefore, we can copy a zoo_sample.cfg and rename it as zoo.cfg, but you must go in and make your own configuration changes. The copy file command is:
cp zoo_sample.cfg zoo.cfg
13.vi zoo.cfg? Start editing the configuration file. When you open it, you can see a bunch of things that you may not understand, but it doesn't matter, because most of them are comments. Beginners don't have to worry so much
There are two main changes here. Which two? As described in bold: data storage directory, ip port of each zookeeper service in the cluster.
Similarly, press I to enter edit mode and find dataDir=/tmp. . . This line. This line is the directory where the data is stored. Change it to our own new directory:
DataDir=/export/data/zkdata/ to configure the first point.
In fact, the zookeeper service has been installed here, but as I said, zookeeper is a cluster, so we must build more servers. I used three virtual machines here and copied three. The ip numbers are 192. 168.209+028 respectively. /? 192. 168.209. 129 /? 192.168.209.130, these three machines are also equipped with JDK and zookeeper. Just repeat the previous operation, or copy the virtual machine directly.
Similarly, in zoo.cfg, capitalized g goes to the last line. Add these three lines of configuration at the end:
Server.1=192.168.209.128: 2888: 3888 # Three services correspond to the server 1 2 3, corresponding to three IPS. The last two ports are heartbeat port 2888 and election port.
server . 2 = 192. 168.209 . 129:2888:3888
server . 3 = 192. 168.209 . 130:2888:3888
Then save and exit.
13. The last step is to set the id for the three zookeeper services. Where can I set it up?
Is to create a /export/data/zkdata/myid file in the directory where zookeeper saves files. The file name can't be scribbled, it must be this, which is very important during the election.
We have three zookeeper servers, and the number of myid files in each server is different. You have to go into three servers to edit this file separately.
The first server, vi myid? Edit the file and write a number 1?
The second server, vi myid? Edit the file and write a number 2.
The third server, vi myid? Edit the file and write a number 3.
14. Finally, start zookeeper and try to install it successfully.
/export/server/zookeeper/bin/zkserver.sh start command to start zookeeper. You can see that the log prints out the default configuration file. With zoo.cfg, you have to start all three services, and zookeeper will send heartbeats according to the three ip ports you configure, and automatically establish a cluster. And choose which server is the leader and which is the follower according to myid. ?
Here it is. Almost installed! Hands-on operation is only 14 steps. But figuring out the principle is the most important thing.