def configure_hbase(): # add java options role_api_instance = cm_client.RolesResourceApi(api_client) rcg_configs = role_api_instance.read_roles(cluster.name, hbase.name) regionserver_groups = [rcg_config.name for rcg_config in rcg_configs.items if rcg_config.type == 'REGIONSERVER'] hbase_java_opts_config = cm_client.ApiConfig(name="hbase_regionserver_java_opts", value="{{JAVA_GC_ARGS}} -XX:ReservedCodeCacheSize=256m -XX:NativeMemoryTracking=summary -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=50100") body = cm_client.ApiServiceConfig([hbase_java_opts_config]) updated_configs = role_api_instance.update_role_config(cluster.name, regionserver_groups[0], hbase.name, body=body) # add environment variable env_config = cm_client.ApiConfig(name="hbase_service_env_safety_valve", value="ASYNC_PROFILER_HOME=/opt/async-profiler-1.8.5-linux-x64") body = cm_client.ApiServiceConfig([env_config]) updated_configs = services_api_instance.update_service_config(cluster.name, hbase.name, body=body) # TODO: add -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints java options to export more accurate async profiler output # enable offheap bucket cache env_config = cm_client.ApiConfig(name="hbase_bucketcache_ioengine", value="offheap") body = cm_client.ApiServiceConfig([env_config]) updated_configs = role_api_instance.update_role_config(cluster.name, regionserver_groups[0], hbase.name, body=body) # bucket cache size env_config = cm_client.ApiConfig(name="hbase_bucketcache_size", value="8192") body = cm_client.ApiServiceConfig([env_config]) updated_configs = role_api_instance.update_role_config(cluster.name, regionserver_groups[0], hbase.name, body=body) print("HBase updated")
def init_conn(self, host, port, version): """初始化连接,构建cm的连接实例 """ url = host + ':' + port + '/api/' + version client = cm_client.ApiClient(url) # 生成资源API self._cluster_api_instance = cm_client.ClustersResourceApi(client) # 为了获取namemode的资源API self._services_api_instance = cm_client.ServicesResourceApi(client) self._roles_api_instance = cm_client.RolesResourceApi(client) self._host_api_instance = cm_client.HostsResourceApi(client)
def configure_yarn(): role_api_instance = cm_client.RolesResourceApi(api_client) rcg_configs = role_api_instance.read_roles(cluster.name, yarn.name) gateway_groups = [rcg_config.name for rcg_config in rcg_configs.items if rcg_config.type == 'GATEWAY'] map_memory_config = cm_client.ApiConfig(name="mapreduce_map_memory_mb", value="4096") body = cm_client.ApiServiceConfig([map_memory_config]) updated_configs = role_api_instance.update_role_config(cluster.name, gateway_groups[0], yarn.name, body=body) print("YARN updated")
def get_roles_api(self, cluster_name, service_name): try: roles_api_instance = cm_client.RolesResourceApi(self.api_client) roles_api_response = roles_api_instance.read_roles(cluster_name, service_name, view='full') return roles_api_response except ApiException as e: self.log.error( 'ERROR with RolesResourceApi > read_roles at {}'.format( self.url)) raise e
def __init__(self, cm_host, env, send_alert): cm_client.configuration.username = '******' cm_client.configuration.password = '******' self.env = env api_host = 'http://' + cm_host port = '7180' api_version = 'v19' api_url = api_host + ':' + port + '/api/' + api_version self.send_alert_email = send_alert print(api_url) self.api_client = cm_client.ApiClient(api_url) self.cluster_api_instance = cm_client.ClustersResourceApi( self.api_client) self.services_api_instance = cm_client.ServicesResourceApi( self.api_client) self.roles_api_instance = cm_client.RolesResourceApi(self.api_client) self.host_api_instance = cm_client.HostsResourceApi(self.api_client) self.host_details = self.get_hostname_by_id() self.bad_alert_count = 0 self.msg_body = ""
api_client = cm_client.ApiClient(api_url) cluster_api_instance = cm_client.ClustersResourceApi(api_client) # # Lists all known clusters. api_response = cluster_api_instance.read_clusters(view='SUMMARY') cluster = api_response.items[0] services_api_instance = cm_client.ServicesResourceApi(api_client) services = services_api_instance.read_services(cluster.name, view='FULL') for service in services.items: # print service.display_name, "-", service.type if service.type == 'YARN': yarn = service # roles = services_api_instance.read_roles(cluster.name, hdfs.name) roles_api_instance = cm_client.RolesResourceApi(api_client) command_api_instance = cm_client.RoleCommandsResourceApi(api_client) roles = roles_api_instance.read_roles(cluster.name, yarn.name) # print (roles) dn_roles = [ role.name for role in roles.items if role.type == 'NODEMANAGER' and role.host_ref.host_id in host_ids_action ] print(dn_roles) role_names = cm_client.ApiRoleNameList(dn_roles) cm_client.RoleCommandsResourceApi(api_client) if options.action.lower() == 'stop': cmd_list = command_api_instance.stop_command(cluster.name, yarn.name,