解压jkd软件包
tar zxvf jdk-8u5-linux-x64.tar.gz
设置环境变量
vim /etc/profile
最后几行添加:
JAVA_HOME=/home/soft/jdk1.8.0_05
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
设置最大打开文件数:
vim /etc/profile
最后添加
ulimit -n 102400
使配置生效
source /etc/profile
zookeeper环境配置:
解压软件包:
tar zxvf zookeeper-3.4.6.tar.gz
分别创建zookeeper数据文件目录和日志目录
cd zookeeper-3.4.6/
mkdir data
mkdir log
修改配置文件
cd zookeeper-3.4.6/conf
mv zoo_sample.cfg zoo.cfg
cat 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=/home/soft/zookeeper-3.4.6/data
#指定日志文件的路径
dataLogDir=/home/soft/zookeeper-3.4.6/logs
# the port at which the clients will connect
#zookeeper运行端口
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
#zookeeper集群host
server.1=172.18.83.204:2888:3888
server.2=172.18.83.175:2888:3888
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/ ... 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
配置文件详细解释说明:
tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
initLimit:这个配置项是用来配置 Zookeeper 接受客户端(这里所说的客户端不是用户连接 Zookeeper 服务器的客户端,而是 Zookeeper服务器集群中连接到 Leader 的 Follower 服务器)初始化连接时最长能忍受多少个心跳时间间隔数。当已经超过 10 个心跳的时间(也就是tickTime)长度后 Zookeeper 服务器还没有收到客户端的返回信息,那么表明这个客户端连接失败。总的时间长度就是5*2000=10秒。
syncLimit:这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 2*2000=4 秒
dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
dataLogDir: Zookeeper的日志文件位置。
server.A=B:C:D:其中 A 是一个数字,表示这个是第几号服务器;B是这个服务器的 ip 地址;C 表示的是这个服务器与集群中的 Leader服务器交换信息的端口;D 表示的是万一集群中的 Leader 服务器挂了,需要一个端口来重新进行选举,选出一个新的 Leader,而这个端口就是用来执行选举时服务器相互通信的端口。如果是伪集群的配置方式,由于 B 都是一样,所以不同的 Zookeeper 实例通信端口号不能一样,所以要给它们分配不同的端口号。
clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
配置完成后把配置发送到其他两台机子
分别在每台机器的/home/soft/zookeeper-3.4.6/data下创建myid文件存储该机器的标识码 比如server.1 的标识码就是 “1” myid文件的内容就一行: 1
分别在solr1和solr2启动zookeeper
[iyunv@solr1 bin]# pwd
/home/soft/zookeeper-3.4.6/bin
[iyunv@solr1 bin]# sh zkServer.sh start
JMX enabled by default
Using config: /home/soft/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[iyunv@solr2 bin]# sh zkServer.sh start
JMX enabled by default
Using config: /home/soft/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
分别查看solr1和solr上面的zookeeper状态
[iyunv@solr1 bin]# pwd
/home/soft/zookeeper-3.4.6/bin
[iyunv@solr1 bin]# ./zkServer.sh status
JMX enabled by default
Using config: /home/soft/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower
[iyunv@solr2 bin]# ./zkServer.sh status
JMX enabled by default
Using config: /home/soft/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: leader