Fpm 之 Zookeeper-3.4.6 rpm 包定制

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Fpm 之 Zookeeper-3.4.6 rpm 包定制相关的知识,希望对你有一定的参考价值。

Fpm 之 Zookeeper-3.4.6 rpm 包定制

一、Zookeeper编译包安装

1.下载zookeeper编译安装包
[[email protected] software]# wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

2.解压到编译包,并指定解压,安装存放的目录
[[email protected] software]# tar -zxvf zookeeper-3.4.6.tar.gz -C /app/
[[email protected] app]# mv /app/zookeeper-3.4.6/ /app/zookeeper         #重命名

3.创建data与logs文件夹,存放数据
[[email protected] app]# mkdir -p /app/zookeeper/data
[[email protected] app]# mkdir -p /app/zookeeper/logs

4.修改配置文件,指定data与logs的存放位置
[[email protected] conf]# mv /app/zookeeper/conf/zoo_sample.cfg /app/zookeeper/conf/zoo.cfg
[[email protected] conf]# 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

[[email protected] conf]# chmod +x /etc/init.d/zookeeper 
[[email protected] conf]# chkconfig --add zookeeper
[[email protected] conf]# chkconfig zookeeper on

6.测试是否成功
[[email protected] conf]# service zookeeper start
JMX enabled by default
Using config: /app/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[[email protected] conf]# lsof -i:2181
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    26548 root   22u  IPv6 199845      0t0  TCP *:eforward (LISTEN)
[[email protected] conf]# service zookeeper stop
JMX enabled by default
Using config: /app/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

二、制作fpm包的运行脚本

[[email protected] zookeeper]# mkdir -p /app/zookeeper/script
[[email protected] zookeeper]# cp /etc/init.d/zookeeper /app/zookeeper/script/
[[email protected] 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包

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

以上是关于Fpm 之 Zookeeper-3.4.6 rpm 包定制的主要内容,如果未能解决你的问题,请参考以下文章

Fpm 之 Redis-5.7.21 rpm 包制

Fpm 之 Mysql-5.7.21 rpm 包制作

Fpm 之 tomcat-7.0.88 rpm 包定制

Fpm 之 Apache2 rpm 包定制

linux系统之定制rpm包

FPM简介(定制rpm包)