-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Makefile for building RPM files for Centos
- Loading branch information
Showing
9 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM centos:6 | ||
MAINTAINER Junegunn Choi <[email protected]> | ||
|
||
RUN yum clean all && yum install -y rpm-build rpmdevtools createrepo | ||
|
||
WORKDIR /root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM centos:7 | ||
MAINTAINER Junegunn Choi <[email protected]> | ||
|
||
RUN yum clean all && yum install -y rpm-build rpmdevtools createrepo | ||
|
||
WORKDIR /root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
NAME := hbase-packet-inspector | ||
VERSION := 0.2.0 | ||
UBERJAR := target/$(NAME)-$(VERSION).jar | ||
|
||
RPM6 := rpmbuild/RPMS/x86_64/$(NAME)-$(VERSION)-1.el6.x86_64.rpm | ||
RPM7 := rpmbuild/RPMS/x86_64/$(NAME)-$(VERSION)-1.el7.centos.x86_64.rpm | ||
|
||
TARBALL := rpmbuild/SOURCES/$(NAME)-$(VERSION).tar.gz | ||
|
||
build: $(UBERJAR) | ||
|
||
$(UBERJAR): $(shell find src/ -name "*.clj") | ||
lein uberjar | ||
|
||
$(TARBALL): $(UBERJAR) | ||
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SRPMS} | ||
mkdir -p rpmbuild/SOURCES/$(NAME)/lib | ||
cp -f $(UBERJAR) rpmbuild/SOURCES/$(NAME)/lib/$(NAME).jar | ||
cd rpmbuild/SOURCES && tar -cvzf $(NAME)-$(VERSION).tar.gz $(NAME) | ||
|
||
$(RPM6): $(TARBALL) | ||
make centos6 | ||
docker run -v $(CURDIR)/rpmbuild:/root/rpmbuild -t hpi-centos6 rpmbuild -ba rpmbuild/SPECS/hbase-packet-inspector.spec | ||
|
||
$(RPM7): $(TARBALL) | ||
make centos7 | ||
docker run -v $(CURDIR)/rpmbuild:/root/rpmbuild -t hpi-centos7 rpmbuild -ba rpmbuild/SPECS/hbase-packet-inspector.spec | ||
|
||
rpm6: $(RPM6) | ||
rpm7: $(RPM7) | ||
rpm: $(RPM6) $(RPM7) | ||
|
||
yum: | ||
rm -rf yum | ||
mkdir -p yum/{6,7} | ||
cp -f rpmbuild/RPMS/x86_64/hbase-packet-inspector-0.2.0-1.el6.x86_64.rpm yum/6 | ||
cp -f rpmbuild/RPMS/x86_64/hbase-packet-inspector-0.2.0-1.el7.centos.x86_64.rpm yum/7 | ||
docker run -v $(CURDIR)/rpmbuild:/root/rpmbuild -v $(CURDIR)/yum:/root/yum -it hpi-centos6 createrepo /root/yum/6 | ||
docker run -v $(CURDIR)/rpmbuild:/root/rpmbuild -v $(CURDIR)/yum:/root/yum -it hpi-centos7 createrepo /root/yum/7 | ||
|
||
yum-server: | ||
cd yum && python -m SimpleHTTPServer 8080 | ||
|
||
%: Dockerfile.% | ||
docker build -t hpi-$@ - < Dockerfile.$@ | ||
# docker run -v $(CURDIR)/rpmbuild:/root/rpmbuild -it hpi-$@ | ||
|
||
clean: | ||
rm -rf rpmbuild/{BUILD,BUILDROOT,RPMS,SRPMS} \ | ||
rpmbuild/SOURCES/$(NAME)-$(VERSION).tar.gz \ | ||
rpmbuild/SOURCES/$(NAME)/lib yum | ||
|
||
.PHONY: all build rpm rpm6 rpm7 yum yum-server clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
rpmbuild/SOURCES/hbase-packet-inspector/conf/hbase-packet-inspector.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# kafka = bootstrap1:9092,bootstrap2:9092/hbase-traffic | ||
device = eth0 |
7 changes: 7 additions & 0 deletions
7
rpmbuild/SOURCES/hbase-packet-inspector/conf/log4j.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
log4j.rootLogger=INFO, FILE | ||
log4j.appender.FILE=org.apache.log4j.RollingFileAppender | ||
log4j.appender.FILE.File=/var/log/hbase-packet-inspector.log | ||
log4j.appender.FILE.MaxFileSize=256MB | ||
log4j.appender.FILE.MaxBackupIndex=10 | ||
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.FILE.layout.ConversionPattern=%d %-5p: %m%n |
124 changes: 124 additions & 0 deletions
124
rpmbuild/SOURCES/hbase-packet-inspector/init.d/hbase-packet-inspector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
#!/bin/bash | ||
# Starts hbase-packet-inspector daemon | ||
# | ||
# chkconfig: 345 90 10 | ||
# description: hbase-packet-inspector daemon | ||
# | ||
### BEGIN INIT INFO | ||
# Provides: hbase-packet-inspector | ||
# Required-Stop: $local_fs $network | ||
# Required-Start: $local_fs $network | ||
# Default-Start: 3 4 5 | ||
# Default-Stop: 0 1 2 6 | ||
# Short-Description: start and stop hbase-packet-inspector daemon | ||
# Description: Monitors HBase packets and sends them to Kafka | ||
### END INIT INFO | ||
|
||
# Sample in /usr/share/doc/initscripts-*/sysvinitfiles | ||
|
||
. /etc/rc.d/init.d/functions | ||
|
||
# 0 - success | ||
# 1 - generic or unspecified error | ||
# 2 - invalid or excess argument(s) | ||
# 3 - unimplemented feature (e.g. "reload") | ||
# 4 - insufficient privilege | ||
# 5 - program is not installed | ||
# 6 - program is not configured | ||
# 7 - program is not running | ||
|
||
[ $EUID = 0 ] || exit 4 | ||
|
||
prog=hbase-packet-inspector | ||
proghome=/usr/lib/$prog | ||
jar=$proghome/lib/$prog.jar | ||
conf=$proghome/conf/$prog.properties | ||
logconf=$proghome/conf/log4j.properties | ||
|
||
[ -f "$jar" ] || exit 5 | ||
|
||
check_file() { | ||
local f | ||
for f in "$@"; do | ||
if [ ! -f "$f" ]; then | ||
echo "$f is not found" | ||
exit 6 | ||
fi | ||
done | ||
} | ||
|
||
check_file "$conf" "$logconf" | ||
|
||
getval() { | ||
local val | ||
val=$(grep -Po "^ *$1 *= *\K[^#]*" < "$conf" | tail -1) | ||
if [ -z "$val" ]; then | ||
echo "$1 not found in $conf" | ||
return 1 | ||
fi | ||
echo "$val" | ||
} | ||
|
||
get_cluster() { | ||
if [ -f /etc/hadoop/conf/core-site.xml ]; then | ||
local cluster | ||
cluster=$(sed -n '/fs.defaultFS/ {n; s|.*://||; s|<.*||; p}' /etc/hadoop/conf/core-site.xml) | ||
[ -n "$cluster" ] && echo "?cluster=$cluster" | ||
fi | ||
} | ||
|
||
kafka=$(getval kafka) || exit 6 | ||
[[ "$kafka" =~ '?' ]] || kafka=$kafka$(get_cluster) | ||
device=$(getval device) || exit 6 | ||
options="--interface $device --kafka $kafka" | ||
cmd="java -Xmx2g -Dlog4j.configuration=file:$logconf -jar $jar $options" | ||
|
||
pidfile=/var/run/$prog.pid | ||
|
||
start() { | ||
status "$prog" && exit 1 | ||
|
||
echo -n "Starting $prog: " | ||
java -jar "$jar" --help > /dev/null || exit 1 | ||
daemon --check "$prog" "nohup $cmd < /dev/null > /dev/null 2>&1 & echo \$! > $pidfile" | ||
ret=$? | ||
touch /var/lock/subsys/$prog | ||
echo | ||
return $ret | ||
} | ||
|
||
stop() { | ||
echo -n "Shutting down $prog: " | ||
killproc "$prog" | ||
ret=$? | ||
rm -f /var/lock/subsys/$prog | ||
echo | ||
return $ret | ||
} | ||
|
||
case "$1" in | ||
start) | ||
start | ||
;; | ||
stop) | ||
stop | ||
;; | ||
restart|reload) | ||
stop | ||
start | ||
;; | ||
condrestart) | ||
if [ -f /var/lock/subsys/$prog ]; then | ||
stop | ||
start | ||
fi | ||
;; | ||
status) | ||
status "$prog" | ||
;; | ||
*) | ||
echo "Usage: $0 {start|stop|status|reload|restart|condrestart}" | ||
exit 2 | ||
esac | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Name: hbase-packet-inspector | ||
Version: 0.2.0 | ||
Release: 1%{?dist} | ||
Summary: hbase-packet-inspector monitors HBase packets | ||
|
||
Group: Development/Tools | ||
License: Apache 2 | ||
URL: https://github.com/kakao/hbase-packet-inspector | ||
Source0: %{name}-%{version}.tar.gz | ||
|
||
Requires: libpcap >= 1.4.0 | ||
|
||
%define __jar_repack 0 | ||
|
||
%description | ||
hbase-packet-inspector is a command-line tool for analyzing network traffic of | ||
HBase RegionServers. | ||
|
||
|
||
%prep | ||
# Without -n, it expects %{name}-%{version} after extracting the tarball | ||
|
||
%setup -q -n %{name} | ||
|
||
%build | ||
# Nothing to do | ||
|
||
|
||
%install | ||
install -m 0755 -d %{buildroot}/etc/init.d | ||
install -m 0755 -d %{buildroot}/usr/lib/%{name} | ||
install -m 0755 -d %{buildroot}/usr/lib/%{name}/lib | ||
install -m 0755 -d %{buildroot}/usr/lib/%{name}/conf | ||
install -m 0755 lib/%{name}.jar %{buildroot}/usr/lib/%{name}/lib/%{name}.jar | ||
install -m 0755 init.d/%{name} %{buildroot}/etc/init.d/%{name} | ||
install -m 0644 conf/log4j.properties %{buildroot}/usr/lib/%{name}/conf/log4j.properties | ||
install -m 0644 conf/%{name}.properties %{buildroot}/usr/lib/%{name}/conf/%{name}.properties | ||
|
||
|
||
%files | ||
/etc/init.d/hbase-packet-inspector | ||
%dir /usr/lib/%{name} | ||
%dir /usr/lib/%{name}/lib | ||
/usr/lib/%{name}/lib/%{name}.jar | ||
%dir /usr/lib/%{name}/conf | ||
/usr/lib/%{name}/conf/log4j.properties | ||
/usr/lib/%{name}/conf/%{name}.properties |