Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | USERNAME=ubuntu |
| 3 | if [ $# == 3 ]; then |
| 4 | NR_NODES=$1 |
| 5 | basename=$2 |
| 6 | hosts_file=$3 |
| 7 | else |
| 8 | echo "$0 nr_hodes basename hostfile" |
| 9 | exit |
| 10 | fi |
| 11 | |
| 12 | for n in `seq 1 $NR_NODES`; do |
| 13 | rm -rf ${basename}${n} |
| 14 | mkdir ${basename}${n} |
| 15 | echo "${basename}${n}" > ${basename}${n}/hostname |
| 16 | echo $n > ${basename}${n}/myid |
| 17 | done |
| 18 | |
| 19 | ## ZK config ## |
| 20 | cp template/zoo.cfg common/ |
| 21 | for n in `seq 1 $NR_NODES`; do |
| 22 | echo "server.${n}=${basename}${n}:2888:3888" |
| 23 | done >> common/zoo.cfg |
| 24 | |
| 25 | ## Cassandra config ## |
| 26 | cat template/cassandra.yaml |\ |
| 27 | sed "s/__SEED__/${basename}1/g" > common/cassandra.yaml |
| 28 | |
| 29 | ## /etc/hosts ## |
| 30 | cat template/hosts $hosts_file > common/hosts |
| 31 | |
| 32 | ## .ssh/known_hosts ## |
| 33 | ssh-keyscan -H -t rsa github.com > common/known_hosts |
| 34 | ssh-keyscan -H -t rsa onosnat >> common/known_hosts |
| 35 | for n in `seq 1 $NR_NODES`; do |
| 36 | ssh-keyscan -H -t rsa ${basename}${n} |
| 37 | done >> common/known_hosts |
| 38 | |
| 39 | echo "GROUP: $basename" > cluster.txt |
| 40 | cat $hosts_file | awk '{print $2}' >> cluster.txt |
| 41 | |
| 42 | |
| 43 | ## Creating shell script to login each node ## |
| 44 | for n in `seq 1 $NR_NODES`; do |
| 45 | cat << EOF > bin/${basename}${n} |
| 46 | #!/bin/sh |
| 47 | ssh $USERNAME@${basename}${n} |
| 48 | EOF |
| 49 | chmod 755 bin/${basename}${n} |
| 50 | done |
| 51 | |
| 52 | echo "======================================" |
| 53 | echo "Do not forget to do the following" |
| 54 | echo "paste $hosts_file to /etc/hosts" |
| 55 | echo "paste cluster.txt to your CLUSTER file" |
| 56 | echo "======================================" |