Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!
Labels (1)
avatar
Master Guru

I have written ambari-admin utility to simplify efforts required to find and trigger API curl call. I'm planning to add many more features than ambari-shell.

Currently below features are supported.

4980-screen-shot-2016-06-13-at-125845-pm.png

Demo on multinode cluster:

1. Clone our github repo to your local machine or any of the node in your cluster.

[root@sme-ambari-server ~]# git clone https://github.com/crazyadmins/useful-scripts.git
Initialized empty Git repository in /root/useful-scripts/.git/
remote: Counting objects: 106, done.
remote: Total 106 (delta 0), reused 0 (delta 0), pack-reused 106
Receiving objects: 100% (106/106), 16.89 KiB, done.
Resolving deltas: 100% (37/37), done.

2. Goto useful-scripts/ambari/

[root@sme-ambari-server ~]# cd useful-scripts/ambari/

3. Edit ambari.props and modify value of below parameters as per your cluster environment

[root@sme-ambari-server ambari]# cat ambari.props
CLUSTER_NAME=sme
AMBARI_ADMIN_USER=admin
AMBARI_ADMIN_PASSWORD=admin
AMBARI_HOST=sme-ambari-server.hwxblr.com
KDC_HOST=sme-ambari-server.hwxblr.com
REALM=HWX.COM
KERBEROS_CLIENTS=sme-ambari-server.hwxblr.com,kknew1.hwxblr.com,kknew2.hwxblr.com,kknew3.hwxblr.com
##### Notes #####
#1. KERBEROS_CLIENTS - Comma separated list of Kerberos clients in case of multinode cluster
#2. Admin princial is admin/admin and password is hadoop

Note - You can ignore Kerberos related parameters for now, in future this script will have functionality to setup Kerberos.

4. To print usage you can run ambari-admin.sh without any argument

Please refer first screenshot provided at the beginning of this article.

5. Stop All services

[root@sme-ambari-server ambari]# ./ambari-admin.sh stopall
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=14oisfe8i5bclm8tdk3npm390;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 152
Server: Jetty(8.1.17.v20150415)
{
  "href" : "http://sme-ambari-server.hwxblr.com:8080/api/v1/clusters/sme/requests/61",
  "Requests" : {
    "id" : 61,
    "status" : "Accepted"
  }

4410-screen-shot-2016-05-22-at-42954-pm.png

4411-screen-shot-2016-05-22-at-42947-pm.png

6. Start all the services

[root@sme-ambari-server ambari]# ./ambari-admin.sh startall
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=1lo2x6u1r5xq319suwh8xiiquw;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 152
Server: Jetty(8.1.17.v20150415)
{
  "href" : "http://sme-ambari-server.hwxblr.com:8080/api/v1/clusters/sme/requests/62",
  "Requests" : {
    "id" : 62,
    "status" : "Accepted"
  }

4412-screen-shot-2016-05-22-at-43601-pm.png

7. Get list of all services installed in your cluster, script also shows list of installed components host_wise

[root@sme-ambari-server ambari]# ./ambari-admin.sh listall
Below is the list of installed services in your cluster:
HDFS
MAPREDUCE2
SMARTSENSE
TEZ
YARN
ZOOKEEPER
########################### List of Host-wise installed components ###########################
kknew1.hwxblr.com
        "component_name" | "DATANODE"
        "component_name" | "HDFS_CLIENT"
        "component_name" | "HST_AGENT"
        "component_name" | "HST_SERVER"
        "component_name" | "MAPREDUCE2_CLIENT"
        "component_name" | "NAMENODE"
        "component_name" | "NODEMANAGER"
        "component_name" | "YARN_CLIENT"
        "component_name" | "ZOOKEEPER_CLIENT"
kknew2.hwxblr.com
        "component_name" | "DATANODE"
        "component_name" | "HDFS_CLIENT"
        "component_name" | "HST_AGENT"
        "component_name" | "MAPREDUCE2_CLIENT"
        "component_name" | "NODEMANAGER"
        "component_name" | "SECONDARY_NAMENODE"
        "component_name" | "YARN_CLIENT"
        "component_name" | "ZOOKEEPER_CLIENT"
        "component_name" | "ZOOKEEPER_SERVER"
kknew3.hwxblr.com
        "component_name" | "APP_TIMELINE_SERVER"
        "component_name" | "DATANODE"
        "component_name" | "HDFS_CLIENT"
        "component_name" | "HISTORYSERVER"
        "component_name" | "HST_AGENT"
        "component_name" | "MAPREDUCE2_CLIENT"
        "component_name" | "NODEMANAGER"
        "component_name" | "RESOURCEMANAGER"
        "component_name" | "TEZ_CLIENT"
        "component_name" | "YARN_CLIENT"
        "component_name" | "ZOOKEEPER_CLIENT"
        "component_name" | "ZOOKEEPER_SERVER"
sme-ambari-server.hwxblr.com
        "component_name" | "HDFS_CLIENT"
        "component_name" | "HST_AGENT"
        "component_name" | "MAPREDUCE2_CLIENT"
        "component_name" | "TEZ_CLIENT"
        "component_name" | "YARN_CLIENT"
        "component_name" | "ZOOKEEPER_CLIENT"

8. Stop individual service

[root@sme-ambari-server ambari]# ./ambari-admin.sh stop yarn
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=10tyime2kd7pr1e0o4t8gwg2jv;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 152
Server: Jetty(8.1.17.v20150415)
{
  "href" : "http://sme-ambari-server.hwxblr.com:8080/api/v1/clusters/sme/requests/63",
  "Requests" : {
    "id" : 63,
    "status" : "Accepted"
  }
}

4414-screen-shot-2016-05-22-at-44619-pm.png

4415-screen-shot-2016-05-22-at-44628-pm.png

9. Start Individual service

[root@sme-ambari-server ambari]# ./ambari-admin.sh start yarn
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=a7wdqn56clk8176d99rm20hz5;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 152
Server: Jetty(8.1.17.v20150415)
{
  "href" : "http://sme-ambari-server.hwxblr.com:8080/api/v1/clusters/sme/requests/64",
  "Requests" : {
    "id" : 64,
    "status" : "Accepted"
  }
}

4416-screen-shot-2016-05-22-at-44822-pm.png

4417-screen-shot-2016-05-22-at-44846-pm.png

10. Stop Individual service component

[root@sme-ambari-server ambari]# ./ambari-admin.sh stop hst_agent kknew2.hwxblr.com
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=vrmnhicrgog42lmu7exfqdm4;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 152
Server: Jetty(8.1.17.v20150415)
{
  "href" : "http://sme-ambari-server.hwxblr.com:8080/api/v1/clusters/sme/requests/65",
  "Requests" : {
    "id" : 65,
    "status" : "Accepted"
  }
}

4418-screen-shot-2016-05-22-at-45219-pm.png

11. Start Individual service component

[root@sme-ambari-server ambari]# ./ambari-admin.sh start hst_agent kknew2.hwxblr.com
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=1fqqp5vqpourgjll9ydnyev3e;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 152
Server: Jetty(8.1.17.v20150415)
{
  "href" : "http://sme-ambari-server.hwxblr.com:8080/api/v1/clusters/sme/requests/66",
  "Requests" : {
    "id" : 66,
    "status" : "Accepted"
  }
}

12. Remove any Hadoop client from any of the host

[root@sme-ambari-server ambari]# ./ambari-admin.sh remove tez_client kknew3.hwxblr.com

13. Add any Hadoop client on any of the host

[root@sme-ambari-server ambari]# ./ambari-admin.sh add tez_client kknew3.hwxblr.com
HTTP/1.1 201 Created
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=pl31hyai9aqt1eyeaj5ehe9i;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 0
Server: Jetty(8.1.17.v20150415)
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=18tzs8uctj2061pmjegp129aqz;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 152
Server: Jetty(8.1.17.v20150415)
{
  "href" : "http://sme-ambari-server.hwxblr.com:8080/api/v1/clusters/sme/requests/67",
  "Requests" : {
    "id" : 67,
    "status" : "Accepted"
  }
}
Sleeping for 5 seconds before starting TEZ_CLIENT
HTTP/1.1 200 OK
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
User: admin
Set-Cookie: AMBARISESSIONID=1bh3u5foki8vh1fgg240i49h6x;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 0
Server: Jetty(8.1.17.v20150415)

14. Backup database for Hive/Oozie/Ambari

Note - Please enter your database password, for e.g. in this demo I have entered default password('bigdata') for Ambari postgresql DB.

[root@sme-ambari-server ambari]# ./ambari-admin.sh backup ambari postgresql sme-ambari-server.hwxblr.com
Password:
[root@sme-ambari-server ambari]# ls -lrt ~/ambari_db_backup_2016_05_22_11_32.sql
-rw-r--r-- 1 root root 6812385 May 22 11:33 /root/ambari_db_backup_2016_05_22_11_32.sql
[root@sme-ambari-server ambari]# date
Sun May 22 11:33:20 UTC 2016
[root@sme-ambari-server ambari]#

Note - I'm planning to add below features to this script, please feel to provide your feedback on this 🙂

4419-screen-shot-2016-05-22-at-71644-pm.png

Please feel free to suggest if you would like to have any more features!

Stay Tuned for Part-2

Happy Hadooping!! 🙂


screen-shot-2016-05-22-at-43320-pm.png
5,877 Views
Version history
Last update:
‎08-17-2019 12:20 PM
Updated by:
Contributors