Deploy SolrCloud in Linux
1. Preparations
Here, I will only document the SolrCloud setup process that my senior teacher taught me and what I should pay attention. Thank you for teaching me a lot.
1. Sub-IP Address
The IP addresses of the three hosts that install linux are as follows:
- 172.24.133.11
- 172.24.133.21
- 172.24.133.31
2. Software Version
- The tomcat version used is apache-tomcat-8.0.26.
- The version of solr used is: solr-5.3.0
- The version of zookeeper used is: zookeeper-3.4.6
3. Software extraction directory
The directory where tomcat and zookeeper have been decompressed by solr is/usr/local/apache/, as shown in:
2. Deploy solr to tomcat1. find the solr Project
Solr is actually a web service, so we need to deploy solr under tomcat. We need to find the solr. war file. Solr. war directories vary with solr versions. To facilitate the display of directories, use the directory structure under win7. The relative path is the same as that on linux.
There is a solr5.2.1 decompression package under the d directory of win7, such as the directory where solr. war is located under solr5.2.1:
We need to decompress solr. war, for example:
If solr5.3.0 is used, we cannot find solr. war, but we can find webapp. All we need to do is rename this folder to solr.
What we need to do after we have the folder solr is to copy the necessary jar package to this folder. The specific operation is as follows: Find the following jar package
Copy these jar packages
You also need to copy the log4j. properties file to the solr project. The specific directory is as follows:
Copy log4j. properties to the following directory:
2. Copy the solr project to tomcat
Now we need to place the solr file under tomcat. The specific directory is as follows:
The directory structure on linux is the same. Finally, solr should be stored in the tomcat directory:
3. Create the solrhome folder
The solrhome folder is used to store solr indexes, that is, full-text retrieval data. You need to manually create the solrhome folder, which can be any location and has any name. 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 of the solr Project
Although the index location has been found, you need to tell the solr project where the solrhome directory is, or else it cannot be found.
Code Used in linux:
Modify the content in the following red box in the web. xml file:
Note:
Start the tomcat input address localhost: 8080/solr. The following interface is displayed, indicating that you have succeeded:
To deploy a zookeeper cluster, perform the following operations:
Modify the solr. xml file in solrhome. The path used in this article is/solr/solrhome/multicore /. Add or modify the content in the solr. xml file:
3. zookeeper
Through the above introduction, you have successfully deployed solr on tomcat, but you often need to use zookeeper with solr. To put it simply, zookeeper can manage the data on the solr server well and keep the data in multiple solr servers synchronized. Deploy zookeeper on the three linux systems respectively.
1. modify the configuration in the zoo. cfg file
Find the zoo_sample.cfg file, rename it to: zoo. cfg, or copy it and rename it to zoo. cfg.
Add or modify parameters for the zoo. cfg file as follows:
Server. A = B: C: D: where A is A number, indicating the number of the server. It is best to use the last few digits of the local IP address, which is not easy to repeat; B Indicates the ip address of the server; C indicates the port on which the server exchanges information with the Leader server in the cluster; D indicates that if the Leader server in the cluster fails, A port is required for re-election and a new Leader is selected, which is the port used for server communication during the election. For the pseudo cluster configuration method, because B is the same, different Zookeeper instance communication port numbers cannot be the same, so you need to assign them different port numbers.
InitLimit: This configuration item is used to configure Zookeeper to accept the client (the client mentioned here is not the client that the user connects to the Zookeeper server, but the Follower server connected to the Leader in the Zookeeper server cluster) the maximum heartbeat interval that can be tolerated during connection initialization. When the length of the heartbeat exceeds 10 (tickTime), the Zookeeper server does not receive the response from the client, which indicates that the connection to the client fails. The total length is 10*2000 = 20 seconds.
SyncLimit: This configuration item identifies the length of time for sending messages, requests, and responses between the Leader and Follower. the maximum length of time is 5*2000 = 10 seconds.
TickTime: This is the interval between the Zookeeper server or between the client and the server to maintain the heartbeat, that is, a heartbeat will be sent every tickTime.
DataDir: As the name implies, it is the directory where Zookeeper stores data. You must create the data directory by yourself. For details, refer to the next step.
ClientPort: the port connecting the client to the Zookeeper server. Zookeeper listens to the port and accepts access requests from the client.
2. Create a data directory
Create a data directory to store zookeeper data, for example:
Create a myid file in the data folder.
The value in myid must be the same as A in server. A = B: C: D. According to the Hu configuration information in zoo. cfg.
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 the server 172.24.133.11 is 11, the value of myid on the server 172.24.133.21 is 21, and the value of myid on the server 172.24.133.31 is 31.
In fact, the configuration of the zookeeper cluster is only different from the content in the myid. It is used to indicate the machines of different zookeeper.
4. Upload schema. xml and solrconfig. xml
First, you need to build one in any directory, such:
The index in the solr server is defined in schema. xml; solrconfig. xml is related to solr configurations; other files have no content, as long as they are created.
Download my configuration file
------------------------------------------ Split line ------------------------------------------
Free in http://linux.bkjia.com/
The username and password are both www.bkjia.com
The specific download directory will be used to deploy SolrCloud/
For the download method, see
------------------------------------------ Split line ------------------------------------------
Upload the content in E: \ 111 \ schemaless_search \ conf to/configs/solrcloud/schemaless_search.
Public static void main (String [] args) throws Exception {// TODO Auto-generated method stub // zookeeperIP address and port String zkServerAddress = "127.0.0.1: 2181 "; string schemeless = "schemaless_search"; // E: \ 111 \ schemaless_search \ confFile config = new File ("E:/111/" + schemeless + "/conf"); System. out. println (config. exists (); SolrZkClient client = new SolrZkClient (zkServerAddress, 1000,100 0, new OnReconnect () {@ Overridepublic void command (){}}); zkConfigManager configManager = new ZkConfigManager (client); // default path:/configs cloud Directory:/configs/solrcloud/schemaless_searchconfigManager.uploadConfigDir (Paths. get ("E:/111/" + schemeless + "/conf"), "solrcloud/" + schemeless); client. close (); System. out. println ("end ");}
Make the index take effect:
Public static void main (String [] args) throws Exception {// TODO Auto-generated method stub String collectionName = "schemaless_search "; // the IP address of the solr server CloudSolrClient client = new CloudSolrClient ("172.24.133.13"); CollectionAdminRequest. delete delete = new CollectionAdminRequest. delete (); // If the schemaless_search folder exists, delete it first. setCollectionName (collectionName); CollectionAdminResponse response; try {response = delete. process (client); System. out. println (response);} catch (Exception e) {e. printStackTrace ();} CollectionAdminRequest. create create = new CollectionAdminRequest. create (); create. setCollectionName (collectionName); // directory/configs/solrcloud/schemaless_search find the file and load create. 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 you can see from accessing the solr server.
20:36:22
Solr3.6.1 build an environment in Tomcat6
Tomcat-based Solr3.5 cluster deployment
Load Balancing for Solr clusters using Nginx on Linux
Install and use Solr in Linux
Deploy Solr 4 on Ubuntu 12.04 LTS through Tomcat
Solr implements Low Level query parsing (QParser)
Build a search Server Based on Solr 3.5
Solr 3.5 development and application tutorial PDF
Solr 4.0 deployment instance tutorial
Solr details: click here
Solr: click here
This article permanently updates the link address: