GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz

  • I8_292224
    了解作者
  • 7.7MB
    文件大小
  • gz
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 9
    下载次数
  • 2022-04-03 02:14
    上传日期
guassdb100在redhat上安装包,单机部署的包,安装步骤请看我的文中介绍,经过大量实验搭建总结出来的文档
GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
  • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit
  • upgrade.py
    188.7KB
  • GaussDB_100_1.0.1-RUN-REDHAT-64bit.sha256
    65B
  • GaussDB_100_1.0.1-RUN-REDHAT-64bit.tar.gz
    7.7MB
  • install.py
    81.2KB
  • sshexkey.py
    7.5KB
  • funclib.py
    24.7KB
内容介绍
#!/usr/bin/env python # -*- coding: utf-8 -*- # Perform hot backups of GaussDB100 databases. # Copyright © Huawei Technologies Co., Ltd. 2010-2018. All rights reserved. import sys try: import os import time import re import getopt import pickle import getpass import subprocess import socket import platform import tarfile sys.path.append(os.path.split(os.path.realpath(__file__))[0]) sys.dont_write_bytecode = True from funclib import CommandTool, exec_popen from funclib import get_error_msg, Execution, SshToolException, get_abs_path from funclib import CommonValue except Exception as err: sys.exit("Upgrade Failed: Unable to import module: %s." % str(err)) # support the oldest python versions is 2.4.2 PYTHON242 = "2.4.2" PYTHON25 = "2.5" # check sha256 sum need hashlib since python 2.5 # and lib sha256 between 2.4.2 to 2.5 try: gPyVersion = platform.python_version() PYBIN = "python" if gPyVersion[0] == "3": _pybin = get_abs_path("python3") if _pybin: PYBIN = "python3" if(gPyVersion >= PYTHON242 and gPyVersion < PYTHON25): import sha256 elif(gPyVersion >= PYTHON25): import hashlib else: print(("Upgrade Failed: This install script can not support python version : %s" % gPyVersion)) sys.exit(1) except ImportError as err: sys.exit("Upgrade Failed: Unable to import module: %s." % str(err)) UPGRADE_MODE_HA = "ha" UPGRADE_MODE_SINGLE = "single" STEP_PRECHECK = "upgrade_precheck" STEP_RUN = "upgrade_run" STEP_ROLLBACK = "upgrade_rollback" STEP_ROLLBACK_CHECK = "upgrade_rollback_check" STEP_CLEAN = "upgrade_clean" STEP_SUCCESS = "SUCCESS" STEP_FAILED = "FAILED" STEP_BEGIN = "BEGIN" SUBSTEP_PRECHECK_DISTRIBUTE_PKG="distribute-pkg" SUBSTEP_PRECHECK_SSHEXKEY = "sshexkey" SUBSTEP_PRECHECK_PRETEST = "pretest" SUBSTEP_PRECHECK_CHECK_NODE = "check-none" SUBSTEP_PRECHECK_CHECK_VER = "check-version" UPGRADE_TYPE_BINARY = 'binary' UPGRADE_TYPE_SYSTABLE = 'systable' def normPath(path): ''' return path that expand ~ absolution path real path ''' p = os.path.expanduser(path) p = os.path.abspath(p) p = os.path.realpath(p) return p def check_illegal_char(check_info): ''' check the path if legal ''' # the list of invalid characters VALUE_CHECK_LIST = ["|", ";", "&", "$", "<", ">", "`", "\\", "'", "\"", "{", "}", "(", ")", "[", "]", "~", "*", "?", "!", "\n", " "] for ch in VALUE_CHECK_LIST: if check_info.find(ch)>= 0: raise Exception("The %s contains invalid characters: '%s'" % (check_info, ch)) def checkLegalityOfPath(path): ''' check the path if legal :param path: :return: ''' check_illegal_char(path) def getSha256obj(): ''' return sha256 object ''' if(gPyVersion >= PYTHON242 and gPyVersion < PYTHON25): sha256Obj = sha256.new() elif(gPyVersion >= PYTHON25): sha256Obj = hashlib.sha256() if(sha256Obj == None): raise Exception("check integrality of run file failed, can not get verification Obj.") return sha256Obj def calcSha256Sum(targetFile): ''' calculate sha256 sum ''' sha256Obj = getSha256obj() with open(targetFile, 'rb') as fp: strRead = "" while True: strRead = fp.read(8096) if(not strRead): break sha256Obj.update(strRead) strSHA256 = sha256Obj.hexdigest() return strSHA256 def checkSHA256(checkFile, sha256sum): ''' check file's sha256 sum return True if matched ''' if(checkFile == ""): raise Exception("Can not find run file.") if not sha256sum: raise Exception("Can not recognize sha256 sum.") f = None sha256Obj = None strSHA256 = "" isSameSHA256=False try: with open(checkFile, "rb") as f: if(gPyVersion >= PYTHON242 and gPyVersion < PYTHON25): sha256Obj = sha256.new() elif(gPyVersion >= PYTHON25): sha256Obj = hashlib.sha256() if(sha256Obj == None): raise Exception("check integrality of run file failed, can not get verification Obj.") strRead = "" while True: strRead = f.read(8096) if(not strRead): break sha256Obj.update(strRead) strSHA256 = sha256Obj.hexdigest() if(strSHA256 == sha256sum): isSameSHA256 = True else: isSameSHA256 = False except Exception as ex: raise Exception("Check integrality of run file except: %s" % str(ex)) return isSameSHA256 def execShellCmd(cmd, envSetting, time_out=0, stdin_ex=None): ''' execute shell command cmd -- the command ''' status ,outputs = execShellCmdEx(cmd, envSetting, time_out, stdin_ex) output = "%s%s" % (outputs[0], outputs[1]) if status != 0: raise Exception("Error:\n%s" % output) return status, output def execShellCmdEx(cmd, envSetting, time_out=0, stdin_ex=None): ''' execute shell command cmd -- the command ''' outputs = [] extra_info = "\nError: sysdba login is disabled, please specify -P parameter to input password, refer to --help." if envSetting: cmd = "%s && %s" % (envSetting, cmd) if time_out: ##################################################### # when passed the time_out parameter # means this call will wait at most time_out seconds # for this case # do not call the communicate interface of Popen # it will wait util subprocess exit # use poll of Popen to detect whether the subprocess finished # if poll returned not None # the subprocess has finished # else # wait 1 seconds and continue ######################################################## p = subprocess.Popen(['bash', '-c', cmd], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if stdin_ex: stdin_ex = '%s\n' % stdin_ex if gPyVersion[0] == "3": stdin_ex = stdin_ex.encode() p.stdin.write(stdin_ex) p.stdin.flush() while time_out: if p.poll() != None: status = p.returncode outputs.append(p.stdout.read().strip()) outputs.append(p.stderr.read().strip()) break else: time.sleep(1) time_out -= 1 else: p.kill() raise Exception("Timeout when executing shell command!" ) else: p = subprocess.Popen(['bash', '-c', cmd], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if stdin_ex: stdin_ex = '%s\n' % stdin_ex if gPyVersion[0] == "3": stdin_ex = stdin_ex.encode() p.stdin.write(stdin_ex) p.stdin.flush() (stdoutdata, stderrdata) = p.communicate() status = p.returncode outputs.append(stdoutdata) outputs.append(stderrdata) if gPyVersion[0] == "3": # python3's Popen returned Byte # python2's Popen returned str # convert to str if python3 outputs[0] = outputs[0].decode() outputs[1] = outputs[1].decode() if cmd.find('zsql') >= 0 and outputs[0].find('login as sysdba is prohibited') >= 0: outputs[0] = "%s%s" % (outputs[0], extra_info) return status, outputs class VersionInfo(object): ''' Database version info. parse verison info, compare version info. ''' VERSION_TYPE_VRC = "vrc" VERSION_TYPE_DOT = "dot" def __init__(self, version_str="", version_file="", logger=None): ''' :param version: ''' # eg:
评论
    相关推荐