Created on 05-22-2016 11:08 AM - edited 08-17-2019 12:20 PM
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.
[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.
[root@sme-ambari-server ~]# cd useful-scripts/ambari/
[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.
Please refer first screenshot provided at the beginning of this article.
[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" }
[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" }
[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"
[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" } }
[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" } }
[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" } }
[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" } }
[root@sme-ambari-server ambari]# ./ambari-admin.sh remove tez_client kknew3.hwxblr.com
[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)
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]#