Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The process of building Zookeeper environment

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "the process of building Zookeeper environment". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. background

Personal habit to see the source code when compiling successfully and running and then start to see, now most of the source code is managed by maven, just import it, zookeeper due to the age is relatively old, rely on management or use Apache Ant, so here special record.

The environment of this paper is based on Windows10 1903 + Ant 1.10.6 + IDEA 2019.2

By the end of this article, pom.xml has been available in versions 3.5.5 and 3.4.14 of zookeeper, but it is always reported that org.apache.zookeeper.data does not exist during compilation. After compiling with ant, it is found that the package is in the zookeeper-jute/target directory. I don't know what the situation is for the time being. Friends who understand it can leave a message: metal:

Second, build the environment 2.1 download the source code

Download the source code of the version you want from https://github.com/apache/zookeeper/releases and decompress it. Here you download 3.4.14

2.2 install Apache Ant

Download the ant distribution package from https://ant.apache.org/bindownload.cgi and extract it, assuming that the decompressed directory is D:\ apache-ant-1.10.6

Add a new environment variable ANT_HOME=D:\ apache-ant-1.10.6; add a% ANT_HOME%\ bin to the environment variable PATH

Open cmd and run ant-v to see if the configuration is successful

2.3 compile the source code

Open cmd, go to the unzipped zookeeper directory, run ant eclipse to compile and convert the project into the eclipse project structure (because IDEA does not recognize the ant project, but can recognize the eclipse project), and then wait for a period of time, it took me about 10 minutes

2.4 Import source code

Open IDEA, select Import eclipse Project, and then next all the way.

2.5 run zookeeper

Search for the class QuorumPeerMain and click the green triangle on the left to run it once.

By default, there will be a build before running, and an error will be reported in the compilation.

Enter the org.apache.zookeeper.Version class and see a red color.

Check it out, this should be used by zookeeper to generate the version when it is released, and we don't release the version, so just write it to death.

The modified code is as follows

Public class Version {/ * * Since the SVN to Git port this field doesn't return the revision anymore * TODO: remove this method and associated field declaration in VerGen * @ see {@ link # getHashRevision ()} * @ return the default value-1 * / @ Deprecated public static int getRevision () {return-1;} public static String getRevisionHash () {return "1" } public static String getBuildDate () {return "2019-08-11";} public static String getVersion () {return "3.4.14";} public static String getVersionRevision () {return getVersion () + "-" + getRevisionHash ();} public static String getFullVersion () {return getVersionRevision () + ", built on" + getBuildDate () } public static void printUsage () {System.out .print ("Usage:\ tjava-cp... Org.apache.zookeeper.Version "+" [--full |-- short |-- revision],\ n\ tPrints-- full version "+" info if no arg specified. "); System.exit (1);} / * * Prints the current version, revision and build date to the standard out. * * @ param args * *-short-prints a short version string "1.2.3" *-- revision-prints a short version string with the SVN * repository revision "1.2.3-94" *-- full-prints the revision and the build date * * / public static void main (String [] args) {if (args.length > 1) {printUsage () } if (args.length = = 0 | (args.length = = 1 & & args [0] .equals ("--full")) {System.out.println (getFullVersion ()); System.exit (0);} if (args [0] .equals ("--short")) System.out.println (getVersion ()) Else if (args [0] .equals ("--revision")) System.out.println (getVersionRevision ()); else printUsage (); System.exit (0);}}

Then, if you run it again, it will still report an error, but it is not important. After running, the corresponding configuration item will appear above and enter the modification.

Specify the location of the configuration file in the command line argument

Go to the conf directory, copy zoo_sample.cfg, rename it to zoo.cfg, and modify it according to your needs.

Copy log4j.properties to the zookeeper-server directory

Then run it again, and you can see the familiar console startup interface.

This is the end of the content of "the process of building a Zookeeper environment". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report