Repository: incubator-hawq Updated Branches: refs/heads/master 641176646 -> e90db50e9
HAWQ-675. update pg_hba config while init new standby Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/e90db50e Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/e90db50e Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/e90db50e Branch: refs/heads/master Commit: e90db50e9aacc1e5a1f00a3fff44578deaf751f0 Parents: 6411766 Author: rlei <[email protected]> Authored: Thu Apr 14 14:30:29 2016 +0800 Committer: rlei <[email protected]> Committed: Fri Apr 15 11:11:01 2016 +0800 ---------------------------------------------------------------------- tools/bin/lib/hawqinit.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/e90db50e/tools/bin/lib/hawqinit.sh ---------------------------------------------------------------------- diff --git a/tools/bin/lib/hawqinit.sh b/tools/bin/lib/hawqinit.sh index 43ffdef..1dd8b48 100755 --- a/tools/bin/lib/hawqinit.sh +++ b/tools/bin/lib/hawqinit.sh @@ -206,7 +206,7 @@ update_master_pg_hba(){ # ${ECHO} "[INFO]:-Setting local host access" ${ECHO} "host all $USER 127.0.0.1/28 trust" >> ${hawq_data_directory}/${PG_HBA} 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' ' '`) + MASTER_HBA_IP_ADDRESS=(`${ECHO} ${master_ip_address_all[@]} ${MASTER_IPV6_LOCAL_ADDRESS_ALL[@]}|tr ' ' '\n'|sort -u|tr '\n' ' '`) for ip_address in ${MASTER_HBA_IP_ADDRESS[@]}; do CIDR_MASTER_IP=$(GET_CIDRADDR ${ip_address}) CHK_COUNT=`${GREP} -c ${CIDR_MASTER_IP} ${hawq_data_directory}/${PG_HBA}` @@ -220,7 +220,23 @@ update_master_pg_hba(){ update_standby_pg_hba(){ # Updatepg_hba.conf for standby master. - ${ECHO} "host all all 0.0.0.0/0 trust" >> ${hawq_data_directory}/${PG_HBA} + STANDBY_HBA_IP_ADDRESSES=(`${ECHO} ${standby_ip_address_all[@]}|tr ' ' '\n'|sort -u|tr '\n' ' '`) + for ip_address in ${STANDBY_HBA_IP_ADDRESSES[@]}; do + CIDR_MASTER_IP=$(GET_CIDRADDR ${ip_address}) + CHK_COUNT=`${GREP} -c ${CIDR_MASTER_IP} ${master_data_directory}/${PG_HBA}` + if [ "$CHK_COUNT" -eq "0" ];then + ${SSH} -o 'StrictHostKeyChecking no' ${hawqUser}@${master_host_name} \ + "${ECHO} \"host all ${USER} ${CIDR_MASTER_IP} trust\" >> ${master_data_directory}/${PG_HBA}" + ${SSH} -o 'StrictHostKeyChecking no' ${hawqUser}@${standby_host_name} \ + "${ECHO} \"host all ${USER} ${CIDR_MASTER_IP} trust\" >> ${master_data_directory}/${PG_HBA}" + fi + + for segment_host_name in `cat ${GPHOME}/etc/slaves`; do + ${SSH} -o 'StrictHostKeyChecking no' ${hawqUser}@${segment_host_name} \ + "if [ -e ${segment_data_directory}/${PG_HBA} ]; then ${ECHO} \"host all all ${CIDR_MASTER_IP} trust\" >> ${segment_data_directory}/${PG_HBA}; fi" + done + + done } update_segment_pg_hba(){ @@ -238,7 +254,7 @@ update_segment_pg_hba(){ CIDR_MASTER_IP=$(GET_CIDRADDR ${ip_address}) CHK_COUNT=`${GREP} -c ${CIDR_MASTER_IP} ${hawq_data_directory}/${PG_HBA}` if [ "$CHK_COUNT" -eq "0" ];then - ${ECHO} "host all ${USER} ${CIDR_MASTER_IP} trust" >> ${hawq_data_directory}/${PG_HBA} + ${ECHO} "host all ${USER} ${CIDR_MASTER_IP} trust" >> ${hawq_data_directory}/${PG_HBA} fi done } @@ -352,6 +368,9 @@ standby_init() { exit 1 fi + LOG_MSG "[INFO]:-Update pg_hba configuration" + update_standby_pg_hba + ${MKDIR} -p ${master_data_directory}/pg_log | tee -a ${STANDBY_LOG_FILE} STANDBY_IP_ADDRESSES=`${SSH} -o 'StrictHostKeyChecking no' ${hawqUser}@${master_host_name} \
