xiaoyu28 发表于 2019-1-8 13:34:45

Fpm 之 Zookeeper

Fpm 之 Zookeeper-3.4.6 rpm 包定制

一、Zookeeper编译包安装

1.下载zookeeper编译安装包
# wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
2.解压到编译包,并指定解压,安装存放的目录
# tar -zxvf zookeeper-3.4.6.tar.gz -C /app/
# mv /app/zookeeper-3.4.6/ /app/zookeeper         #重命名
3.创建data与logs文件夹,存放数据
# mkdir -p /app/zookeeper/data
# mkdir -p /app/zookeeper/logs
4.修改配置文件,指定data与logs的存放位置
# mv /app/zookeeper/conf/zoo_sample.cfg /app/zookeeper/conf/zoo.cfg
# vi 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=/app/zookeeper/data                         #增加项
dataLogDir=/app/zookeeper/logs                  #增加项
# 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
5.创建自启动服务
vi /etc/init.d/zookeeper
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
#export JAVA_HOME=//usr/java/jdk1.8.0_112
case $1 in
start) su root /app/zookeeper/bin/zkServer.sh start;;
stop) su root /app/zookeeper/bin/zkServer.sh stop;;
status) su root /app/zookeeper/bin/zkServer.sh status;;
restart) su /app/zookeeper/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
# chmod +x /etc/init.d/zookeeper
# chkconfig --add zookeeper
# chkconfig zookeeper on
6.测试是否成功
# service zookeeper start
JMX enabled by default
Using config: /app/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
# lsof -i:2181
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    26548 root   22uIPv6 199845      0t0TCP *:eforward (LISTEN)
# service zookeeper stop
JMX enabled by default
Using config: /app/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
二、制作fpm包的运行脚本

# mkdir -p /app/zookeeper/script
# cp /etc/init.d/zookeeper /app/zookeeper/script/
# vi /app/zookeeper/script/server.sh
#!/bin.bash
#制作自启动服务
cp /app/zookeeper/script/zookeeper /etc/init.d/
chmod +x /etc/init.d/zookeeper
chkconfig --add zookeeper
chkconfig zookeeper on
三、定制rpm包

fpm -s dir -t rpm -n zookeeper -v 3.4.6 --post-install /app/zookeeper/script/server.sh -f /app/zookeeper/
四、在客户端安装rpm包

# yum -y localinstall zookeeper-3.4.6-1.x86_64.rpm
# service zookeeper start
JMX enabled by default
Using config: /app/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
# lsof -i:2181
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    10611 root   21uIPv6 271570      0t0TCP *:eforward (LISTEN)
# service zookeeper stop
JMX enabled by default
Using config: /app/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
# ll /app/
total 16
drwxr-xr-x 12 mysql mysql 4096 Jun 13 21:02 mysql
drwxr-xr-x 12 rootroot4096 Jun 13 01:57 nginx-1.12.2
drwxr-xr-x3 rootroot4096 Jun 14 13:39 redis
drwxr-xr-x 13 rootroot4096 Jun 14 15:15 zookeeper


页: [1]
查看完整版本: Fpm 之 Zookeeper