升级 SAP HANA 中的地理数据库

在 Standard 或 Advanced 许可等级下可用。

升级企业级地理数据库的目标是更新地理数据库系统表、存储过程、类型和函数,以利用新功能和漏洞修复。 如果您使用的数据库版本在所用的 ArcGIS 客户端中不再受支持,则可能还需要对数据库进行升级。

安装新版本的 ArcGIS ProArcGIS Server,或将补丁包、修补程序或热修复程序应用到现有安装并升级地理数据库。

注:

即使不升级地理数据库,您所使用的数据库版本可能在当前的 ArcGIS 软件版本中也不再受支持。 使用前请务必查看系统要求,以确保所用数据库版本仍受支持。 如果数据库版本不再受支持,您可能需要升级地理数据库。 执行升级操作的间隔越长,升级过程所需的操作就越多。

如果使用 ArcGIS Pro 3.2 升级地理数据库,则已升级的地理数据库版本为 11.2.0。

完成升级前的必需步骤,然后使用升级地理数据库地理处理工具Python 脚本升级地理数据库。

在升级之前

在对任何企业级系统(包括地理数据库)执行升级之前,必须事先进行规划。 在开发或测试服务器上测试新版本,以确保其能够与所有客户端应用程序配合使用。

当您确定新系统可如预期运行时,即可安排升级;请确保有必要员工可以执行升级,并且他们具有完成分配的任务所需的权限。

不提供将地理数据库降级到先前版本的正式机制。 如果升级到较新版本后需要降级该地理数据库,则必须从备份文件中恢复旧数据库。

以下是升级地理数据库之前需要完成的步骤清单:

  1. 请参阅 ArcGIS 的 SAP HANA 数据库要求以确认 Esri 支持要使用的 SAP HANA 和 ArcGIS 版本组合。

    如果要升级到的 ArcGIS 版本支持 SAP HANA 数据库版本,则可以直接从 10.8.x 或更高版本地理数据库进行升级。

  2. 确认地理数据库是否可以升级。 要执行此操作,需将要移动到的 ArcGIS ProArcGIS Server 版本安装到一台计算机上。
    • 要在 ArcGIS Pro 中进行确认,请在目录窗格中连接到数据库并打开数据库属性升级状态下方随即显示一条消息,指示是否能够进行升级。
    • 要在 ArcGIS Server 中进行确认,请使用 ArcPy Describe 函数确定是否能够升级地理数据库。 以下为创建地理数据库连接和检查地理数据库是否可升级的示例。
      # Open Python.
      cd /arcgis/server/tools
      ./python
      
      # Create a connection to the geodatabase. You must connect as the sde user.
      arcpy.CreateDatabaseConnection_management("/usr/tmp/",
                                                "egdb_connection.sde",
                                                "SAP HANA",
                                                sys.argv[1],
                                                "DATABASE_AUTH",
                                                "sde",
                                                sys.argv[2],
                                                "SAVE_USERNAME")
      
      # Import ArcPy and check the geodatabase release.
      import arcpy
      
      isCurrent = arcpy.Describe('/usr/tmp/egdb_connection.sde').currentRelease
      
      print isCurrent
      如果返回 False,则可升级地理数据库。 请继续进行其他步骤。 如果返回 True,则无需升级。 请勿继续执行后续步骤。
  3. 请确认 sde 用户具有数据库的适当权限
  4. 创建数据库的备份。
  5. 移除所有您已添加到 ArcGIS 外部的地理数据库系统表中的自定义功能。

    升级程序无法兼容对系统表的自定义修改。 如果类似的自定义修改禁止更改系统表方案,升级将失败。

  6. 请确认没有其他用户连接到正在升级的地理数据库。

您现在可以升级地理数据库。

升级地理数据

可以使用 ArcGIS Pro 中的升级地理数据库工具或使用在 ArcGIS ProArcGIS Server 计算机上运行的 Python 脚本升级地理数据库。

使用升级地理数据库工具

可通过以下任一方式打开升级地理数据库地理处理工具:

  • 数据管理工具箱中的地理数据库管理工具集
  • ArcGIS Pro数据库属性对话框内常规选项卡上的运行升级按钮

如果打开了数据库属性中的工具,则将使用地理数据库连接信息预填充输入地理数据库文本框。

Esri 建议选中先行检查升级地理数据库选项。 这样,在继续地理数据库升级之前,该工具将确认是否满足升级的先决条件。

您必须以 sde 用户身份连接到地理数据库才能运行先决条件检查和升级地理数据库。

先决条件检查用于检测连接到地理数据库的其他活动连接,确定您是否以 sde 用户身份连接,并确认 sde 用户是否有足够的权限升级地理数据库。 如果未满足任意先决条件,则工具将终止。 再次运行升级过程之前,必须修正所有问题。

此检查的结果在地理处理工具对话框中报告。 如果检查(或升级)失败,其结果还将写入 c:\Users\<user name>\AppData\Local\ESRI\<ArcGIS product> 文件夹的 GDBUpgrade.log 文件中。

如果通过了所有检查,该工具将继续进行升级。 先行检查和升级的状态将在地理处理工具进度对话框中显示。 如果升级失败,则信息将写入 GDBUpgrade.log 文件。 其他信息将写入系统 TEMP 目录的 sde_setup.log 文件中。

运行脚本

要使用 Python 脚本升级地理数据库,请复制以下代码,将其粘贴到文本文件中并保存。 然后,您可以在命令行处使用位置特定的信息运行脚本。

"""
Name: upgrade_gdb_for_sap_hana.py
Type upgrade_gdb_for_sap_hana.py -h or upgrade_gdb_sap_hana.py --help for usage
Author: Esri
"""

# Import system modules
import arcpy, os, optparse, sys


# Define usage and version
parser = optparse.OptionParser(usage = "usage: %prog [Options]", version="%prog 1.0 for " + arcpy.GetInstallInfo()['Version'] )

#Define help and options
parser.add_option ("-i", dest="data_source", type="string", default="", help="SAP HANA ODBC data source name")
parser.add_option ("-u", dest="User", type="string", default="", help="Geodatabase administrator user name")
parser.add_option ("-p", dest="Password", type="string", default="", help="Geodatabase administrator password")
parser.add_option ("--upgrade", dest="Upgrade", type="choice", choices=['TRUE', 'FALSE'], default="FALSE", help="Upgrade Options (case-sensitive):  TRUE=Perform Pre-requisite check and upgrade geodatabase, FALSE=Perform Pre-requisite check only.  Default=FALSE")                   


# Check if value entered for option
try:
	(options, args) = parser.parse_args()

	
#Check if no system arguments (options) entered
	if len(sys.argv) == 1:
		print ("%s: error: %s\n" % (sys.argv[0], "No command options given"))
		parser.print_help()
		sys.exit(3)

	#Usage parameters for spatial database connection to upgrade
	account_authentication = "DATABASE_AUTH"
	username = options.User.lower() 
	password = options.Password	
	do_upgrade = options.Upgrade
	database = ""
	database_type = "SAP HANA"
	instance = options.data_source
	
	
	# Get the current product license
	product_license=arcpy.ProductInfo()
	
	# Checks required license level to upgrade
	if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
		print ("\n" + product_license + " license found!" + "  Enterprise geodatabase upgrade requires an ArcGIS for Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS for Server license.")
		sys.exit("Re-authorize ArcGIS before upgrading.")
	else:
		print ("\n" + product_license + " license available!  Continuing to upgrade...")
		arcpy.AddMessage("+++++++++")
	
	# Local variables
	Conn_File_NameT = instance + "_" + database + "_" + username     
	
	if os.environ.get("TEMP") == None:
		temp = "c:\\temp"	
	else:
		temp = os.environ.get("TEMP")
	
	if os.environ.get("TMP") == None:
		temp = "/usr/tmp"		
	else:
		temp = os.environ.get("TMP")  
	
	Connection_File_Name = Conn_File_NameT + ".sde"
	Connection_File_Name_full_path = temp + os.sep + Conn_File_NameT + ".sde"
	
	# Check for the .sde file and delete it if present
	arcpy.env.overwriteOutput=True
	if os.path.exists(Connection_File_Name_full_path):
		os.remove(Connection_File_Name_full_path)
	
	print ("\nCreating Database Connection File...\n")	
	# Process: Create Database Connection File...
	# Usage:  out_file_location, out_file_name, DBMS_TYPE, instnace, database, account_authentication, username, password, save_username_password(must be true)
	arcpy.management.CreateDatabaseConnection(out_folder_path=temp, out_name=Connection_File_Name, database_platform=database_type, instance=instance, database=database, account_authentication=account_authentication, username=username, password=password, save_user_pass="TRUE")
        			

	# Process: Upgrade geodatabase...
	try:
		if do_upgrade.lower() == "true":
			print ("Upgrading Geodatabase...\n")
			arcpy.management.UpgradeGDB(input_workspace=Connection_File_Name_full_path, input_prerequisite_check="PREREQUISITE_CHECK", input_upgradegdb_check="UPGRADE")
			for i in range(arcpy.GetMessageCount()):
				arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
	
		else:
			print ("Running Pre-Requisite Check...\n")
			arcpy.management.UpgradeGDB(input_workspace=Connection_File_Name_full_path, input_prerequisite_check="PREREQUISITE_CHECK", input_upgradegdb_check="NO_UPGRADE")
			for i in range(arcpy.GetMessageCount()):
				arcpy.AddReturnMessage(i)
			arcpy.AddMessage("+++++++++\n")
		
	        
	except:
		for i in range(arcpy.GetMessageCount()):
			arcpy.AddReturnMessage(i)
		
	if os.path.exists(Connection_File_Name_full_path):
		os.remove(Connection_File_Name_full_path)
	
#Check if no value entered for option	
except SystemExit as e:
	if e.code == 2:
		parser.usage = ""
		print ("\n")
		parser.print_help()
		parser.exit(2)

例如,如果将文本文件另存为 gdbupgrade,您的 SAP HANA 数据源命名为 mydata,您的 sde 密码为 mysdepassword,则请在命令提示符处输入以下内容:

gdbupgrade --DBMS SAP HANA -i mydata -u sde -p mysdepassword --upgrade TRUE