废话很少说,直接开始吧html
先声明一下软件的版本: 我用的是 zookeeper 3.4.5 + solr 5.4.0web
主机环境:apache
三台服务器 浏览器
192.168.15.43bash
192.168.15.44服务器
192.168.15.45ssh
为了之后ssh方便 我修改了 43 的/etc/hosts:ide
192.168.15.43 solr1ui
192.168.15.44 solr2this
192.168.15.45 solr3
复制到服务器上 解压安装
目录: ~/software
software下 installed-package 下存储安装软件包
新建/software/zookeeper-data 文件夹 //zookeeper的数据存储位置
将/soft/ zookeeper-3.4.5/ conf 下的zoo_sample.cfg文件名改成zoo.cfg 并修改zoo.cfg文件以下:
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 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=/root/software/zookeeper-data # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # 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=192.168.15.43:2888:3888 server.2=192.168.15.44:2888:3888 server.3=192.168.15.45:2888:3888
分发到 192.168.15.44 和 192.168.15.45 ~下面
可是发现 software下面的快捷方式消失了, 可是配置没有小时,咱们须要从新 ln -s zookeeper
分别在每台机器的/soft/zookeeper-data 下建立myid文件存储该机器的标识码 好比server.1 的标识码就是 “1” myid文件的内容就一行: 1
三台服务器分别为 1, 2, 3
注: 有问题能够查看 bin下面的 zookeeper.out 文件,这个下面是会有异常报出的。
首先将solr-5.4.0.tar.gz包分别展开到各台服务器的指定目录下,例如:/root/solr-5.4.0
选择一台服务器在/root/下建立solr_home目录,里面用来临时存放自定义的solr配置文件。结构以下:(注:solr4com是用户自定义的索引核心配置,能够从5.4自带的/root/solr-5.4.0/server/solr/configsets/sample_techproducts_configs/中的文件做为基础修改获得)
/root/solr_home/configsets/....
-/solr4com/conf/solrconfig.xml,schema.xml,... (自定义的core)
-/solr.xml,zoo,cfg
须要说明的是:各个自定义模块的solrconfig.xml内容中的如下内容用系统默认的配置。
${solr.data.dir:}
schema.xml与单机版无异。
执行solr配置文件上传到zk命令
选择那台有solr_home配置文件的服务器,进入/root/solr-5.4.0/server/scripts/cloud-scripts下,执行:
./zkcli.sh -cmd upconfig -confdir /root/solr_home/solr4com/conf -confname solr4com -z solr1:2181,solr2:2181,solr3:2181
进入/root/solr-5.4.0/server/scripts/cloud-scripts下,执行:
./zkcli.sh -cmd linkconfig -collection mycollectionname -confname solr4com -z solr1:2181,solr2:2181,solr3:2181
分别进入cloud1,cloud2,cloud3各台solr节点服务器的/root/solr-5.4.0/bin 下,执行:
./solr start -cloud -p 8080 -s "/root/solr-5.4.0/server/solr" -z solr1:2181,solr2:2181,solr3:2181
稍等片刻,就能够经过浏览器访问http://cloud1:8080/solr/ 查看solr的部署状况。这里solr已经将使用Jetty作为默认的web服务器。
在web浏览器地址栏输入:
http://cloud1:8080/solr/admin/collections?action=CREATE&name=col4com&numShards=3&replicationFactor=3&maxShardsPerNode=3&collection.configName=solr4com
其中:col4com 为集合(collection)名,solr4com 为关联的 config名(单机下的core名)
进入solr管理界面便可见到很帅的cloud节点图。