安装三个node的SolrCloud集群,配置3个zookeeper样例

SolrCloud 服务器: s1.solr.com,s2.solr.com,s3.solr.com
Zookeeper 服务器: z1.com,z2.com,z3.com
默认安装目录 /home/myuser

首先启动zookeeper集群

按照顺序启动 z1.com,z2.com,z3.com

1.从 http://hadoop.apache.org/zookeeper/releases.html 下载zookeeper
2.解压缩zookeeper到zookeeper目录 tar -xf -C /home/myuser/zookeeper/
3.编辑zookeeper配置文件
vi /home/myuser/zookeeper/conf/zoo.cfg and put something similar to
# The number of milliseconds of each tick tickTime=2000

# The number of ticks that the initial synchronization phase can take initLimit=10

# The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5

# the directory where the snapshot is stored. # Choose appropriately for your environment dataDir=/home/myuser/zookeeper/data/

# the port at which the clients will connect clientPort=2181

# the directory where transaction log is stored. # this parameter provides dedicated log device for ZooKeeper dataLogDir=/home/myuser/zookeeper/log/

# ZooKeeper server and its port no. # ZooKeeper ensemble should know about every other machine in the ensemble # specify server id by creating ‘myid’ file in the dataDir # use hostname instead of IP address for convenient maintenance server.1=z1.com:2888:3888 server.2=z2.com:2888:3888 server.3=z3.com:2888:3888

4. 为每个服务器建立一个id文件到data目录,配置合适的id到文件中,例如
vi /home/myuser/zookeeper/data/myid and write just 1 for z1.com in the file. For z2.com server write 2 in its myid and 3 in z3.com myid file. myid file is used to identify the zookeeper server.

启动所有zookeeper服务器

# cd /home/myuser/zookeeper/bin/
# ./zkServer.sh start
安装tomcat

Now once zookeeper cluster is ready lets setup Solr Cloud machines : s1.solr.com,s2.solr.com,s3.solr.com

现在zookeeper集群已经准备好了,我们接下来安装SolrCloud服务器:s1.solr.com,s2.solr.com,s3.solr.com

首先从一台solr服务器上加载配置文件

1.把solr.war放到s1.solr.com服务器
2.拷贝solr.war到solr-war目录
cp solr.war /home/myuser/solr-war
3.cd /home/myuser/solr-war
4.jar xvf solr.war
5.cp WEB-INF/lib/* /home/myuser/solr-war-lib/
6.吧所有配置文件例如solrconfig.xml,schema.xml 等等放到 /home/myuser/solr-config/
7.用solr zookeeper cli(zookeeper客户端)上传配置文件到zookeeper
java -classpath .:/home/myuser/solr-war-lib/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost z1.com:2181,z2.com:2181,z3.com:2181 -confdir /home/myuser/solr-config -confname myconf
8.链接上传的配置和collection(假设新的collection名字叫mycollection)
9.建立一个目录用于存储solr索引 /home/myuser/solr-cores/
10.在solr-cores里面建立solr.xml文件内容如下
<?xml version=”1.0″ encoding=”UTF-8″ ?> <solr persistent=”true” sharedLib=”lib”> <cores adminPath=”/admin/cores” zkClientTimeout=”20000″ hostPort=”8080″ hostContext=”solr”> </cores> </solr>
11.用下面的jvm参数启动tomcat
-DzkHost=z1.com:2181,z2.com:2181,z3.com:2181
12.把solr.war 放到 /home/myuser/tomcat/webapps/ 然后重启tomcat
13.编辑 /home/myuser/tomcat/webapps/solr/META-INF/context.xml 文件并且重启tomcat
<?xml version=”1.0″ encoding=”utf-8″?> <Context docBase=”solr.war” debug=”0″ crossContext=”false”> <Environment name=”solr/home” type=”java.lang.String” value=”/home/myuser/solr-cores” override=”true”/> </Context>
14.curl ‘http://s1.solr.com:8080/solr/admin/collections?action=CREATE&name=mycollection&numShards=3&replicationFactor=1’