-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
zookeeper*.service | ||
|
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,35 @@ | ||
#! /bin/bash | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "usage: start <number of servers>" | ||
exit -1 | ||
fi | ||
|
||
SERVER_COUNT=$1 | ||
|
||
while read -ra line | ||
do | ||
MACHINE=${line[0]} | ||
IP=${line[1]} | ||
IPS+=($IP) | ||
MACHINES+=($MACHINE) | ||
done < <(fleetctl list-machines -l | tail +2 | tail -$SERVER_COUNT) | ||
|
||
ALLIPS=$(IFS=","; echo "${IPS[*]}") | ||
echo $ALLIPS | ||
|
||
INDEX=0 | ||
while [ $INDEX -lt $SERVER_COUNT ] | ||
do | ||
ID=$(($INDEX+1)) | ||
MACHINE=${MACHINES[$INDEX]} | ||
IP=${IPS[$INDEX]} | ||
THISIPS=$(echo $ALLIPS | sed "s/$IP/zookeeper-$ID/") | ||
echo "Setting server $ID as $MACHINE ($IP)" | ||
sed -e "s/#ZK_SERVERS#/$THISIPS/" -e "s/#MACHINE_ID#/$MACHINE/" zookeeper.service.template > zookeeper@$ID.service | ||
let INDEX=INDEX+1 | ||
done | ||
|
||
|
||
|
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 @@ | ||
#! /bin/bash | ||
|
||
for service in *.service | ||
do | ||
echo "Starting $service" | ||
fleetctl start $service | ||
done |
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,8 @@ | ||
#! /bin/bash | ||
|
||
for service in *.service | ||
do | ||
echo "Stopping $service" | ||
fleetctl stop $service | ||
fleetctl destroy $service | ||
done |
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,26 @@ | ||
[Unit] | ||
Description=zookeeper | ||
After=docker.service | ||
Requires=docker.service | ||
|
||
[Service] | ||
TimeoutStartSec=0 | ||
ExecStartPre=-/usr/bin/docker kill nrandell/zookeeper-centos | ||
ExecStartPre=-/usr/bin/docker rm nrandell/zookeeper-centos | ||
ExecStartPre=/usr/bin/docker pull nrandell/zookeeper-centos | ||
ExecStart=/usr/bin/docker run \ | ||
--rm \ | ||
--name zookeeper-%i \ | ||
--env ZK_SERVER_NUMBER=%i \ | ||
--hostname zookeeper-%i \ | ||
--env ZK_SERVERS=#ZK_SERVERS# \ | ||
--publish 2181:2181 \ | ||
--publish 2888:2888 \ | ||
--publish 3888:3888 \ | ||
--volume /var/zookeeper:/data \ | ||
nrandell/zookeeper-centos | ||
|
||
ExecStop=/usr/bin/docker stop zookeeper-%i | ||
|
||
[X-Fleet] | ||
MachineID=#MACHINE_ID# |