In combination with the previous experience of building projects and configuring security controls, the construction process should be as follows:
1. Build Zookeeper cluster
2. Configuring the jetty Boot configuration for SOLR
3. Add ZK ACL configuration information to the SOLR boot configuration
4. Using the SOLR configuration, start the Solrcloud cluster and give the cluster to zookeeper management
5. Upload the relevant configuration file, create the collection
6. Upload the Security configuration file
7. Log in to the admin interface to see the status of the cluster and access the files on the zookeeper
8. Add data to Solrcloud
9. Configure the client, use SOLRJ to operate the Solrcloud (groping stage)
================================================================
1. Configure the Zookeeper cluster 1.1 to upload the compressed package into the LIUNX, after decompression into the root directory compressed package address:Links:Http://pan.baidu.com/s/1geOTZeNPassword: 5bh8Create a Data foldermkdir Dataenter data.CD DataVim myIDInput 1Enter the Conf directoryMVzoo_sample.cfg zoo.cfg Edit Zoo.cfg content modified as follows I only use two nodes here, according to the official recommendation should use 2n+1 more good empathy after configuring another node: Start zookeeper zookeeper/bin/zkserver.sh start two nodes are started to view the cluster status zookeeper/bin/zkserver.sh status
I use only two nodes here, according to the official recommendation should use 2n+1 more good empathy after configuring another node: Start zookeeper zookeeper/bin/zkserver.sh start two nodes are started after the view cluster status zookeeper/bin/ zkserver.sh status
================
2. Configure the jetty startup file. 2.1 First upload the solr5.5 project to Liunx, Unzip: File address: Link: http://pan.baidu.com/s/1eRQrVfs password: rzvu2.2 Upload the boot configuration information I provided to the LIUNX Link:/http PAN.BAIDU.COM/S/1NVHE9HV Password: YEF8 General Catalogue after the following
2.3 Modify the configuration information in solr_8001 to match your own (a solr.xml file is missing from the data directory cp/root/solr/solr/server/solr/solr.xml/root/solr/solr_8001/ data/find a similar directory to copy the past can be)
Vim solr.in.sh I modified post configuration information as follows
After modifying the Solr.shvim under the bin bin/solr.sh I modified it as follows
Copy the modified file to another node: SCP-----------=================
3. Add ZK ACL configuration information to the SOLR boot configuration
3.1 Add the following to the Solr.xml in Solr_8001/data
3.2 Add the following at the bottom of the solr_8001/solr.in.sh:
Here is a permission to set an operation Zookeeper user admin password is also admin
================
4. upload the relevant configuration file and create a collection (using a custom method) 4.1 Upload config file, this is the script that I write the configuration file, can refer to
4.2 Custom Collection mode, create a collection cd/root/solr/solr_8001/data The Shard Library's folder mkdir Gome_suggest edit the information for the Shard vim core.properties
Another node only need to talk about core_node1 into Core_node2 can be said here again, the port can be adjusted to start, just need to correct the solr.in.sh in the port information can be
==========================
5. using the SOLR configuration, start the Solrcloud cluster and give the cluster to zookeeper management
Normal start of SOLR server (two nodes)/root/solr/solr_8001/bin/solr.sh start---> failed for what reason---> Try using the API to set up the following first close SOLR cluster and zookeeper cluster to clean up the data before opening the zookeeper cluster and Solrcloud cluster trying to set up the collection using the HTTP API http://192.168.119.20:8001/ solr/admin/collections?action=create&name=meixin_suggest&numshards=1&replicationfactor=2& Collection.configname=meixin_suggest Delete Collection:http://192.168.119.20:8001/solr/admin/collections?action=delete& Name=meixin_suggest
===================
6. Upload the security profile (save the original and upload it again)
Use the following script to upload a secure file: Java-classpath./:/root/solr/solr/server/solr-webapp/webapp/web-inf/lib/*-dzkdigestusername= Admin-dzkdigestpassword=admin-dzkaclprovider= Org.apache.solr.common.cloud.vmparamsallandreadonlydigestzkaclprovider-dzkcredentialsprovider= Org.apache.solr.common.cloud.VMParamsSingleSetCredentialsDigestZkCredentialsProvider Org.apache.solr.cloud.zkcli-zkhost 192.168.119.20:2181,192.168.119.21:2181-cmd Put/security.json ' {" Authentication ": {" Class ": SOLR. Basicauthplugin "," Blockunknown ": True," credentials ": {"root": "V1kx29vsv2jhda4iy+rqpnphscww29rh1z6rzi/6lvi= tl5dtovbr1eraw8u1hyo5jluy8bmqkeqj573pglyndw= "}}," Authorization ": {" Class ":" Solr. " Rulebasedauthorizationplugin "}}'The account set is the root password for songqinghu=============
7. Set permissions for the security configuration file
----> has just started to configure ZK's access control, the default is to create a security profile and files created with SOLR are privileged
============
8. Log in to the admin interface to see the status of the cluster and access the files on the zookeeperThe contents of the files on ZK can be accessed to prove that SOLR is authorized to manipulate ZK.
9. Add Data to SolrcloudAdd two data to the database to prove that it can be manipulated by the node to be tested later
10. Configure the client, use SOLRJ to operate the Solrcloud (groping stage)
Official information:
Attempt to connect directly: caused by: org.apache.zookeeper.keeperexception$noauthexception: keepererrorcode = NoAuth for /clusterstate.json at Org.apache.zookeeper.KeeperException.create (keeperexception.java:113) at Org.apache.zookeeper.KeeperException.create (keeperexception.java:51) at Org.apache.zookeeper.ZooKeeper.getData (zookeeper.java:1155) at Org.apache.solr.common.cloud.solrzkclient$7.execute (solrzkclient.java:345) at Org.apache.solr.common.cloud.solrzkclient$7.execute (solrzkclient.java:342) at Org.apache.solr.common.cloud.ZkCmdExecutor.retryOperation (zkcmdexecutor.java:60) at org.apache.solr.common.cloud.solrzkclient.getdata (solrzkclient.java:342) at Org.apache.solr.common.cloud.ZkStateReader.refreshLegacyClusterState (zkstatereader.java:443) &Nbsp; at org.apache.solr.common.cloud.zkstatereader.createclusterstatewatchersandupdate ( zkstatereader.java:296) at Org.apache.solr.client.solrj.impl.CloudSolrClient.connect (cloudsolrclient.java:467) 2 more
can be found to have no permissions, we mimic the parameter settings in the script, add related data to the system's properties properties p = new properties (); p.setproperty ("Zkdigestusername", "admin"); p.setproperty ("Zkdigestpassword", "admin"); p.setproperty ( "Zkcredentialsprovider", " Org.apache.solr.common.cloud.VMParamsSingleSetCredentialsDigestZkCredentialsProvider "); p.setproperty ("Zkaclprovider", " Org.apache.solr.common.cloud.VMParamsAllAndReadonlyDigestZkACLProvider "); system.setproperties (P); // system.out.println ( System.getproperty ("Zkdigestusername")); string zkurl = "192.168.119.20:2181,192.168.119.21:2181"; // esystemdefaulthttpclient httpclient = New esystemdefaulthttpclient (200, 2000); Cloudsolrclient cloudsolrclient = new cloudsolrclient (ZKURL); cloudsolrclient.setdefaultcollection ("Meixin_suggest"); cloudsolrclient.connect (); solrquery q = new solrquery (); q.set ("Q", "*:*"); queryrequest req = new Queryrequest (q); req.setbasicauthcredentials ("Root", " Songqinghu "); queryresponse response = Req.process (cloudsolrclient); long numfound = Response.getresults (). Getnumfound (); &nBsp; system.out.println ("THE&NBSP;QUERY&NBSP;NUMFOUND&NBSP;IS&NBSP;:" + numFound); cloudsolrclient.close (); Run again error: Xception in thread "Main" java.lang.ExceptionInInitializerError at Org.apache.solr.common.cloud.ZkClientConnectionStrategy.createSolrZooKeeper (Zkclientconnectionstrategy.java : 103) at org.apache.solr.common.cloud.defaultconnectionstrategy.connect ( defaultconnectionstrategy.java:37) at org.apache.solr.common.cloud.solrzkclient. <init> (solrzkclient.java:144) at org.apache.solr.common.cloud.solrzkclient. <init> (solrzkclient.java:115) at org.apache.solr.common.cloud.solrzkclient. <init> (solrzkclient.java:105) at org.apache.solr.common.cloud.zkstatereader. <init> (zkstatereader.java:201) at org.apache.solr.client.solrj.impl.cloudsolrclient.connect (cloudsolrclient.java:466) at com.git.solr.auth.solrjauthclient.client (solrjauthclient.java:45) At com.git.solr.auth.solrjauthclient.main (solrjauthclient.java:21) caused by: Java.lang.nullpointerexception at sun.nio.cs.ext.extendedcharsets.init ( extendedcharsets.java:1300) at sun.nio.cs.abstractcharsetprovider.charsetforname ( abstractcharsetprovider.java:160) at Java.nio.charset.Charset.lookupExtendedCharset (charset.java:455) at Java.nio.charset.Charset.lookup2 (charset.java:480) at Java.nio.charset.Charset.lookup (charset.java:468) at Java.nio.charset.Charset.isSupported (charset.java:510) at Java.lang.StringCoding.lookupCharset (stringcoding.java:99) &NBSP;&NBSP;&NBsp; at java.lang.stringcoding.decode (stringcoding.java:185) at Java.lang.string.<init> (string.java:416) at java.lang.String.<init> ( string.java:481) at java.net.inet6addressimpl.getlocalhostname (Native Method) at java.net.inetaddress.getlocalhost (inetaddress.java:1444) at org.apache.zookeeper.environment.list (environment.java:61) at ORG.APACHE.ZOOKEEPER.ENVIRONMENT.LOGENV (environment.java:98) at Org.apache.zookeeper.zookeeper.<clinit> (zookeeper.java:95) ... 9 more
Can be found to create Solrclientzookeeper error: How should we solve this problem?
The connection node should be similar to the SOLR server to connect ZK, to operate, since SOLR can connect, then I should be no problem hereFollow the SOLR server to connect ZK, to operate. Build a service, set the system variables to the server, run the project directly on the server after a day of experimentation, it is found that the parameters do need to be configured to the server.
The configuration file is as follows (Window System) Catalina.bat in Tomcat
The Java code used is as follows:
Package Com.mx.solr.zk.client.servlet.utils;import Org.apache.solr.client.solrj.solrclient;import Org.apache.solr.client.solrj.impl.cloudsolrclient;public class Solrclientuitls { private static solrclient client = null; public static Solrclient Getclient () { if (client ==null) { String Zkurl = " 192.168.119.20:2181,192.168.119.21:2181 "; Cloudsolrclient cloudsolrclient = new cloudsolrclient (zkurl); Cloudsolrclient.setdefaultcollection ("Meixin_suggest"); Cloudsolrclient.connect (); client = cloudsolrclient; } return client;} }
Package Com.mx.solr.zk.client.servlet;import Java.io.ioexception;import Java.util.properties;import Javax.servlet.servletexception;import Javax.servlet.annotation.webservlet;import Javax.servlet.http.HttpServlet; Import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletresponse;import Org.apache.solr.client.solrj.solrclient;import Org.apache.solr.client.solrj.solrquery;import Org.apache.solr.client.solrj.solrserverexception;import org.apache.solr.client.solrj.impl.CloudSolrClient; Import Org.apache.solr.client.solrj.request.queryrequest;import Org.apache.solr.client.solrj.response.queryresponse;import Org.apache.solr.common.solrdocument;import Org.apache.solr.common.solrdocumentlist;import com.mx.solr.zk.client.servlet.utils.solrclientuitls;/** * servlet Implementation class Clientservlet */@WebServlet ("/clientservlet") public class Clientservlet extends HttpServlet {priv Ate static final long serialversionuid = 1L; /** * @see Httpservlet#httpservlet () */Public Clientservlet () {super (); } protected void Doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { Solrclient client = Solrclientuitls.getclient (); Solrquery q = new Solrquery (); Q.set ("Q", "*:*"); Queryrequest req = new Queryrequest (q); Req.setbasicauthcredentials ("root", "Songqinghu"); Queryresponse Res; try {res = req.process (client); Long Numfound = Res.getresults (). Getnumfound (); SYSTEM.OUT.PRINTLN ("The Query Numfound is:" + numfound); Solrdocumentlist docs = Res.getresults (); for (Solrdocument Doc:docs) {System.out.println ("Suggestid:" +doc.getfieldvalue ("Suggestid"). Tostrin g ()); System.out.println ("Word:" +doc.getfieldvalue ("word"). toString ()); }} catch (Solrserverexception e) { E.printstacktrace (); }//Cloudsolrclient.close (); } protected void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {doget (request, response); }}
The results of the operation are as follows:
If you start with Maven, you only need to set the variable in the location:
So far, a security control function of the Solrcloud set is completed, of course, you may encounter many problems in the construction process, if you need to discuss together, please Garber the main QQ group.
488252920
Get started with SOLR build Solrcloud clusters with security controls and rights management capabilities