1. Preparatory work
Here I just took my brother to teach me about the process of building the Solrcloud, as well as the areas needing attention to document. Thank him for teaching me a lot.
1. IP
The IP addresses of the three installed Linux systems are:
172.24.133.11
172.24.133.21
172.24.133.31
2. Software version
The version of Tomcat that is used is: apache-tomcat-8.0.26
The version of SOLR that is used is: solr-5.3.0
The version of Zookeeper used is: zookeeper-3.4.6
3. Software Decompression Directory
The directory that Tomcat, zookeeper already SOLR has unpacked is:/usr/local/apache/, as shown in:
2. SOLR deploys to TOMCAT1. Find SOLR Project
SOLR is actually a Web service, so we need to deploy SOLR under Tomcat. We need to find Solr.war this file. The Solr.war directory between different versions of SOLR is different. To facilitate the presentation of the directory, use the directory structure under Win7, and the relative path is the same as on Linux.
In Win7 's D-disk directory There is solr5.2.1 unpacking, as solr5.2.1 under the Solr.war directory:
We need to extract this solr.war, for example:
If it's solr5.3.0 then we can't find Solr.war, but we can find WebApp, and all we have to do is rename this folder to SOLR.
After owning the folder SOLR, what we need to do is to copy the necessary jar packages into this folder, as follows: Find the following jar package
Copy these jar packages to
You will also need to copy the Log4j.properties file to the SOLR project, with the following directories:
Copy the log4j.properties to the following directory:
2. Copy SOLR project to Tomcat
Well, now we need to place the Solr file under Tomcat, as shown in the following directory:
The directory structure on Linux is the same. Finally, SOLR will be stored in the Tomcat directory:
3. Create a Solrhome folder
The Solrhome folder is the data that is used to store the SOLR index, which is the full-text search. Solrhome This folder needs to be created manually, and the location can be arbitrary and the name is arbitrary. For example:
You need to find the following two files in solr5.3.0 and copy them to the Multicore folder:
4. Modify the Web. XML for SOLR Project
Although the location where the index was placed has been found, you need to tell the SOLR project where the Solrhome directory is, or else it will not be found.
Code to use under Linux:
Modify the following red box content in the Web. xml file:
Be careful to remove the annotations:
Starting the Tomcat input address LOCALHOST:8080/SOLR, you can see the following interface, indicating that you have succeeded:
If you need to deploy a zookeeper cluster then you need to do the following:
To modify the Solr.xml file in Solrhome, the path used in this article is:/solr/solrhome/multicore/. Add or modify the contents of the Solr.xml file:
3. Zookeeper
You have successfully deployed SOLR to Tomcat with the above introduction, but often need to use zookeeper with SOLR. Simply speaking, zookeeper can manage the data in the SOLR server well and keep the data in multiple SOLR servers in sync. Deploy zookeeper on those three Linux systems, respectively.
1. Modify the configuration in the Zoo.cfg file
Locate the Zoo_sample.cfg file, rename it as: Zoo.cfg, or copy it and rename it to Zoo.cfg.
Add or modify the parameters for the Zoo.cfg file as shown:
Server. A=b:c:d: Where A is a number, indicating that this is the first server, preferably using the last number of native IP address, so it is not easy to repeat, B is the IP address of this server, C is the server and the cluster's Leader server to exchange information on the port; D indicates that in the event of a cluster The Leader server hangs up and requires a port to re-elect a new Leader, which is the port that the server communicates with each other when the election is performed. If it is a pseudo-cluster configuration, because B is the same, so different Zookeeper instance communication port numbers can not be the same, so they should be assigned a different port number.
Initlimit: This configuration item is used to configure the Zookeeper accept client (the client here is not the client that connects the Zookeeper server, but the Leader that is connected to Follower in the Zookeeper server cluster) Server) The maximum number of heartbeat intervals that can be tolerated when a connection is initialized. The client connection failed when the Zookeeper server has not received the return information of the client after 10 heartbeats (that is, ticktime) length. The total length of time is 10*2000=20 seconds.
Synclimit: This configuration item identifies the length of time that a message, request and response is sent between Leader and Follower, the maximum number of ticktime, and the total length of time is 5*2000=10 seconds.
Ticktime: This time is the time interval between the Zookeeper server or between the client and the server to maintain the heartbeat, that is, every ticktime time a heartbeat is sent.
DataDir: As the name implies is Zookeeper to save the data directory, and data directory to create their own, concrete operation to see the next step
ClientPort: This port is the port that the client connects to the Zookeeper server, Zookeeper listens to the port and accepts the client's access request.
2. Create the Data directory
Set up the data directory to hold the zookeeper, for example:
Create the myID file in the Data folder.
The value in myID must be the same as server. A in A=b:c:d is the same. According to the zoo.cfg in the Hu configuration information.
server.11=172.24.133.11:6888:8888
server.21=172.24.133.21:6888:8888
server.31=172.24.133.31:6888:8888
The value of myID on this machine is 11;myid on 172.24.133.21 this machine, the value of 21;myid on 172.24.133.31 on this machine is 31
In fact, the zookeeper cluster configuration is only myID content is not the same, its role is used to represent the different zookeeper of the machine.
4. Uploading Schema.xml and Solrconfig.xml
First, you need to build one in any directory, such as:
The index in the SOLR server is defined in the Schema.xml, and Solrconfig.xml is the relevant configuration of SOLR, and the other files are not content, as long as they are created. My profile: Download
Upload content from E:\111\schemaless_search\conf to/configs/solrcloud/schemaless_search.
Public Static voidMain (string[] args) throws Exception {//TODO auto-generated Method Stub//Zookeeperip Address and port numberString zkserveraddress="127.0.0.1:2181"; String schemeless="Schemaless_search";//E:\111\schemaless_search\confFile config=NewFile ("e:/111/"+ schemeless +"/conf"); System. out. println (Config.exists ()); Solrzkclient Client=NewSolrzkclient (Zkserveraddress, +, +,NewOnreconnect () {@Override Public voidcommand () {}}); Zkconfigmanager ConfigManager=NewZkconfigmanager (client);//default Add path:/configs Cloud directory:/configs/solrcloud/schemaless_searchConfigmanager.uploadconfigdir (Paths.Get("e:/111/"+ schemeless +"/conf"),"solrcloud/"+schemeless); Client.close (); System. out. println ("End");}
To make the index effective:
Public Static voidMain (string[] args) throws Exception {//TODO auto-generated Method StubString CollectionName ="Schemaless_search"; //IP of SOLR serverCloudsolrclient client =NewCloudsolrclient ("172.24.133.13"); Collectionadminrequest.delete Delete=NewCollectionadminrequest.delete (); //If the Schemaless_search folder is present, delete it firstDelete.setcollectionname (CollectionName); Collectionadminresponse response; Try{Response=delete.process (client); System. out. println (response); } Catch(Exception e) {e.printstacktrace (); } collectionadminrequest.create Create=Newcollectionadminrequest.create (); Create.setcollectionname (CollectionName); //directory/configs/solrcloud/schemaless_search Locate the file and loadCreate.setconfigname ("solrcloud/"+CollectionName); Create.setnumshards (2); Create.setmaxshardspernode (2); Create.setreplicationfactor (2); Response=create.process (client); Client.close (); }
So far all the configurations have been completed, and access to the SOLR server can be seen.
Deploying Solrcloud under Linux