Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sgykfjsm/8326115 to your computer and use it in GitHub Desktop.
Save sgykfjsm/8326115 to your computer and use it in GitHub Desktop.
Zookeeperのインストールと、mesosおよびZookeeperの設定ファイルの配布をいっぺんに行うスクリプト
#!/bin/bash
# mesos setting
user=`whoami`
slaves=(slave1 slave2)
mesos_config_dir=/etc/default
mesos_config_files=(${mesos_config_dir}/mesos \
${mesos_config_dir}/mesos-master \
${mesos_config_dir}/mesos-slave \
/usr/local/var/mesos/deploy/slave.lst \
)
for slave in ${slaves[@]}
do
for mesos_config_file in ${mesos_config_files[@]}
do
scp ${mesos_config_file} ${user}@${slave}:/tmp/`basename ${mesos_config_file}`
ssh ${user}@${slave} " \
sudo cp /tmp/`basename ${mesos_config_file}` ${mesos_config_file}; \
"
done
done
echo
echo `date` end distribute mesos config files.
deb_url=http://archive.cloudera.com/cdh4/one-click-install/precise/amd64/cdh4-repository_1.0_all.deb
deb_file=`basename ${deb_url}`
archive_key=http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/archive.key
zoo_cfg=/etc/zookeeper/conf/zoo.cfg
echo `date` start install zookeeper.
for slave in ${slaves[@]}
do
case ${slave} in
slave1) myid=2 ;;
slave2) myid=3 ;;
* ) continue ;;
esac
scp ${zoo_cfg} ${user}@${slave}:/tmp/`basename ${zoo_cfg}`
ssh ${user}@${slave} " \
wget -q -O /tmp/${deb_file} ${deb_url}; \
sudo dpkg -i /tmp/${deb_file}; \
curl -s ${archive_key} | sudo apt-key add -; \
sudo apt-get -fy update; \
sudo apt-get -y install zookeeper zookeeper-server; \
sudo cp /tmp/`basename ${zoo_cfg}` `${zoo_cfg}`; \
sudo service zookeeper-server stop; \
sudo sudo -u zookeeper /usr/lib/zookeeper/bin/zkServer-initialize.sh --force --myid ${myid}
sudo service zookeeper-server start; \
"
done
echo `date` end install zookeeper-server
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment