Nitin Kumar Nitin Kumar - 7 months ago 26
SQL Question

Restarting a MySQL server managed by Ambari

I have a scenario where I need to change several parameters of a hadoop cluster managed by Ambari to document performance of a particular application. The change in the configs entails a restart of the affected components.

I am using the Ambari REST API for achieving this. I figured out how to do this for all service components of hadoop. I' am not sure whether the API provides a way to restart the MySQL server that Hive uses.

I have the following questions:-


  1. Is it the case that a mere stop and start of mysqld on the appropriate machine is enough to ensure that the required configuration changes are recognized by Ambari and the application?

  2. I chose the 'New MySQL database' option while installing Hive via Ambari. Does this mean that restarts are reflected in Ambari only when it is carried out from the Ambari UI?



Your inputs would be highly appreciated.

Thanks!

Answer

Found a solution to the problem. I used the following commands using the Ambari REST API for changing configurations and restarting services from the backend.

Login to the host on which the ambari server is running and use the already provided config.sh script as described below.

Modifying configuration files

#!/bin/bash
CLUSTER_NAME=$1
CONFIG_FILE=$2
PROPERTY_NAME=$3
PROPERTY_VALUE=$4

/var/lib/ambari-server/resources/scripts/configs.sh -port <ambari-server-port> set localhost $1 $2 "$3" "$4"

where CONFIG_FILE can take values like tez-site, mapred-site, hadoop-site, hive-site etc. PROPERTY_NAME and PROPERTY_VALUE should be set to values relevant to the specified CONFIG_FILE.

Restarting host components

curl -uadmin:admin -H 'X-Requested-By: ambari' -X POST -d '
{
   "RequestInfo":{
      "command":"RESTART",
      "context":"Restart MySQL server used by Hive Metastore on node3.cluster.com and HDFS client on node1.cluster.com",
      "operation_level":{
         "level":"HOST",
         "cluster_name":"c1"
      }
   },
   "Requests/resource_filters":[
      {
         "service_name":"HIVE",
         "component_name":"MYSQL_SERVER",
         "hosts":"node3.cluster.com"
      },
      {
         "service_name":"HDFS",
         "component_name":"HDFS_CLIENT",
         "hosts":"node1.cluster.com"
      }
   ]
}' http://localhost:<ambari-server-port>/api/v1/clusters/c1/requests

Reference Links:

  1. Restarting components
  2. modifying configurations

Hope this helps!

Comments