示例#1
0
        elif (key == "-l"):
            logFile = os.path.abspath(value)
        elif(key == "-i"):
            if (value.isdigit()):
                instanceIds.append(int(value))
            else:
                GaussLog.exitWithError("Parameter invalid. -i %s is not digit." % value)

    # check if user exist and is the right user
    PlatformCommand.checkUser(g_clusterUser)

    #check log dir
    if (logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "", "")

    #Init logger
    global g_logger
    g_logger = GaussLog(logFile, "CheckConfig")
    try:
        checker = CheckNodeEnv(cooParams, dataParams, instanceIds)
        checker.run()

        g_logger.log("Check config on node[%s] successfully!" % socket.gethostname())
        g_logger.closeLog()
        sys.exit(0)
    except Exception, e:
        g_logger.logExit(str(e))

if __name__ == '__main__':
    main()
示例#2
0
    # check if user exist and is the right user
    if (g_clusterUser == ""):
        GaussLog.exitWithError("Parameter input error, need '-U' parameter.")     
    PlatformCommand.checkUser(g_clusterUser)
        
    if (confType not in [ConfigInstance.CONFIG_ALL_FILE, ConfigInstance.CONFIG_GS_FILE, ConfigInstance.CONFIG_PG_FILE]):
        GaussLog.exitWithError("Unknown config type: %s" % confType)
        
    if (logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "")

    if (alarm_component == ""):
        alarm_component = DefaultValue.ALARM_COMPONENT_PATH

    # Init logger
    global g_logger
    g_logger = GaussLog(logFile, "ConfigInstance")
    try:
        configer = ConfigInstance(cooParams, dataParams, confType, gsPath, alarm_component)
        configer.run()
        
        g_logger.log("Config all instances on node[%s] successfully!" % socket.gethostname())
        g_logger.closeLog()
        sys.exit(0)
    except Exception, e:
        g_logger.logExit(str(e))

if __name__ == '__main__':
    main()
示例#3
0
        raise Exception("There is no coordinator to connect!")
    ip = connList[0][0]
    port = connList[0][1]
    
    sql = "select case (select pgxc_lock_for_backup()) when true then (select pg_sleep(%d)) end;" % time_out
    cmd = "gsql -h %s -p %d postgres -X -c \"%s\"" % (ip, port, sql)
    cmd = "su - %s -c '%s'" % (user, cmd)
    sqlThread = CommandThread(cmd)
    sqlThread.start()
    time.sleep(5)
    while True:
        td = endTime - datetime.now()
        leftSeconds = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
        if (leftSeconds <= 0):
            if (sqlThread.isAlive()):
                g_logger.log("Timeout!Release the cluster!")
                g_logger.closeLog()
                sys.exit(0)
            
        if (not sqlThread.isAlive()):
            if (sqlThread.cmdStauts != 0):
                g_logger.logExit("Lock cluster failed!Output: %s" % sqlThread.cmdOutput)
            else:
                g_logger.log("Execute SQL finished!Release the cluster!")
                g_logger.closeLog()
                sys.exit(0)
        
        g_logger.log("Thread is still alive!Left seconds[%s]" % leftSeconds)
        time.sleep(10)
        
if __name__ == '__main__':
示例#4
0
            logFile = value
        else:
            GaussLog.exitWithError("Parameter input error, unknown options %s." % key)

    # check if user exist and is the right user
    if(g_clusterUser == ""):
        GaussLog.exitWithError("Parameter input error, need '-U' parameter.")
    PlatformCommand.checkUser(g_clusterUser)

    if (logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "")
          
    if (not os.path.isabs(logFile)):
        GaussLog.exitWithError("Parameter input error, log file need absolute path.")

    # Init logger
    global g_logger
    g_logger = GaussLog(logFile, "UpgradeConfig")
    try:    
        upgrader = UpgradeConfiguration()
        upgrader.run()
        
        g_logger.log("Upgrade config on node[%s] successfully!" % socket.gethostname())
        g_logger.closeLog()
        sys.exit(0)
    except Exception, e:
        g_logger.logExit(str(e))

if __name__ == '__main__':
    main()
示例#5
0
        elif (key == "-U"):
            g_clusterUser = value
        elif (key == "-P"):
            dbInitParams.append(value)
        elif (key == "-G"):
            gtmInitParams.append(value)
        elif (key == "-l"):
            logFile = os.path.abspath(value)

    # check if user exist and is the right user
    PlatformCommand.checkUser(g_clusterUser)
        
    if (logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "")

    # Init logger
    global g_logger
    g_logger = GaussLog(logFile, "InitInstance")
    try:
        dbInit = initDbNode(dbInitParams, gtmInitParams)
        dbInit.run()
        
        g_logger.log("Init instances on node[%s] successfully!" % socket.gethostname())
        g_logger.closeLog()
        sys.exit(0)
    except Exception, e:
        g_logger.logExit(str(e))

if __name__ == '__main__':
    main()
    
示例#6
0
        GaussLog.exitWithError("Parameter input error, need '-U' parameter.")
    PlatformCommand.checkUser(g_clusterUser)

    # check log file
    if (logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "")
    if (not os.path.isabs(logFile)):
        GaussLog.exitWithError("Parameter input error, log path need absolute path.")
    
    if (restorePara == False and restoreBin == False):
        GaussLog.exitWithError("Parameter input error, need '-p' or '-b' parameter.")

    if (restoreDir == ""):
        GaussLog.exitWithError("Parameter input error, need '-P' parameter.")
    
    global g_logger
    g_logger = GaussLog(logFile, "LocalRestore")
    g_logger.log("Local restore begin...")
    try:
        LocalRestorer = LocalRestore(g_clusterUser, restoreDir, restorePara, restoreBin)
        LocalRestorer.run()
        
        g_logger.log("Local restore succeed.")
        g_logger.closeLog()
        sys.exit(0)
    except Exception, e:
        GaussLog.exitWithError("Local restore Failed! %s" % str(e))

if __name__ == '__main__':   
    main()