GaussDB T 备份工具GaussRoach.py 报错:NoneType object has no attribute
【摘要】 华为GaussDB T数据库备份管理工具python GaussRoach.py AttributeError: 'NoneType' object has no attribute 'endswith',Python 2.7 调用posixpath.py 在对路径进行拼接的时候,如果发现有些路径为空,就出现了这个报错。
问题描述
运行华为GaussDB T 备份工具Roach时报错如下:
[omm@pr7 roach]$ python GaussRoach.py -h Traceback (most recent call last): File "GaussRoach.py", line 27, in <module> import util.GSroachCommon as RoachCommon File "/opt/software/roach/util/GSroachCommon.py", line 23, in <module> from util.GSroachConfig import RConfig,ClusterStatus File "/opt/software/roach/util/GSroachConfig.py", line 13, in <module> ROACH_INI = os.path.join(ROACH_HOME,"conf","roach.ini") File "/usr/lib64/python2.7/posixpath.py", line 77, in join elif path == '' or path.endswith('/'): AttributeError: 'NoneType' object has no attribute 'endswith'[omm@pr7 roach]$ python GaussRoach.py -h Traceback (most recent call last): File "GaussRoach.py", line 27, in <module> import util.GSroachCommon as RoachCommon File "/opt/software/roach/util/GSroachCommon.py", line 23, in <module> from util.GSroachConfig import RConfig,ClusterStatus File "/opt/software/roach/util/GSroachConfig.py", line 15, in <module> g_logger = GaussLog(os.path.join(log_path,DEFAULT_LOG_PATH,LOG_FILE_NAME)) File "/usr/lib64/python2.7/posixpath.py", line 77, in join elif path == '' or path.endswith('/'): AttributeError: 'NoneType' object has no attribute 'endswith'
请问如何解决?
专家解答
查看/opt/software/roach/util/GSroachConfig.py相关行代码如下:
log_path = DefaultValue.getPathFileOfENV("GAUSSLOG") ROACH_INI = os.path.join(ROACH_HOME,"conf","roach.ini") g_logger = GaussLog(os.path.join(log_path,DEFAULT_LOG_PATH,LOG_FILE_NAME))
这个问题是gaussdb脚本和Python版本不兼容的问题,Python 2.7 调用posixpath.py 在对路径进行拼接的时候,如果发现有些路径为空,就出现了这个报错。
所以根据以上至少需要设置GAUSSLOG和ROACH_HOME两个环境变量,就可以正常打开了。
[omm@pr7 roach]$ export ROACH_HOME=/opt/software/roach [omm@pr7 roach]$ export GAUSSLOG=/opt/software/roach/log[omm@pr7 roach]$ python GaussRoach.py -h [GAUSS-51800] : The environmental variable GAUSSHOME is empty.
另外需要设置GAUSSHOME环境变量即可正常使用。
[omm@pr7 roach]$ export GAUSSHOME=/opt/gaussdb/app [omm@pr7 roach]$ python GaussRoach.py -h GaussRoach.py is a utility to backup GaussDB100 to NBU/disk and restore GaussDB100 from NBU/disk. Usage: python GaussRoach.py -h | --help python GaussRoach.py -v | --version python GaussRoach.py -t start python GaussRoach.py -t backup [options] python GaussRoach.py -t restore [options] python GaussRoach.py -t stop python GaussRoach.py -t delete [options] python GaussRoach.py -t show [options] python GaussRoach.py -t validate [options] Common options: -t The step of GaussRoach, include config, clean and start,backup,restore,delete,stop -h --help Show this help, then exit -v --version Display the current roach version. --master-port <master port> The port in which master roach should be started. --media-type <media type> Mention type of media either disk or NBU --media-destination <media destination> The path or policy that should be used for backup/restore as per media-type. --metadata-destination <path-name> The path where the metadata file is to be kept in backup --group backup,restore,start database group in SingleService --nbu-policy <nbu policy> The NBU policy that should be used for backup/restore. --nbu-schedule <nbu schedule> The NBU schedule that should be used for backup/restore. Options for backup --compression-level The compression level that should be used for backup. --compression-mode The compression mode that should be used for backup. --archivelog Backup archive log --prior-backup-key Previous Full Backup key to be considered as the base for Incremental Backup Options for Restore --backup-key <backup key> The key for restoring. --clean For cluster restore,performs clean up activity internally. --restore-new-cluster Restore data to new cluster --archivelog Restore archive log --restore-target-time Time(<=) to be used for restore, format '<YYYY-MM-DD HH:MM:SS>'Options for Show --all-backups Show complete backup catalogue information. Default action if no option given. --backup-key <backup_key> Show restore path upto a given backup key. Options for Validate --backup-key <backup key> The key for validate. Options for Delete --cascade To delete all descendant backups of the provided backup key. ### Refer user manual for more details ###
转自墨天轮
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)