Repository: bigtop Updated Branches: refs/heads/BIGTOP-2253 52d5e65e9 -> 24aa75744 (forced update)
BIGTOP-2273. Add exec command into docker-hadoop.sh Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/43acb843 Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/43acb843 Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/43acb843 Branch: refs/heads/BIGTOP-2253 Commit: 43acb8434eb15cc11b1f9c7e923c9be0b2c8a318 Parents: d19b5c7 Author: Evans Ye <[email protected]> Authored: Sun Jan 24 13:49:36 2016 +0800 Committer: Evans Ye <[email protected]> Committed: Sat Apr 23 08:23:05 2016 +0000 ---------------------------------------------------------------------- provisioner/docker/README.md | 23 +++++++++++++++++----- provisioner/docker/docker-hadoop.sh | 33 ++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/43acb843/provisioner/docker/README.md ---------------------------------------------------------------------- diff --git a/provisioner/docker/README.md b/provisioner/docker/README.md index 51bac85..3866ee8 100644 --- a/provisioner/docker/README.md +++ b/provisioner/docker/README.md @@ -60,19 +60,31 @@ service docker start ./docker-hadoop.sh --destroy ``` -3) Update your cluster after doing configuration changes on ./config. (re-run puppet apply) +3) Get into the first container (the master) + +``` +./docker-hadoop.sh --exec 1 bash +``` + +4) Execute a command on the second container + +``` +./docker-hadoop.sh --exec 2 hadoop fs -ls / +``` + +5) Update your cluster after doing configuration changes on ./config. (re-run puppet apply) ``` ./docker-hadoop.sh --provision ``` -4) Run Bigtop smoke tests +6) Run Bigtop smoke tests ``` ./docker-hadoop.sh --smoke-tests ``` -5) Chain your operations with-in one command. +7) Chain your operations with-in one command. ``` ./docker-hadoop.sh --create 5 --smoke-tests --destroy @@ -84,7 +96,7 @@ Commands will be executed by following order: create 5 node cluster => run smoke tests => destroy the cluster ``` -6) See helper message: +8) See helper message: ``` ./docker-hadoop.sh -h @@ -92,9 +104,10 @@ usage: docker-hadoop.sh [-C file ] args -C file Use alternate file for config.yaml commands: -c NUM_INSTANCES, --create=NUM_INSTANCES Create a Docker based Bigtop Hadoop cluster + -d, --destroy Destroy the cluster + -e, --exec INSTANCE_NO COMMAND Execute command on a specific instance. For example: docker-hadoop.sh --exec 1 bash -p, --provision Deploy configuration changes -s, --smoke-tests Run Bigtop smoke tests - -d, --destroy Destroy the cluster -h, --help ``` http://git-wip-us.apache.org/repos/asf/bigtop/blob/43acb843/provisioner/docker/docker-hadoop.sh ---------------------------------------------------------------------- diff --git a/provisioner/docker/docker-hadoop.sh b/provisioner/docker/docker-hadoop.sh index e8bd767..d8392ba 100755 --- a/provisioner/docker/docker-hadoop.sh +++ b/provisioner/docker/docker-hadoop.sh @@ -22,9 +22,12 @@ usage() { echo " -C file Use alternate file for config.yaml" echo " commands:" echo " -c NUM_INSTANCES, --create=NUM_INSTANCES Create a Docker based Bigtop Hadoop cluster" + echo " -d, --destroy Destroy the cluster" + echo " -e, --exec INSTANCE_NO|INSTANCE_NAME Execute command on a specific instance. Instance can be specified by name or number." + echo " For example: $PROG --exec 1 bash" + echo " $PROG --exec docker_bigtop_1 bash" echo " -p, --provision Deploy configuration changes" echo " -s, --smoke-tests Run Bigtop smoke tests" - echo " -d, --destroy Destroy the cluster" echo " -h, --help" exit 1 } @@ -137,6 +140,20 @@ get-yaml-config() { cat ${yamlconf} | $RUBY_EXE -ryaml -e "$RUBY_SCRIPT" | tr -d '\r' } +execute() { + re='^[0-9]+$' + if [[ $1 =~ $re ]] ; then + no=$1 + shift + nodes=(`docker-compose ps -q`) + docker exec -ti ${nodes[$((no-1))]} $@ + else + name=$1 + shift + docker exec -ti $name $@ + fi +} + PROG=`basename $0` if [ $# -eq 0 ]; then @@ -160,15 +177,23 @@ while [ $# -gt 0 ]; do fi yamlconf=$2 shift 2;; + -d|--destroy) + destroy + shift;; + -e|--exec) + if [ $# -lt 3 ]; then + echo "exec command takes 2 parameters: 1) instance no 2) command to be executed" 1>&2 + usage + fi + shift + execute $@ + shift $#;; -p|--provision) provision shift;; -s|--smoke-tests) smoke-tests shift;; - -d|--destroy) - destroy - shift;; -h|--help) usage shift;;
