分享到:

关于搭建solrCloud + zookeeper +HDFS的实践经验

关于搭建solrCloud + zookeeper +HDFS的实践经验

 

 

搭建zookeeper

1、        zookeeper官网下载zookeeper(用于管理solrcloud云的配置文件)http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.6/

2、        准备三台服务器,或者搭建3台虚拟机:                                                 例如:host3.com   192.168.2.87    

Host5.com   192.168.2.89

Host4.com   192.168.2.94

3、        上传zookeeper-3.4.6.tar.gz到任意一台服务器/usr/local/目录,并解压到当前目录:zookeeper tar –zxvf zookeeper-3.4.6.tar.gz                            改名:zookeeper-3.4.6 zookeepermv  zookeeper-3.4.6   zookeeper

4、        zookeeper目录下建立data logs目录,同时将zookeeper目录下conf/zoo_simple.cfg文件复制一份成 zoo.cfg

5、        修改zoo.cfg  

# 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 passbetween

# sending a request and getting anacknowledgement

syncLimit=5

# the directory where the snapshot isstored.

# do not use /tmp for storage, /tmp hereis just

# example sakes.

dataDir=/usr/local/zookeeper/data  

# the port at which the clients willconnect

clientPort=2181

# the maximum number of clientconnections.

# increase this if you need to handle moreclients

#maxClientCnxns=60

#

# Be sure to read the maintenance sectionof the

# administrator guide before turning onautopurge.

#

#http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance

#

# The number of snapshots to retain indataDir

#autopurge.snapRetainCount=3

# Purge task interval in hours

# Set to "0" to disable autopurge feature

#autopurge.purgeInterval=1

dataLogDir=/usr/local/zookeeper/logs

server.1=192.168.2.89:2888:3888

server.2=192.168.3.87:2888:3888

server.3=192.168.3.94:2888:3888

 

6、    拷贝zookeeper目录到另外两台服务器:                                                                    

  

scp-r /usr/local/zookeeper root@192.168.2.87:/usr/local/

scp–r /usr/local/zookeeper root@192.168.2.89:/usr/local/

 

分别在几台服务器的data目录下建立myid  ip对应相应的server.*   server.1 myid内容为1  server.2myid内容为server.3myid 3  

7、        启动ZooKeeper集群,在每个节点上分别启动ZooKeeper服务:

8、  可以查看ZooKeeper集群的状态,保证集群启动没有问题:分别查看每台服务器的zookeeper状态 zookeeper#bin/zkServer.shstatus查看那些是following那个是leader

Eg:  

[root@host4zookeeper-3.3.6]# bin/zkServer.sh status

JMXenabled by default

Usingconfig: /home/hadoop/zookeeper-3.3.6/bin/../conf/zoo.cfg

Mode:follower

[root@host5/]# cd /home/hadoop/zookeeper-3.3.6/

[root@host5zookeeper-3.3.6]# bin/zkServer.sh status

JMXenabled by default

Usingconfig: /home/hadoop/zookeeper-3.3.6/bin/../conf/zoo.cfg

Mode:leader

 

[root@host3multicore]# cd /home/hadoop/zookeeper-3.3.6/

[root@host3zookeeper-3.3.6]# bin/zkServer.sh status

JMXenabled by default

Usingconfig: /home/hadoop/zookeeper-3.3.6/bin/../conf/zoo.cfg

Mode:follower

 

建立SolrCloud

1、        Apache官网下载solr安装文件 solr-4.10.1.tgz    http://mirror.bit.edu.cn/apache/lucene/solr/4.10.1/                            并解压tar –xvzf solr-4.10.1.tgz                                                         更改solr-4.10.1目录:mv solr-4.10.1 solr

2、         创建在根目录下创建目录mkdir –p /data0/solrcloud    solr目录移动到data0下,那么data0下包含两个目录{solrsolrcloud}

3、        /data0/solr/example/webapps/solr.war放到tomcatwebapps目录下,启动tomcat,这是tomcat下多出solr目录

4、        /data0/solr/example/lib/ext/下的所有的jar文件复制到tomcat/webapps/solr/WEB-INF/lib/下,建立mkdir –p /data0/solrcloud/{multicoresolr-lib}目录,在将tomcat/webapps/solr/WEB-INF/lib/* 复制一份到solr-lib/ 

cp  /usr/local/tomcat/webapps/solr/WEB-INF/lib/*  /data0/solrcloud/solr-lib/

 

 

 

5、        在建立一个装在配置文件的目录

 

mkdir–p  /data0/solrcloud/multicore/collection/{conf,data}  

 

同时将 /data0/solr/ example/solr/collection1/conf/* 

复制到/data0/solrcloud/multicore/collection/conf目录下

 

example/solr/multicore下的solr.xmlzoo.cfg复制到/data0/solrcloud/multicore目录下 eg

 

 

Collection目录:

 

 Data-config.xml文件是数据导入的配置文件查看:

 

http://blog.csdn.net/john_hongming/article/details/40181451

 

需要自己建立的 solrcore.properties文件

文件内容:

solr.shard.data.dir=/data0/solrcloud/multicore/collection/data

说明:属性solr.shard.data.dirsolrconfig.xml文件中被引用过,指定索引数据的存放位置。

 

Solr.xml文件的说明:

 

 

 

6、        通过zookeeper管理配置文件:

#zookeeper上传配置文件 #

java-classpath .:/data0/solrcloud/solr-lib/* org.apache.solr.cloud.ZkCLI -cmdupconfig -zkhost host3.com:2181,host4.com:2181,host5.com:2181 -confdir/data0/solrcloud/multicore/collection/conf -confname myconf

#zookeeper连接多个节点#

java-classpath .:/data0/solrcloud/solr-lib/* org.apache.solr.cloud.ZkCLI -cmdlinkconfig -collection collection1 -confname myconf -zkhosthost3.com:2181,host4.com:2181,host5.com:2181

 

7、        在启动文件tomcat/bin/Catalina.sh中添加如下配置:

#配置tomcat/bin/catlina.sh下的启动参数#

JAVA_OPTS="-server -Xmx2048m-Xms1024m -verbose:gc  -Xloggc:solr_gc.log -Dsolr.solr.home=/data0/solrcloud/multicore 

-DzkHost=host3.com:2181,host4.com:2181,host5.com:2181"

 

8、        修改tomcat/webapps/solr/WEB-INF/web.xml

context.xml

      




    
    <