1 搭建Solr集群(SolrCloud)
1.1 Zookeeper介绍
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务、node管理等。
Zookeeper实现了高性能,高可靠性,和有序的访问。高性能保证了zookeeper能应用在大型的分布式系统上。高可靠性保证它不会由于单一节点的故障而造成任何问题。
你运行一个zookeeper也是可以的,但是在生产环境中,你最好部署3,5,7个节点。部署的越多,可靠性就越高,当然最好是部署奇数个,偶数个不是不可以的,但是zookeeper集群是以宕机个数过半才会让整个集群宕机的(选举机制),所以奇数个集群更佳。
1.2 介绍搭建环境
资料\solr资料
1.3 搭建zookeeper集群
1.3.1 软件上传
略
1.3.2 创建zookeeper-cluster目录
在/usr/local/src/下创建zookeeper-cluster目录
1.3.3 解压zookeeper到该目录下
1.3.4 修改zookeeper名称
修改解压后的目录名称zookeeper-3.4.6位zookeeper01
1.3.5 在zookeeper01下创建data、logs目录
在zookeeper01下创建
1、 data目录(存放配置的服务或者节点等)
2、 logs目录(存放日志)
1.3.6 修改conf目录下的文件名称
进入conf目录下,将zoo_sample.cfg文件修改为zoo.cfg文件。
1.3.7 修改zoo.cfg文件
1、 指定data目录
2、 指定logs目录
3、 指定zookeeper的节点编号
说明:2888端口用于zookeeper集群间数据同步传输,3888端口用于zookeeper的选举机制
# 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=/tmp/zookeeper # 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 dataDir=/usr/local/src/zookeeper/zookeeper01/data dataLogDir=/usr/local/src/zookeeper/zookeeper01/logs server.1=192.168.200.128:2888:3888 server.2=192.168.200.128:4888:5888 server.3=192.168.200.128:6888:7888 |
1.3.8 在data目录下创建myid文件
1.3.9 修改myid
指定该zookeeper是第几个节点
echo 1 > myid
查看文件中的值命令:
more myid
1.3.10 copy zookeeper02
修改:
1、 修改zoo.cfg文件