Home > Java > javaTutorial > body text

Detailed explanation of solrcloud (jetty container) construction and usage examples

零下一度
Release: 2017-06-27 09:43:15
Original
2351 people have browsed it

1. Preparation work

1. System and software version

System version: centos6.4, zookeeper version: zookeeper-3.4.8, solr version: solr-5.5.3

 2. Install 3 virtual machines

  Virtual machine IP 192.168.17.142, 192.168.17.143, 192.168.17.144

 3. Install jdk

# on each machine ## 4. Create the data directory and upload zookeeper-3.4.8 and solr-5.5.3 to data (this is true for each machine)

  mkdir /data

2. Zookeeper cluster installation

1. Decompress zookeeper

tar -zxvf zookeeper-3.4.8.tar.gz

2. Create data and log directories to store data

mkdir zookeeper-3.4.8/data

mkdir zookeeper-3.4.8/log

3.

Copyzookeeper configuration file zoo_sample.cfg

cp conf/zoo_sample.cfg conf/zoo.cfg

4. Modify the configuration file zoo.cfg

vi conf/zoo.cfg

Add the following content:

         dataDir=/data/zookeeper-3.4.8/data
         dataLogDir=/data/zookeeper-3.4.8/log
	 server.1=192.168.17.142:2888:3888
	 server.2=192.168.17.143:2888:3888
	 server.3=192.168.17.144:2888:3888
Copy after login
5. Create myid under data in zookeeper and write the corresponding number

Note: The myid must correspond. The myid number on the 192.168.17.142 server is 1. The myid number on the 192.168.17.143 server is 2, and the myid number on the 192.168.17.144 server is 3. These numbers can be arbitrary but must be consistent with the numbers in servder.numbers in zoo.cfg.

6. Open the zookeeper port

      /sbin/iptables -I INPUT -p tcp --dport 2181 -j ACCEPT
      /sbin/iptables -I INPUT -p tcp --dport 2888 -j ACCEPT
      /sbin/iptables -I INPUT -p tcp --dport 3888 -j ACCEPT
Copy after login

7. Save the changes and restart the firewall

/etc/rc.d/init.d/iptables save #Save the changes

/etc/init .d/iptables restart #Restart the firewall so that changes can take effect

8. Start the zookeeper cluster

Enter the bin directory in zookeeper

./zkServer.sh start

                       

    ./zkServer.sh status    There may be errors when just starting up. Other nodes in the cluster will be normal after they are put together

    ./zkServer.sh stop    

    ./zkServer.sh restart      

      ./zkCli.sh  Connect to the zookeeper cluster

  9. The result of a successful installation is as follows: One leader 2 followers

   

                

三、Building a solr cluster

  1. Decompress solr

   tar -zxvf solr-5.5.3.tgz

2. Modify the solr.in.sh file under bin

Remove ZK_HOST="192.168.17.142:2181,192.168.17.143:2181,192.168.617.144:2181" Comments on ZK_CLIENT_TIMEOUT

  

 3. Upload mysql and ik Chinese word segmenter to /data/solr-5.5.3/server/solr-webapp/webapp/WEB-INF/lib / Upload the configuration files such as the extended word segmentation of the Chinese word segmenter to /data/solr-5.5.3/server/solr-webapp/webapp/WEB-INF/classes (the classes directory needs to be created by yourself)

 4. Create the solrhome directory (used to store uploaded configuration files) and copy the configuration files

 mkdir /data/solrhome

 mkdir /data/solrhome/myconf

  cp -r / data/solr-5.5.3/example/example-DIH/solr/solr/conf /data/solrhome/myconf

5. Modify solrconfig.xml and managed-schema under conf in myconf. Refer to this. . . . (No explanation here)

6. Upload the configuration file to zookeeper (you can also upload it in /data/solr-.5.3/server/scripts/cloud-scripts/zkcli.sh)

Enter the zookeeper bin

/myconf/conf/ -confname test (upload folder)

-confdir: This refers to the location of the locally uploaded file

-confname: The node name in zookeeper after uploading

   ./zkcli.sh -zkhost 192.168.17.142:2181,192.168.17.143:2181,192.168.617.144:2181 -cmd putfile /configs/test/data-config.xml /data/solrhome/myconf/conf/ data-config.xml (upload a single file)

Parameter Description The first /configs/test/data-config.xml after putfile refers to the configuration file in zookeeper, /data/solrhome/myconf/conf /data-config.xml is the local file path

Note: Before uploading a single file, you must delete it first, otherwise an error will be reported.

7. Zookeeper cluster operates uploaded files

Enter the zookeeper bin

./zkCli.sh Connect to the zookeeper cluster

ls /configs/myconf View the uploaded configuration file

Delete /configs/myconf/solrconfig.xml Delete file

Delete /configs/myconf Delete empty folder

get /configs/myconf/solrconfig .xml View file content

rmr /configs/myconf Recursive deletion (use with caution)

8. Start solr cluster

Enter solr-5.5.3

    ./bin/solr restart 

 9. Operation collection 

 a.Create collection 

   http://192.168.17.142:8983/solr/admin/collections? action=CREATE&name=test&numShards=3&replicationFactor=3&maxShardsPerNode=3&collection.configName=myconf

 b.Delete

   http://192.168.17.142:8983/solr/admin/collections?action=DELETE&name= test

  c.Reload

   http://192.168.17.143:8983/solr/admin/collections?action=RELOAD&name=test

 10. Error handling

  a. An error occurred while creating the kernel. The ip in the error message is 192.168.17.1

Processing: Modify the /data/solr-5.5.3/server/solr/solr.xml file and add ip

Note: In order to reduce errors as much as possible, the configuration file should be tested in Solr on a single node first. After there is no problem, upload it to the zookeeper node

The above is the detailed content of Detailed explanation of solrcloud (jetty container) construction and usage examples. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template