Shell Script to Install Ambari Agent on all nodes from One node

0
40

If we want to add new datanodes to your existing hadoop cluster first we need to install ambari agents on all nodes. Ambari agents we can install two ways.

  • Provide your SSH private key (id_rsa for root) and use SSH to automatically register hosts
  • Perform Manual registration on host and don’t use SSH

suppose you need to add new 100 datanodes to your existing hadoop cluster, if you selected SSH private key option, you don’t need to install ambari agents over all 100 datanodes manually, By using SSH connectivity ambari-server can install ambari-agents over the all new nodes.

If you facing any issues with SSH connection installation, then you have to select second option. But here we need to install ambari-agents on all nodes manually. Instantiating ambari-agents on all nodes manually is not an easy task,It will take lot of time to install manually.

To avoid manual efforts we can use shell script to Install Ambari Agent on all nodes from One node. To run shell script successfully first we need to complete some pre-requisites .

pre-requisites to Install Ambari Agent on all nodes from One node

Install Ambari Agent on all nodes from One node

In host file only copy the required new nodes hostnames or IP address with line separate format.

for i in `cat hosts`; do echo "###### $i #########" ; ssh -t $i sudo yum install -y ambari-agent  ; done

-y helps to install directly without asking Y/N options.

Check Ambari Agent Status on all nodes from One node

for i in `cat hosts`; do echo "###### $i #########" ; ssh -t $i sudo ambari-agent status; done

If ambari-agent installed on all required nodes,The above command gives the output as ambari-agent stopped.

Start Ambari Agent on all nodes from One node

for i in `cat hosts`; do echo "###### $i #########" ; ssh -t $i sudo ambari-agent start; done

The above command start the all ambari-agents from one node with help of this small script.

Stop Ambari Agent on all nodes from One node

for i in `cat hosts`; do echo "###### $i #########" ; ssh -t $i sudo ambari-agent stop; done

The above command start the all ambari-agents from one node with help of this small script.

Suppose if you want to install any other software by using .sh file, you can use below script. In the below script i am showing you how to install anaconda on all required hosts from one node to all nodes at a time.

for i in `cat hosts`; do echo "###### $i #########" ; ssh -t $i sudo sh /home/user/anaconda501ac14-0.1.2-Linux-x86_64.sh -b -p /opt/continum/anaconda501ac14-0.1.2/ ; done

LEAVE A REPLY

Please enter your comment!
Please enter your name here