hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject incubator-hawq git commit: HAWQ-235. Fix init issues on centos7.
Date Mon, 01 Feb 2016 02:59:30 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 1df52b663 -> 163a35c36


HAWQ-235. Fix init issues on centos7.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/163a35c3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/163a35c3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/163a35c3

Branch: refs/heads/master
Commit: 163a35c36a9864063aaa328cee4d3ed3b3d75c9f
Parents: 1df52b6
Author: rlei <rlei@pivotal.io>
Authored: Sun Jan 31 22:18:10 2016 +0800
Committer: rlei <rlei@pivotal.io>
Committed: Mon Feb 1 10:50:34 2016 +0800

----------------------------------------------------------------------
 tools/bin/hawq_ctl        | 20 ++-------
 tools/bin/lib/hawqinit.sh | 93 ++++++++++++++++++++++++++++++++++--------
 2 files changed, 79 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/163a35c3/tools/bin/hawq_ctl
----------------------------------------------------------------------
diff --git a/tools/bin/hawq_ctl b/tools/bin/hawq_ctl
index 375c7fa..0d17c8b 100755
--- a/tools/bin/hawq_ctl
+++ b/tools/bin/hawq_ctl
@@ -306,7 +306,7 @@ class HawqInit:
 
         master_cmd = self._get_master_init_cmd()
         logger.info("Start to init master node: '%s'" % self.master_host_name)
-        check_return_code(local_ssh(master_cmd), logger, "Master init failed, exit", \
+        check_return_code(local_ssh(master_cmd, logger), logger, "Master init failed, exit",
\
                           "Master init successfully")
         if self.standby_host_name.lower() not in ('', 'none'):
             check_return_code(self._init_standby(), logger, \
@@ -508,16 +508,6 @@ class HawqStart:
             logger.info("Segments started successfully")
         return node_init.return_flag
 
-    def _check_master_running(self):
-        logger.info("Check if master is running")
-    def _check_standby_running(self):
-        logger.info("Check if standby master is running")
-    def _check_version(self):
-        logger.info("Check hawq version")
-    def _recovery_startup(self):
-        logger.info("Do recovery master start")
-    def _remove_postmaster_tmpfile(self, port):
-        logger.info("Delete postmaster temporary file")
 
     def run(self):
         if self.node_type == "master":
@@ -980,7 +970,7 @@ def create_parser():
                       choices=['smart', 'immediate', 'fast'],
                       dest="stop_mode",
                       default="smart",
-                      help="HAWQ stop mode: smart/fast/immediatly")
+                      help="HAWQ stop mode: smart/fast/immediate")
     parser.add_option("-v", "--verbose",
                       action="store_true",
                       dest="verbose",
@@ -1004,14 +994,10 @@ def create_parser():
                       dest="parallel_processses",
                       default="60",
                       help="Sets the max parallel processes")
-    parser.add_option("-V", "--version",
-                      dest="hawq_version",
-                      default="dev",
-                      help="Show HAWQ version")
     parser.add_option("--user",
                       dest="user",
                       default="",
-                      help="Sets hawq user")
+                      help="Sets HAWQ user")
     parser.add_option("-u", "--reload",
                       dest="hawq_reload",
                       action="store_true",

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/163a35c3/tools/bin/lib/hawqinit.sh
----------------------------------------------------------------------
diff --git a/tools/bin/lib/hawqinit.sh b/tools/bin/lib/hawqinit.sh
index 4431900..daaa28a 100755
--- a/tools/bin/lib/hawqinit.sh
+++ b/tools/bin/lib/hawqinit.sh
@@ -28,10 +28,41 @@ ${SOURCE_PATH}
 
 host_name=`${HOSTNAME}`
 
-if [ -f /etc/redhat-release ]; then
-    os_version=`${CAT} /etc/redhat-release | ${AWK} '{print substr($7,0,1)}'`
+lowercase(){
+    echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
+}
+
+OS=`lowercase \`uname\``
+
+if [ "${OS}" = "darwin" ]; then
+    OS=mac
+    distro_based_on='Mac'
+    distro_name=`sw_vers -productName`
+    distro_version=`sw_vers -productVersion`
+    distro_major_version=`echo $distro_version |awk -F '.' '{print $1}'`
 else
-    os_version='other'
+    if [ "${OS}" = "linux" ] ; then
+        if [ -f /etc/redhat-release ] ; then
+            distro_based_on='RedHat'
+            distro_name=`cat /etc/redhat-release |sed s/\ release.*//`
+            psuedo_name=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
+            distro_version=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
+            distro_major_version=`echo $distro_version | awk -F '.' '{print $1}'`
+        elif [ -f /etc/SuSE-release ] ; then
+            distro_based_on='SuSe'
+            distro_name=`cat /etc/SuSE-release |sed s/\ release.*//`
+            psuedo_name=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
+            distro_version=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
+            distro_major_version=`echo $distro_version |awk -F '.' '{print $1}'`
+        elif [ -f /etc/debian_version ] ; then
+            distro_based_on='Debian'
+            distro_name=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F=  '{ print $2
}'`
+            psuedo_name=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F=  '{ print
$2 }'`
+            distro_version=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F=  '{
print $2 }'`
+            distro_major_version=`echo $distro_version |awk -F '.' '{print $1}'`
+        fi
+    fi
+
 fi
 
 mgmt_config_file=${GPHOME}/etc/_mgmt_config
@@ -54,25 +85,45 @@ else
    ${ECHO} "hawq init object should be one of master/standby/segment"
    exit 1
 fi
+
 master_max_connections=${max_connections}
 segment_max_connections=${max_connections}
 master_ip_address_all=""
 standby_ip_address_all=""
-if [ "${os_version}" = "7" ];then
-    master_ip_address_all=`${SSH} ${master_host_name} "${IFCONFIG} |${GREP} -v '127.0.0'
| ${GREP} 'inet '|${AWK} '{print \\$2}'"`
-    if [ "${standby_host_name}" != "" ] && [ "${standby_host_name}" != "None" ] \
-        && [ "${standby_host_name}" != "none" ] && [ "${standby_host_name}"
!= "NONE" ];then
-        standby_ip_address_all=`${SSH} ${standby_host_name} "${IFCONFIG} |${GREP} -v '127.0.0'
| ${GREP} 'inet '|${AWK} '{print \\$2}'"`
+standby_host_lowercase=`lowercase "${standby_host_name}"`
+
+get_all_ip_address() {
+    if [ "${distro_based_on}" = "RedHat" ] && [ "${distro_major_version}" -ge 7 ];
then
+        cmd_str="${IFCONFIG} |${GREP} -v '127.0.0' | ${GREP} 'inet '|${AWK} '{print \$2}'"
+    elif [ "${distro_based_on}" = "Mac" ] && [ "${distro_version:0:5}" = "10.11"
]; then
+        cmd_str="${IFCONFIG} |${GREP} -v '127.0.0' | ${GREP} 'inet '|${AWK} '{print \$2}'"
+    else
+        cmd_str="${IFCONFIG} |${GREP} -v '127.0.0' |${AWK} '/inet addr/{print substr(\$2,6)}'"
     fi
-    segment_ip_address_all=`${IFCONFIG} | ${GREP} -v '127.0.0' | ${AWK} '/inet addr/{print
substr($2,6)}'`
-else
-    master_ip_address_all=`${SSH} ${master_host_name} "${IFCONFIG} |${GREP} -v '127.0.0'
|${AWK} '/inet addr/{print substr(\\$2,6)}'"`
-    if [ "${standby_host_name}" != "" ] && [ "${standby_host_name}" != "None" ] \
-        && [ "${standby_host_name}" != "none" ] && [ "${standby_host_name}"
!= "NONE" ];then
-        standby_ip_address_all=`${SSH} ${standby_host_name} "${IFCONFIG} |${GREP} -v '127.0.0'
|${AWK} '/inet addr/{print substr(\\$2,6)}'"`
+
+    master_ip_address_all=`${SSH} ${master_host_name} "${cmd_str}"`
+    if [ -z ${master_ip_address_all} ];then
+        ${ECHO} "Failed to get master ip addresses"
+        exit 1
     fi
-    segment_ip_address_all=`${IFCONFIG} | ${GREP} -v '127.0.0' | ${AWK} '/inet addr/{print
substr($2,6)}'`
-fi
+
+    if [ "${standby_host_lowercase}" != "none" ] && [ -n "${standby_host_lowercase}"
];then
+        standby_ip_address_all=`${SSH} ${standby_host_name} "${cmd_str}"`
+        if [ -z ${standby_ip_address_all} ];then
+            ${ECHO} "Failed to get standby ip addresses"
+            exit 1
+        fi
+    fi
+
+    segment_ip_address_all=`${SSH} localhost "${cmd_str}"`
+
+    if [ -z ${segment_ip_address_all} ];then
+        ${ECHO} "Failed to get segment ip addresses"
+        exit 1
+    fi
+}
+
+get_all_ip_address
 
 PG_HBA=pg_hba.conf
 TMP_PG_HBA=/tmp/pg_hba_conf_master.$$
@@ -152,6 +203,14 @@ LOAD_GP_TOOLKIT () {
     return $RETVAL
 }
 
+get_master_ipv6_addresses() {
+    if [ "${distro_based_on}" = "Mac" ] && [ "${distro_version:0:5}" = "10.11" ];
then
+        MASTER_IPV6_LOCAL_ADDRESS_ALL=(`${IFCONFIG} | ${GREP} inet6 | ${AWK} '{print $2}'
| cut -d'%' -f1`)
+    else
+        MASTER_IPV6_LOCAL_ADDRESS_ALL=(`ip -6 address show |${GREP} inet6|${AWK} '{print
$2}' |cut -d'/' -f1`)
+    fi
+}
+
 update_master_pg_hba(){
     # Updatepg_hba.conf for master.
     ${CAT} ${hawq_data_directory}/${PG_HBA} |${GREP} '^#' > ${TMP_PG_HBA}
@@ -160,7 +219,7 @@ update_master_pg_hba(){
     ${ECHO} "local    all         $USER         ident" >> ${hawq_data_directory}/${PG_HBA}
     # ${ECHO} "[INFO]:-Setting local host access"
     ${ECHO} "host     all         $USER         127.0.0.1/28    trust" >> ${hawq_data_directory}/${PG_HBA}
-    MASTER_IPV6_LOCAL_ADDRESS_ALL=(`/sbin/ip -6 address show |${GREP} inet6|${AWK} '{print
$2}' |cut -d'/' -f1`)
+    get_master_ipv6_addresses
     MASTER_HBA_IP_ADDRESS=(`${ECHO} ${master_ip_address_all[@]} ${MASTER_IPV6_LOCAL_ADDRESS_ALL[@]}
${standby_ip_address_all[@]}|tr ' ' '\n'|sort -u|tr '\n' ' '`)
     for ip_address in ${MASTER_HBA_IP_ADDRESS[@]}; do
         CIDR_MASTER_IP=$(GET_CIDRADDR ${ip_address})


Mime
View raw message