Commit 12ef3867 authored by Georgios Ouzounis's avatar Georgios Ouzounis
Browse files

LAM-49 Created Apache Zookeeper and Kafka init scripts.

parent 1517c353
...@@ -8,3 +8,6 @@ ...@@ -8,3 +8,6 @@
- name: Create softlink for Apache Kafka. - name: Create softlink for Apache Kafka.
file: src="{{ installation_path }}/kafka_{{ scala_version }}-{{ version }}" dest="{{ installation_path }}/kafka" state=link file: src="{{ installation_path }}/kafka_{{ scala_version }}-{{ version }}" dest="{{ installation_path }}/kafka" state=link
- name: Copy Apache Kafka init script.
template: src=kafka-init.j2 dest=/etc/init.d/kafka-init owner=root group=root mode=0755
--- ---
- name: Download and install Apache kafka. - name: Install Apache kafka.
include: download.yml include: install.yml
tags:
- download - name: Copy Apache Zookeeper init script.
template: src=zookeeper-init.j2 dest=/etc/init.d/zookeeper-init owner=root group=root mode=0755
- name: Configure Apache kafka. - name: Configure Apache kafka.
copy: src=server.properties dest="{{ installation_path }}/kafka/config/server.properties" owner=root group=root mode=0644 copy: src=server.properties dest="{{ installation_path }}/kafka/config/server.properties" owner=root group=root mode=0644
...@@ -10,9 +11,7 @@ ...@@ -10,9 +11,7 @@
- configure-kafka - configure-kafka
- name: Start Apache Zookeeper server. - name: Start Apache Zookeeper server.
shell: "{{ installation_path }}/kafka/bin/zookeeper-server-start.sh {{ installation_path }}/kafka/config/zookeeper.properties" shell: /etc/init.d/zookeeper-init start # Should use ansible module service: name=zookeeper-init state=started when the bug in version 1.9.1 is fixed.
async: 31536000 # Stay alive for a year(1 year = 31536000 seconds).
poll: 0
tags: tags:
- start-zookeeper - start-zookeeper
...@@ -22,9 +21,7 @@ ...@@ -22,9 +21,7 @@
- start-zookeeper - start-zookeeper
- name: Start Apache Kafka server. - name: Start Apache Kafka server.
shell: "{{ installation_path }}/kafka/bin/kafka-server-start.sh {{ installation_path }}/kafka/config/server.properties" shell: /etc/init.d/kafka-init start # Should use ansible module service: name=zookeeper-init state=started when the bug in version 1.9.1 is fixed.
async: 31536000 # Stay alive for a year(1 year = 31536000 seconds).
poll: 0
tags: tags:
- start-kafka - start-kafka
......
--- ---
- name: Download and install Apache kafka. - name: Install Apache kafka.
include: download.yml include: install.yml
tags:
- download
- name: Configure Apache kafka. - name: Configure Apache kafka.
template: src=server.properties.j2 dest="{{ installation_path }}/kafka/config/server.properties" owner=root group=root mode=0644 template: src=server.properties.j2 dest="{{ installation_path }}/kafka/config/server.properties" owner=root group=root mode=0644
...@@ -10,9 +8,7 @@ ...@@ -10,9 +8,7 @@
- configure-kafka - configure-kafka
- name: Start Apache Kafka server. - name: Start Apache Kafka server.
shell: "{{ installation_path }}/kafka/bin/kafka-server-start.sh {{ installation_path }}/kafka/config/server.properties" shell: /etc/init.d/kafka-init start # Should use ansible module service: name=zookeeper-init state=started when the bug in version 1.9.1 is fixed.
async: 31536000 # Stay alive for a year(1 year = 31536000 seconds).
poll: 0
tags: tags:
- start-kafka - start-kafka
......
#!/bin/bash
# The path where Apache Kafka is installed.
INSTALLATION_PATH="{{ installation_path }}"
# The full path of the pid file to use.
PIDFILE="{{ installation_path }}/kafka/kafka.pid"
# The full path of the lock file to use.
LOCKFILE="{{ installation_path }}/kafka/kafka-lock"
# The command that will start Apache Kafka.
START_COMMAND="$INSTALLATION_PATH/kafka/bin/kafka-server-start.sh $INSTALLATION_PATH/kafka/config/server.properties"
start(){
touch $PIDFILE
nohup $START_COMMAND & echo $! > $PIDFILE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
stop(){
kill -s 9 $(cat $PIDFILE)
RETVAL=$?
[ $RETVAL -eq 0 ] && $(rm -f $LOCKFILE)
return $RETVAL
}
restart(){
stop
start
}
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f $LOCKFILE ] && restart || :
;;
status)
ps -p $(cat $PIDFILE)
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
#!/bin/bash
# The path where Apache Zookeeper is installed.
INSTALLATION_PATH="{{ installation_path }}"
# The full path of the pid file to use.
PIDFILE="{{ installation_path }}/kafka/zookeeper.pid"
# The full path of the lock file to use.
LOCKFILE="{{ installation_path }}/kafka/zookeeper-lock"
# The command that will start Apache Zookeeper.
START_COMMAND="$INSTALLATION_PATH/kafka/bin/zookeeper-server-start.sh $INSTALLATION_PATH/kafka/config/zookeeper.properties"
start(){
touch $PIDFILE
nohup $START_COMMAND & echo $! > $PIDFILE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
stop(){
kill -s 9 $(cat $PIDFILE)
RETVAL=$?
[ $RETVAL -eq 0 ] && $(rm -f $LOCKFILE)
return $RETVAL
}
restart(){
stop
start
}
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f $LOCKFILE ] && restart || :
;;
status)
ps -p $(cat $PIDFILE)
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment