Return-Path: X-Original-To: apmail-hawq-commits-archive@minotaur.apache.org Delivered-To: apmail-hawq-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BB7A418D62 for ; Wed, 24 Feb 2016 02:25:49 +0000 (UTC) Received: (qmail 91750 invoked by uid 500); 24 Feb 2016 02:25:49 -0000 Delivered-To: apmail-hawq-commits-archive@hawq.apache.org Received: (qmail 91710 invoked by uid 500); 24 Feb 2016 02:25:49 -0000 Mailing-List: contact commits-help@hawq.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hawq.incubator.apache.org Delivered-To: mailing list commits@hawq.incubator.apache.org Received: (qmail 91701 invoked by uid 99); 24 Feb 2016 02:25:49 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Feb 2016 02:25:49 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 2C8291805CD for ; Wed, 24 Feb 2016 02:25:49 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.549 X-Spam-Level: X-Spam-Status: No, score=-3.549 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.329] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id PNQS2qVQBUAr for ; Wed, 24 Feb 2016 02:25:47 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id 4F0D35F21E for ; Wed, 24 Feb 2016 02:25:47 +0000 (UTC) Received: (qmail 91691 invoked by uid 99); 24 Feb 2016 02:25:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Feb 2016 02:25:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6B1F3E8E85; Wed, 24 Feb 2016 02:25:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rlei@apache.org To: commits@hawq.incubator.apache.org Message-Id: <2f4fab72cd034a6ba21ea05737e207c9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-hawq git commit: HAWQ-431. Add option to specify standby host name while init Date: Wed, 24 Feb 2016 02:25:46 +0000 (UTC) Repository: incubator-hawq Updated Branches: refs/heads/master dbec94962 -> 4b84d6580 HAWQ-431. Add option to specify standby host name while init Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/4b84d658 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/4b84d658 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/4b84d658 Branch: refs/heads/master Commit: 4b84d658083d923dfa06240765c2a6c7a65ce731 Parents: dbec949 Author: rlei Authored: Tue Feb 23 12:42:54 2016 +0800 Committer: rlei Committed: Wed Feb 24 10:23:44 2016 +0800 ---------------------------------------------------------------------- tools/bin/hawq_ctl | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/4b84d658/tools/bin/hawq_ctl ---------------------------------------------------------------------- diff --git a/tools/bin/hawq_ctl b/tools/bin/hawq_ctl index 2bf3096..8e02788 100755 --- a/tools/bin/hawq_ctl +++ b/tools/bin/hawq_ctl @@ -55,6 +55,7 @@ class HawqInit: self.timeout = opts.timeout_seconds self.no_update = opts.no_update self.remove_standby = opts.remove_standby + self.new_standby_hostname = opts.new_standby_hostname self.hawq_dict = hawq_dict self.locale = opts.hawq_locale self.quiet = opts.quiet_run @@ -109,9 +110,14 @@ class HawqInit: logger.error("Standby host should not be the same as master host") sys.exit(1) else: - logger.info("No standby host configured, skip it") self.standby_host_name = '' + if self.new_standby_hostname != 'none': + self.standby_host_name = self.new_standby_hostname + + if self.standby_host_name.lower() in ('', 'none'): + logger.info("No standby host configured, skip it") + if 'enable_secure_filesystem' in self.hawq_dict: self.enable_secure_filesystem = self.hawq_dict['enable_secure_filesystem'] else: @@ -148,8 +154,7 @@ class HawqInit: f.write("dfs_url=%s\n" % self.dfs_url) f.write("log_filename=%s\n" % log_filename) f.write("log_dir=%s\n" % self.log_dir) - if 'hawq_standby_address_host' in self.hawq_dict: - with open(configFile, 'a') as f: + if self.standby_host_name.lower() not in ('', 'none'): f.write("standby_host_name=%s\n" % self.standby_host_name) @@ -168,6 +173,16 @@ class HawqInit: logger.debug("Check hdfs: %s" % cmd) check_return_code(local_ssh(cmd, logger, warning = True), logger, "Check hdfs failed, please verify your hdfs settings") + + def set_new_standby_host(self): + cmd = "%s; hawq config -c hawq_standby_address_host -v %s --skipvalidation -q > /dev/null" % \ + (source_hawq_env, self.new_standby_hostname) + result = local_ssh(cmd, logger) + if result != 0: + logger.warn("Set standby host name failed") + return result + + def set_total_vsegment_num(self): cmd = "%s; hawq config -c default_segment_num -v %s --skipvalidation -q > /dev/null" % \ (source_hawq_env, self.total_vseg_num) @@ -176,6 +191,7 @@ class HawqInit: logger.warn("Set default_segment_num failed") return result + def set_vsegment_num_per_node(self): cmd = "%s; hawq config -c hawq_rm_nvseg_perquery_perseg_limit \ -v %s --skipvalidation -q > /dev/null" % \ @@ -185,16 +201,19 @@ class HawqInit: logger.warn("Set hawq_rm_nvseg_perquery_perseg_limit failed") return result + def _get_master_init_cmd(self): cmd = "%s/bin/lib/hawqinit.sh master '%s'" % \ (self.GPHOME, self.GPHOME) return cmd + def _get_standby_init_cmd(self): cmd = "%s/bin/lib/hawqinit.sh standby '%s'" % \ (self.GPHOME, self.GPHOME) return cmd + def hawq_remove_standby(self): """Removes the standby master""" running_standby_host = '' @@ -266,6 +285,7 @@ class HawqInit: else: logger.info("Do not find a running standby master") + def _init_standby(self): logger.info("Start to init standby master: '%s'" % self.standby_host_name) logger.info("This might take a couple of minutes, please wait...") @@ -303,11 +323,13 @@ class HawqInit: return result + def _get_segment_init_cmd(self): cmd = "%s/bin/lib/hawqinit.sh segment '%s'" % \ (self.GPHOME, self.GPHOME) return cmd + def _init_cluster(self): logger.info("%s segment hosts defined" % self.hosts_count_number) logger.info("Set default_segment_num as: %s" % self.total_vseg_num) @@ -347,7 +369,11 @@ class HawqInit: return node_init.return_flag + def run(self): + if self.new_standby_hostname != 'none': + check_return_code(self.set_new_standby_host()) + if self.node_type == "master": self.check_hdfs_path() logger.info("%s segment hosts defined" % self.hosts_count_number) @@ -388,6 +414,7 @@ class HawqInit: sys.exit('hawq init object should be one of master/standby/segment/cluster') return None + class HawqStart: def __init__(self, opts, hawq_dict): self.node_type = opts.node_type @@ -1032,6 +1059,9 @@ def create_parser(): parser.add_option('-r', '--remove-standby', action='store_true', dest='remove_standby', default=False, help='Delete hawq standby master node.') + parser.add_option('-s', '--standby-host', type='string', + dest='new_standby_hostname', default='none', + help='Hostname of system to create standby master on') parser.add_option('-n', '--no-update', action='store_true', dest='no_update', default=False, help='Do not update system catalog tables.')