def start_cluster(self, cluster): nn_instance = utils.get_namenode(cluster) datanodes = utils.get_datanodes(cluster) jt_instance = utils.get_jobtracker(cluster) tasktrackers = utils.get_tasktrackers(cluster) oozie = utils.get_oozie(cluster) hive_server = utils.get_hiveserver(cluster) with remote.get_remote(nn_instance) as r: run.format_namenode(r) run.start_process(r, "namenode") snns = utils.get_secondarynamenodes(cluster) if snns: for snn in snns: run.start_process(remote.get_remote(snn), "secondarynamenode") for dn in datanodes: run.start_process(remote.get_remote(dn), "datanode") LOG.info("HDFS service at '%s' has been started", nn_instance.hostname) if jt_instance: run.start_process(remote.get_remote(jt_instance), "jobtracker") for tt in tasktrackers: run.start_process(remote.get_remote(tt), "tasktracker") LOG.info("MapReduce service at '%s' has been started", jt_instance.hostname) if oozie: with remote.get_remote(oozie) as r: if c_helper.is_mysql_enable(cluster): run.mysql_start(r, oozie) run.oozie_create_db(r) run.oozie_share_lib(r, nn_instance.hostname) run.start_oozie(r) LOG.info("Oozie service at '%s' has been started", nn_instance.hostname) if hive_server: with remote.get_remote(nn_instance) as r: run.hive_create_warehouse_dir(r) if c_helper.is_mysql_enable(cluster): with remote.get_remote(hive_server) as h: if not oozie or hive_server.hostname != oozie.hostname: run.mysql_start(h, hive_server) run.hive_create_db(h) run.hive_metastore_start(h) LOG.info("Hive Metastore server at %s has been started", hive_server.hostname) LOG.info('Cluster %s has been started successfully' % cluster.name) self._set_cluster_info(cluster)
def _push_hive_configs(self, cluster, ng_extra, hive_mysql_passwd, r): files = {'/opt/hive/conf/hive-site.xml': ng_extra['xml']['hive-site']} if c_helper.is_mysql_enable(cluster): sql_script = f.get_file_text( 'plugins/vanilla/resources/create_hive_db.sql') sql_script = sql_script.replace('pass', hive_mysql_passwd) files.update({'/tmp/create_hive_db.sql': sql_script}) r.write_files_to(files)
def start_cluster(self, cluster): instances = utils.get_instances(cluster) nn_instance = utils.get_namenode(cluster) jt_instance = utils.get_jobtracker(cluster) oozie = utils.get_oozie(cluster) hive_server = utils.get_hiveserver(cluster) with remote.get_remote(nn_instance) as r: run.format_namenode(r) run.start_processes(r, "namenode") for snn in utils.get_secondarynamenodes(cluster): run.start_processes(remote.get_remote(snn), "secondarynamenode") if jt_instance: run.start_processes(remote.get_remote(jt_instance), "jobtracker") self._start_tt_dn_processes(instances) LOG.info("Hadoop services in cluster %s have been started" % cluster.name) if oozie: with remote.get_remote(oozie) as r: if c_helper.is_mysql_enable(cluster): run.mysql_start(r, oozie) run.oozie_create_db(r) run.oozie_share_lib(r, nn_instance.hostname) run.start_oozie(r) LOG.info("Oozie service at '%s' has been started", nn_instance.hostname) if hive_server: with remote.get_remote(nn_instance) as r: run.hive_create_warehouse_dir(r) if c_helper.is_mysql_enable(cluster): with remote.get_remote(hive_server) as h: if not oozie or hive_server.hostname != oozie.hostname: run.mysql_start(h, hive_server) run.hive_create_db(h) run.hive_metastore_start(h) LOG.info("Hive Metastore server at %s has been started", hive_server.hostname) LOG.info('Cluster %s has been started successfully' % cluster.name) self._set_cluster_info(cluster)
def start_cluster(self, cluster): nn_instance = utils.get_namenode(cluster) with remote.get_remote(nn_instance) as r: run.format_namenode(r) run.start_processes(r, "namenode") for snn in utils.get_secondarynamenodes(cluster): run.start_processes(remote.get_remote(snn), "secondarynamenode") jt_instance = utils.get_jobtracker(cluster) if jt_instance: run.start_processes(remote.get_remote(jt_instance), "jobtracker") self._start_tt_dn_processes(utils.get_instances(cluster)) self._await_datanodes(cluster) LOG.info("Hadoop services in cluster %s have been started" % cluster.name) oozie = utils.get_oozie(cluster) if oozie: with remote.get_remote(oozie) as r: if c_helper.is_mysql_enable(cluster): run.mysql_start(r, oozie) run.oozie_create_db(r) run.oozie_share_lib(r, nn_instance.hostname()) run.start_oozie(r) LOG.info("Oozie service at '%s' has been started", nn_instance.hostname()) hive_server = utils.get_hiveserver(cluster) if hive_server: with remote.get_remote(nn_instance) as r: run.hive_create_warehouse_dir(r) if c_helper.is_mysql_enable(cluster): with remote.get_remote(hive_server) as h: if not oozie or hive_server.hostname() != oozie.hostname(): run.mysql_start(h, hive_server) run.hive_create_db(h) run.hive_metastore_start(h) LOG.info("Hive Metastore server at %s has been started", hive_server.hostname()) LOG.info('Cluster %s has been started successfully' % cluster.name) self._set_cluster_info(cluster)
def _push_oozie_configs(self, cluster, ng_extra, r): r.write_file_to('/opt/oozie/conf/oozie-site.xml', ng_extra['xml']['oozie-site']) if c_helper.is_mysql_enable(cluster): sql_script = f.get_file_text( 'plugins/vanilla/resources/create_oozie_db.sql') files = {'/tmp/create_oozie_db.sql': sql_script} r.write_files_to(files)
def _push_oozie_configs(self, cluster, ng_extra, r): r.write_file_to('/opt/oozie/conf/oozie-site.xml', ng_extra['xml']['oozie-site']) if c_helper.is_mysql_enable(cluster): sql_script = f.get_file_text( 'plugins/vanilla/resources/create_oozie_db.sql') files = { '/tmp/create_oozie_db.sql': sql_script } r.write_files_to(files)
def _push_hive_configs(self, cluster, ng_extra, hive_mysql_passwd, r): files = { '/opt/hive/conf/hive-site.xml': ng_extra['xml']['hive-site'] } if c_helper.is_mysql_enable(cluster): sql_script = f.get_file_text( 'plugins/vanilla/resources/create_hive_db.sql' ) sql_script = sql_script.replace('pass', hive_mysql_passwd) files.update({'/tmp/create_hive_db.sql': sql_script}) r.write_files_to(files)
def _push_configs_to_nodes(self, cluster, instances=None): extra = self._extract_configs_to_extra(cluster) if instances is None: instances = utils.get_instances(cluster) for inst in instances: ng_extra = extra[inst.node_group.id] files = { '/etc/hadoop/core-site.xml': ng_extra['xml']['core-site'], '/etc/hadoop/mapred-site.xml': ng_extra['xml']['mapred-site'], '/etc/hadoop/hdfs-site.xml': ng_extra['xml']['hdfs-site'], '/tmp/savanna-hadoop-init.sh': ng_extra['setup_script'] } with remote.get_remote(inst) as r: # TODO(aignatov): sudo chown is wrong solution. But it works. r.execute_command( 'sudo chown -R $USER:$USER /etc/hadoop' ) r.execute_command( 'sudo chown -R $USER:$USER /opt/oozie/conf' ) r.write_files_to(files) r.execute_command( 'sudo chmod 0500 /tmp/savanna-hadoop-init.sh' ) r.execute_command( 'sudo /tmp/savanna-hadoop-init.sh ' '>> /tmp/savanna-hadoop-init.log 2>&1') nn = utils.get_namenode(cluster) jt = utils.get_jobtracker(cluster) with remote.get_remote(nn) as r: r.write_file_to('/etc/hadoop/dn.incl', utils. generate_fqdn_host_names( utils.get_datanodes(cluster))) if jt: with remote.get_remote(jt) as r: r.write_file_to('/etc/hadoop/tt.incl', utils. generate_fqdn_host_names( utils.get_tasktrackers(cluster))) oozie = utils.get_oozie(cluster) if oozie: with remote.get_remote(oozie) as r: r.write_file_to('/opt/oozie/conf/oozie-site.xml', extra[oozie.node_group.id] ['xml']['oozie-site']) if c_helper.is_mysql_enable(cluster): sql_script = f.get_file_text( 'plugins/vanilla/resources/create_oozie_db.sql') files = { '/tmp/create_oozie_db.sql': sql_script } remote.get_remote(oozie).write_files_to(files) hive_server = utils.get_hiveserver(cluster) if hive_server: ng_extra = extra[hive_server.node_group.id] files = { '/opt/hive/conf/hive-site.xml': ng_extra['xml']['hive-site'] } if c_helper.is_mysql_enable(cluster): sql_script = f.get_file_text( 'plugins/vanilla/resources/create_hive_db.sql' ) files.update({'/tmp/create_hive_db.sql': sql_script}) remote.get_remote(hive_server).write_files_to(files)