使用外部zookeeper 在tomcat下配置solrcloud

1.zookeeper 配置

    下载zookeeper; 集群安装配置可参考其他网络文章,

     在此我贴出关键信息:

    (1)配置文件内容:

 # 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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=E:/zookeeper-3.4.5/td/zookeeper
# the port at which the clients will connect
clientPort=2181
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=127.0.0.1:2888:3888
server.2=192.168.1.208:2888:3888
server.3=192.168.1.207:2888:3888

在数据文件下创建myid文件,文件内容为1;不同的节点内容不一样,使用server.1后的数字作为myid的文件内容。

2.配置完成后启动三台服务器的zookeeper。

3.上传solr的配置文件到ZooKeeper ensemble中。

solr的配置文件目录可以随意。

(1)上传solr配置文件

   java -classpath d:\lib\*;d:\lib\apache-solr-solrj-4.0.0.jar org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 127.0.0.1:2181,192.168.1.207:2181,192.168.1.208:2181 -confdir   E:\tomcatcluster\collection1\conf -confname testconf

classpath:参数总是报错找不到solrj.jar,干脆把其加入classpath中;lib目录中包含solr.war中的lib包所有内容

 zkhost:zookeeper的服务器地址列表;

confdir:solr的配置文件目录,包含schema,solrconfig等文件;

confname:起个名,下面有用

(2)将上传的配置文件和collection联系起来

  java -classpath d:\lib\*;d:\lib\apache-solr-solrj-4.0.0.jar org.apache.solr.cloud.ZkCLI -cmd linkconfig -collection europe-collection -confname testconf -zkhost 127.0.0.1:2181,192.168.1.207:2181,192.168.1.208:2181

 collection:collection的名字,后面有用,要记住

(3)测试

  配置完成后测试下是否正确;

使用zookeeper下面的工具 zkCli;      zkCli -server localhost:2181

[zk: localhost:2181(CONNECTED) 1] ls /
[configs, collections, zookeeper]
[zk: localhost:2181(CONNECTED) 2] ls /configs
[myconf]
[zk: localhost:2181(CONNECTED) 3] ls /configs/myconf
[admin-extra.menu- top .html, currency.xml, protwords.txt, mapping-FoldToASCII.txt, solrconfig.xml, stopwords.txt, lang, spellings.txt, mapping-ISOLatin1Accent.txt, admin-extra.html, xslt, synonyms.txt, scripts.conf, update-script.js, velocity, elevate.xml, admin-extra.menu-bottom.html, schema.xml]
[zk: localhost:2181(CONNECTED) 4] ls /collections
[europe-collection]
[zk: localhost:2181(CONNECTED) 5]
4.tomcat中配置solrcloud
(1)部署三套tomcat,端口分别用7070,8080,9090;
(2)将solr.war包拷贝到webapps下;
(3)在tomcat\conf\Catalina\localhost 增加配置文件solr.xml,内容类似下面内容:
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="E:\tomcatcluster\tomcat6080\webapps\solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="../solr" override="true"/>
</Context>
(4)在tomcat目录下创建solr目录;并在solr目录中创建文件solr.xml,内容类似下面:
  <?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
  <cores adminPath="/admin/cores" hostPort="7080">
  </cores>
</solr>
上面4步是solr的安装。
 
一直困扰我的问题是zookeeper和tomcat如何交互,原来秘密在这个地方。
打开文件catalina.bat添加类似内容:
set JAVA_OPTS= -Xms512m -Xmx1024m -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Dport=7080 -DhostContext=solr -DzkHost=localhost:2181,192.168.1.207:2181,192.168.1.208:2181
 
这样就基本搞定了,启动3台tomcat。

 

 5 在solrcloud中创建Collection, Shard(s), Replica(s)

  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值