在 Oracle 中创建地理数据库

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

要在 Oracle 数据库中创建地理数据库,请从 ArcGIS 客户端运行地理处理工具或 Python 脚本。首先阅读先决条件,然后按照适合实际情况的说明进行操作。

注:

从 ArcGIS 10.7 和 ArcGIS Pro 2.3 开始,您无法在 Oracle 中创建用户方案地理数据库。

先决条件

要在 Oracle 中创建地理数据库,需要执行以下操作:

  1. 请确认您想使用的 ArcGIS、Oracle 和操作系统组合相互兼容
  2. 获取连接用于存储地理数据库的 Oracle 版本所需的 Oracle 客户端。
  3. 获取 ArcGIS Server 密钥代码文件,然后将其放置到可从用于创建地理数据库的 ArcGIS 客户端访问的位置。
  4. 确定将创建地理数据库的人员(这会影响创建数据库的人员),以及运行哪个工具来创建地理数据库。按照适合实际情况的说明进行操作:

您是数据库和地理数据库管理员

如果您执行数据库管理员和地理数据库管理员的角色,并知道这两个登录的密码,则可以使用创建企业级地理数据库地理处理工具或 Python 脚本在 Oracle 中创建地理数据库。

创建企业级地理数据库工具可令您轻松设置地理数据库,因为此工具可创建 sde 用户、方案和表空间,并授予您 sde 用户的所需权限。为实现此操作,该工具使用以下默认设置:

  • 创建名为 sde 的数据库用户
  • Oracle 的默认位置中创建 400 MB 的表空间,并将其设置为 sde 用户的表空间
  • 授予 sde 用户创建和升级地理数据库、删除数据库连接和使用 Oracle Data Pump 导入数据的权限(不适用于 Oracle 11g)
  • 授予创建地理数据库所需的包权限
  • 创建地理数据库

有关所需权限的详细信息,请参阅 Oracle 中地理数据库的权限

运行工具或脚本创建地理数据库前,您必须设置 Oracle

安装并配置 Oracle

创建地理数据库前,必须安装和配置 Oracle。配置 Oracle 实例的方式取决于您的组织的特定需求。有关安装和配置信息,请参考 Oracle 文档。

创建地理数据库之前,请查看 ArcGIS Oracle 系统要求,以确保要使用的 Oracle、ArcGIS 和硬件组合能够得到支持。

如果您希望能够进行以下任意操作,则还需要配置 Oracle extproc,以访问 Esri ST 库:

安装和配置 Oracle 后,安装 ArcGIS 和 Oracle 客户端。

安装并配置客户端

可以安装 ArcGIS DesktopDesktop StandardDesktop Advanced)、ArcGIS Engine Geodatabase UpdateArcGIS Server(企业版),然后运行脚本来创建地理数据库。如果您想要运行创建企业级地理数据库地理处理工具,而非脚本,请安装 ArcGIS Desktop

注:

您需要一个 ArcGIS Server(企业版)密钥代码文件,以便在下一部分中授权地理数据库。即使不在 ArcGIS Server 计算机上运行 Python 脚本来创建地理数据库,也必须安装和授权 ArcGIS Server 才能获取密钥代码文件。可能需要将 ArcGIS Server 中的密钥代码文件复制到可使用创建企业级地理数据库地理处理工具访问的位置。

在大多数情况下,ArcGIS 客户端将安装在不同于 Oracle 的计算机上。因此,ArcGIS 客户端计算机上必须具有受支持的 Oracle 客户端,才能连接到 Oracle 实例。请参阅 Oracle 文档,确定应安装哪个 Oracle 客户端版本才能连接到正在使用的 Oracle 版本,并获得安装和配置客户端的说明。

  1. 安装要用于创建地理数据库的 ArcGIS 客户端。

    遵循软件安装指南中提供的说明。

  2. 在 ArcGIS 客户端计算机上安装和配置 Oracle 客户端。

    如果从 32 位 ArcGIS 客户端(例如 ArcMap)进行连接,则必须安装 32 位 Oracle 客户端。即便将 ArcGIS 客户端应用程序安装到 64 位操作系统的计算机上并且数据库和服务器的操作系统均为 64 位,也是如此。如果从 64 位 ArcGIS 客户端(例如 ArcGIS ServerArcGIS Pro)进行连接,则必须安装 64 位 Oracle 客户端。

    可以从 Oracle 中获取 Oracle Instant、Runtime 或 Administrator Client。请参阅 Oracle 文档以获取安装说明。

  3. 设置操作系统的环境变量或用户配置文件,以添加安装 Oracle 客户端的目录的路径和名称。

    • Linux 上,设置 LD_LIBRARY_PATH 环境变量。

      可以从 Oracle 中获取 Oracle Instant、Runtime 或 Administrator Client。请参阅 Oracle 文档以获取安装说明。

    • Microsoft Windows 上,设置 PATH 环境变量。如果将 ArcMapArcGIS ProArcGIS Server 安装在同一台 Windows 计算机上,则请将 PATH 变量设置为先读取 64 位客户端,后读取 32 位客户端。例如,如果 32 位 Oracle 客户端安装在 c:\Program Files (x86)\Oracle 下,64 位 Oracle Instant Client 安装在 c:\Program Files\Oracle 下,则将以下内容添加到 PATH 变量值的开始位置:C:\Program Files\Oracle;C:\Program Files (x86)\Oracle;

  4. 如果已经运行 ArcGIS 客户端,请重新启动它以识别 Oracle 客户端和新环境变量。
  5. 可使用 Easy Connect 字符串从 ArcGIS 连接到 Oracle。但是,必须将 Oracle 数据库配置为允许使用 Easy Connect 字符串。如果已安装完整的 Oracle 客户端,但想使用 Easy Connect 语法进行连接,请确保客户端上的 sqlnet.ora 文件已组态为允许使用 Easy Connect,且 Oracle 服务器已组态为允许 Easy Connect 语法。有关进一步的说明,请参阅 Oracle 文档。

现在,您可以创建地理数据库。

创建地理数据库

您可以从 ArcGIS DesktopDesktop StandardDesktop Advanced)运行创建企业级地理数据库工具,或从 ArcGIS DesktopArcGIS ServerArcGIS Engine 客户端运行 Python 脚本,来创建 sde 用户、方案、表空间和地理数据库。

运行创建企业级地理数据库工具

如果您有权访问 ArcGIS Desktop,则可运行地理处理工具来创建地理数据库。

请遵照以下步骤使用 ArcMap 中的创建企业级地理数据库工具创建地理数据库:

  1. 启动 ArcGIS Desktop 客户端。
  2. 打开创建企业级地理数据库工具。

    您可以搜索或浏览到此工具,它位于“数据管理”工具箱的“地理数据库管理”工具集中。

  3. 数据库平台下拉列表中选择 Oracle
  4. 提供连接到 Oracle 实例所需的信息。
    • 如果已经将 Oracle 客户端配置为使用 TNS 网络别名,则请在实例文本框中输入 Net 服务别名。
    • 如果尚未配置 Oracle 客户端的网络别名,并且 Oracle 数据库和客户端均配置为使用 Easy Connect 字符串,则在实例文本框中提供 Oracle Easy Connect 字符串。
  5. 必须以数据库管理员身份连接到数据库才能创建地理数据库管理员和表空间。因此,数据库管理员文本框中应填充 sys 用户名。
  6. 数据库管理员密码文本框中输入 sys 用户的密码。
  7. 地理数据库管理员文本框中输入 sde

    如果数据库中不存在 sde 用户,则该工具会创建此用户并授予其创建地理数据库所需的权限。如果用户已存在,则会向其授予所需的权限。

  8. 地理数据库管理员密码文本框中输入 sde 用户的密码。

    如果数据库中已存在 sde 用户,请确保为现有用户输入正确的密码;此工具不会更改密码。如果创建的是 sde 用户,则输入的密码会在创建 sde 用户时使用。

  9. 为 sde 用户指定表空间。
    • 如果拥有可用于地理数据库资料档案库的预配置表空间,则可在表空间名称文本框中输入其名称。
    • 如果想要此工具为您创建表空间,可在表空间名称文本框中输入有效的名称,该工具会在 Oracle 默认位置创建一个 400 MB 的表空间。如果不输入表空间名称,则会创建 SDE_TBS 表空间,并将其设置为 sde 用户的默认表空间。
  10. 要指定授权文件,请浏览到在授权 ArcGIS Server Enterprise 时创建的密钥代码文件,并选择该文件。

    将此文件写入 Windows 服务器的 \\Program Files\ESRI\License<release#>\sysgen 文件夹和 Linux 服务器的 /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release#>/sysgen 中。将该密钥代码文件复制到可使用该工具访问的位置。如果尚未执行此操作,则立即授权 ArcGIS Server 创建此文件。

  11. 单击确定ArcMapArcCatalog)或运行 (ArcGIS Pro)。

将在 Oracle 数据库中创建地理数据库。

将创建地理数据库的相关消息写入 sde_setup.log 文件,该文件是在为运行工具的计算机上的 %TEMP% 变量指定的目录中创建的。如果在创建地理数据库时出现任何问题,可查看此日志文件以解决这些问题。

接下来,如果未将 Oracle 数据库 open_cursors 参数设置为 300,请运行 sde.gdb_util.update_open_cursors 存储过程来同步 Oracle 数据库参数和地理数据库的设置

运行 Python 脚本

您可以通过复制、保存和运行此处提供的脚本在 ArcGIS DesktopDesktop StandardDesktop Advanced)、ArcGIS ServerArcGIS Runtime(具有 Geodatabase Update 扩展模块)中创建地理数据库。

  1. 在 ArcGIS 客户端计算机上创建文本文件,然后将以下脚本复制到该文件中。
    """
    Name: create_enterprise_gdb.py
    Description: Provide connection information to a DBMS instance and create an enterprise geodatabase.
    Type  create_enterprise_gdb.py -h or create_enterprise_gdb.py --help for usage
    """
    
    # Import system modules
    import arcpy
    import os
    import optparse
    import 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 ("--DBMS", dest="Database_type", type="choice", choices=['SQL_SERVER', 'ORACLE', 'POSTGRESQL', ''], default="", help="Type of enterprise DBMS:  SQL_SERVER, ORACLE, or POSTGRESQL.")                   
    parser.add_option ("-i", dest="Instance", type="string", default="", help="DBMS instance name")
    parser.add_option ("-D", dest="Database", type="string", default="none", help="Database name:  Do not specify for Oracle")
    parser.add_option ("--auth", dest="Account_authentication", type ="choice", choices=['DATABASE_AUTH', 'OPERATING_SYSTEM_AUTH'], default='DATABASE_AUTH', help="Authentication type options (case-sensitive):  DATABASE_AUTH, OPERATING_SYSTEM_AUTH.  Default=DATABASE_AUTH")
    parser.add_option ("-U", dest="Dbms_admin", type="string", default="", help="DBMS administrator user")
    parser.add_option ("-P", dest="Dbms_admin_pwd", type="string", default="", help="DBMS administrator password")
    parser.add_option ("--schema", dest="Schema_type", type="choice", choices=['SDE_SCHEMA', 'DBO_SCHEMA'], default="SDE_SCHEMA", help="Schema type  applies to geodatabases in SQL Server only. Type SDE_SCHEMA to create geodatabase in SDE schema or type DBO_SCHEMA to create geodatabase in DBO schema. Default=SDE_SCHEMA")
    parser.add_option ("-u", dest="Gdb_admin", type="string", default="", help="Geodatabase administrator user name; Must always be sde for PostgreSQL, sde-schema geodatabases in SQL Server, and sde geodatabase in Oracle")
    parser.add_option ("-p", dest="Gdb_admin_pwd", type="string", default="", help="Geodatabase administrator password")
    parser.add_option ("-t", dest="Tablespace", type="string", default="", help="Tablespace name; For PostgreSQL, type name of existing tablespace in which to store database. If no tablespace name specified, pg_default is used. For Oracle, type name of existing tablespace, or, if tablespace with specified name does not exist, it will be created and set as the default tablespace for the sde user. If no tablespace name is specified, SDE_TBS tablespace is created and set as sde user default. Tablespace name not supported for SQL Server.")
    parser.add_option ("-l", dest="Authorization_file", type="string", default="", help="Full path and name of authorization file; file created when ArcGIS Server Enterprise authorized, and stored in \\Program Files\ESRI\License<release#>\sysgen on Windows or /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release#>/sysgen on Linux")
    # 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
    	database_type = options.Database_type.upper()
    	instance = options.Instance
    	database = options.Database.lower()	
    	account_authentication = options.Account_authentication.upper()
    	dbms_admin = options.Dbms_admin
    	dbms_admin_pwd = options.Dbms_admin_pwd
    	schema_type = options.Schema_type.upper()
    	gdb_admin = options.Gdb_admin
    	gdb_admin_pwd = options.Gdb_admin_pwd	
    	tablespace = options.Tablespace
    	license = options.Authorization_file
    
    	
    	if( database_type ==""):	
    		print(" \n%s: error: \n%s\n" % (sys.argv[0], "DBMS type (--DBMS) must be specified."))
    		parser.print_help()
    		sys.exit(3)		
    		
    	if (license == ""):
    		print(" \n%s: error: \n%s\n" % (sys.argv[0], "Authorization file (-l) must be specified."))
    		parser.print_help()
    		sys.exit(3)			
    	
    	if(database_type == "SQL_SERVER"):
    		if(schema_type == "SDE_SCHEMA" and gdb_admin.lower() != "sde"):
    			print("\n%s: error: %s\n" % (sys.argv[0], "To create SDE schema on SQL Server, geodatabase administrator must be SDE."))
    			sys.exit(3)
    		if (schema_type == "DBO_SCHEMA" and gdb_admin != ""):
    			print("\nWarning: %s\n" % ("Ignoring geodatabase administrator specified when creating DBO schema..."))
    		if( account_authentication == "DATABASE_AUTH" and dbms_admin == ""):
    			print("\n%s: error: %s\n" % (sys.argv[0], "DBMS administrator must be specified with database authentication"))
    			sys.exit(3)
    		if( account_authentication == "OPERATING_SYSTEM_AUTH" and dbms_admin != ""):
    			print("\nWarning: %s\n" % ("Ignoring DBMS administrator specified when using operating system authentication..."))
    	else:
    		if (schema_type == "DBO_SCHEMA"):
    			print("\nWarning: %s %s, %s\n" % ("Only SDE schema is supported on", database_type, "switching to SDE schema..." ))
    			
    		if( gdb_admin.lower() == ""):
    			print("\n%s: error: %s\n" % (sys.argv[0], "Geodatabase administrator must be specified."))
    			sys.exit(3)
    
    		if( gdb_admin.lower() != "sde"):
    			if (database_type == "ORACLE"):
    				print("\nGeodatabase admin user is not SDE, creating user schema geodatabase on Oracle...\n")
    			else:
    				print("\n%s: error: %s for %s.\n" % (sys.argv[0], "Geodatabase administrator must be SDE", database_type))
    				sys.exit(3)
    			
    		if( dbms_admin == ""):
    			print("\n%s: error: %s\n" % (sys.argv[0], "DBMS administrator must be specified!"))
    			sys.exit(3)
    
    		if (account_authentication == "OPERATING_SYSTEM_AUTH"):
    			print("Warning: %s %s, %s\n" % ("Only database authentication is supported on", database_type, "switching to database authentication..." ))
    
    	# Get the current product license
    	product_license=arcpy.ProductInfo()
    	
    	
    	# Checks required license level
    	if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
    		print("\n" + product_license + " license found!" + " Creating an enterprise geodatabase requires an ArcGIS Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS Server license.")
    		sys.exit("Re-authorize ArcGIS before creating enterprise geodatabase.")
    	else:
    		print("\n" + product_license + " license available!  Continuing to create...")
    		arcpy.AddMessage("+++++++++")
    	
    	
    	try:
    		print("Creating enterprise geodatabase...\n")
    		arcpy.CreateEnterpriseGeodatabase_management(database_platform=database_type,instance_name=instance, database_name=database, account_authentication=account_authentication, database_admin=dbms_admin, database_admin_password=dbms_admin_pwd, sde_schema=schema_type, gdb_admin_name=gdb_admin, gdb_admin_password=gdb_admin_pwd, tablespace_name=tablespace, authorization_file=license)
    		for i in range(arcpy.GetMessageCount()):
    			arcpy.AddReturnMessage(i)
    		arcpy.AddMessage("+++++++++\n")
    	except:
    		for i in range(arcpy.GetMessageCount()):
    			arcpy.AddReturnMessage(i)
    			
    #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)
  2. .py 扩展名保存该文件。
  3. 运行脚本,同时提供特定于您的站点的选项和信息。

    在从 Linux 计算机上运行的以下示例中,针对 SID 为 orcl 的 Oracle 实例运行文件 create_gdb.py。该实例在服务器 gisprod 上运行。创建密码为 Tgdbst@rtsh3r3 的 sde 用户以及名为 sde 的表空间。默认 ArcGIS Server 位置中指定的密钥代码文件用于授权地理数据库。

    ./create_gdb.py --DBMS ORACLE -i gisprod/orcl --auth DATABASE_AUTH -U sys
     -P N0pe3king! -u sde -p Tgdbst@rtsh3r3 -t sde -l '/usr/arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License/sysgen/keycodes'

    在此示例中,在 Windows 计算机中运行相同的脚本:

    create_gdb.py --DBMS ORACLE -i gisprod/orcl --auth DATABASE_AUTH -U sys
     -P N0pe3king! -u sde -p Tgdbst@rtsh3r3 -t sde -l '\\Program Files\ESRI\License\sysgen\keycodes'
    提示:

    Type -h or --help at the command prompt to get syntax help.

您现已在 Oracle 中具有一个地理数据库。

将创建地理数据库的相关消息写入 sde_setup.log 文件,该文件是在为运行工具的计算机上的 TEMP 或 TMP 变量指定的目录中创建的。如果在创建地理数据库时出现任何问题,可查看此日志文件以解决这些问题。

接下来,如果未将 Oracle 数据库 open_cursors 参数设置为 300,请运行 sde.gdb_util.update_open_cursors 存储过程来同步 Oracle 数据库参数和地理数据库的设置

Oracle 管理员配置数据库;地理数据库管理员创建地理数据库

如果地理数据库的创建人员无法获得数据库管理员的密码,数据库管理员可创建数据库和 sde 用户,然后地理数据库管理员可以 sde 登录帐户连接到数据库并使用启用企业级地理数据库地理处理工具或 Python 脚本在数据库中创建地理数据库。

启用企业级地理数据库工具以数据库连接文件作为输入并在 sde 用户方案中创建地理数据库系统表、视图、函数和过程。

安装并配置 Oracle

地理数据库管理员创建地理数据库前,数据库管理员必须执行以下操作:

  • 安装并配置 Oracle 实例。配置 Oracle 实例的方式取决于您的组织的特定需求。有关安装和配置信息,请参考 Oracle 文档。

    创建地理数据库之前,请查看 ArcGIS 系统要求,以确保要使用的数据库管理系统、ArcGIS 和硬件组合能够得到支持。有关所需权限的列表,请参阅 Oracle 地理数据库的权限

  • 创建 sde 用户和方案。
  • 为 sde 用户授予创建地理数据库所需的的权限。
  • 为 sde 用户创建表空间并将其设置为 sde 用户的默认表空间。
  • 授予地理数据库创建所需的包的执行权限。有关包的列表,请参阅 Oracle 地理数据库的权限

如果您希望能够进行以下任意操作,则还需要配置 Oracle extproc,以访问 Esri ST 库:

安装和配置 Oracle 后,地理数据库管理员可安装 ArcGIS 和 Oracle 客户端。

安装并配置客户端

可以安装 ArcGIS DesktopDesktop StandardDesktop Advanced)、ArcGIS Engine Geodatabase UpdateArcGIS Server 以运行 Python 脚本,创建地理数据库。如果您想要运行创建企业级地理数据库地理处理工具,而非脚本,请安装 ArcGIS Desktop

注:

您需要一个 ArcGIS Server(企业版)密钥代码文件,以便在下一部分中授权地理数据库。即使不在 ArcGIS Server 计算机上运行 Python 脚本来创建地理数据库,也必须安装和授权 ArcGIS Server 才能获取密钥代码文件。可能需要将 ArcGIS Server 中的密钥代码文件复制到可使用创建企业级地理数据库地理处理工具访问的位置。

在大多数情况下,ArcGIS 客户端将安装在不同于 Oracle 的计算机上。因此,ArcGIS 客户端计算机上必须具有受支持的 Oracle 客户端,才能连接到 Oracle 实例。请参阅 Oracle 文档,确定应安装哪个 Oracle 客户端版本才能连接到正在使用的 Oracle 版本,并获得安装和配置客户端的说明。

  1. 安装要用于创建地理数据库的 ArcGIS 客户端。

    遵循软件安装指南中提供的说明。

  2. 在 ArcGIS 客户端计算机上安装和配置 Oracle 客户端。

    如果从 32 位 ArcGIS 客户端(例如 ArcMap)进行连接,则必须安装 32 位 Oracle 客户端。即便将 ArcGIS 客户端应用程序安装到 64 位操作系统的计算机上并且数据库和服务器的操作系统均为 64 位,也是如此。如果从 64 位 ArcGIS 客户端(例如 ArcGIS ServerArcGIS Pro)进行连接,则必须安装 64 位 Oracle 客户端。

    可以从 Oracle 中获取 Oracle Instant、Runtime 或 Administrator Client。请参阅 Oracle 文档以获取安装说明。

  3. 设置操作系统的环境变量或用户配置文件,以添加安装 Oracle 客户端的目录的路径和名称。

    • Linux 上,设置 LD_LIBRARY_PATH 环境变量。
    • Windows 上,设置 PATH 环境变量。如果将 ArcMapArcGIS ProArcGIS Server 安装在同一台 Windows 计算机上,则请将 PATH 变量设置为先读取 64 位客户端,后读取 32 位客户端。例如,如果 32 位 Oracle 客户端安装在 c:\Program Files (x86)\Oracle 下,64 位 Oracle Instant Client 安装在 c:\Program Files\Oracle 下,则将以下内容添加到 PATH 变量值的开始位置:C:\Program Files\Oracle;C:\Program Files (x86)\Oracle;

  4. 如果已经运行 ArcGIS 客户端,请重新启动它以识别 Oracle 客户端和新环境变量。
  5. 可使用 Easy Connect 字符串从 ArcGIS 连接到 Oracle。但是,数据库管理员必须将 Oracle 数据库配置为允许使用 Easy Connect 字符串。如果已安装完整的 Oracle 客户端,但想使用 Easy Connect 语法进行连接,请确保客户端上的 sqlnet.ora 文件已配置为允许使用 Easy Connect,且数据库管理员已将 Oracle 服务器配置为 允许 Easy Connect 语法。有关进一步的说明,请参阅 Oracle 文档。

现在,您可以创建地理数据库。

创建地理数据库

地理数据库管理员可以从 ArcGIS DesktopDesktop StandardDesktop Advanced)运行启用企业级地理数据库工具,或从 ArcGIS DesktopArcGIS ServerArcGIS Engine 客户端中运行 Python 脚本,以在现有数据库中创建地理数据库。

运行启用企业级地理数据库 ArcGIS Desktop 工具

如果您有权访问此应用程序,则可以运行启用企业级地理数据库工具,以创建地理数据库。

请遵照以下步骤使用 ArcGIS Desktop 中的启用企业级地理数据库工具创建地理数据库:

  1. 启动 ArcGIS Desktop 客户端。
  2. 以 sde 用户身份连接到 Oracle 数据库。

    确保在数据库连接对话框中保存用户密码。

  3. 打开启用企业级地理数据库地理处理工具。
  4. 将步骤 2 中创建的数据库连接用作输入数据库连接
  5. 浏览至授权 ArcGIS Server 时创建的授权文件,并将其添加到授权文件文本框中。

    使用向导来授权 ArcGIS Server 之后,密钥代码文件将被写入安装该软件的服务器。如果在 Linux 计算机上授权 ArcGIS Server,则密钥代码文件在 /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release>/sysgen 中创建。如果在 Windows 服务器上进行授权,则文件在 Program Files\ESRI\License<release>\sysgen 中创建。如果尚未执行此操作,则请授权 ArcGIS Server 来创建此文件。将该密钥代码文件复制到可使用该工具访问的位置。

  6. 单击确定ArcMapArcCatalog)或运行 (ArcGIS Pro)。

将在数据库中创建地理数据库。

将创建地理数据库的相关消息写入 sde_setup.log 文件,该文件是在为运行工具的计算机上的 %TEMP% 变量指定的目录中创建的。如果在创建地理数据库时出现任何问题,可查看此日志文件以解决这些问题。

如果客户端要使用 SQL 访问地理数据库,请Oracle extproc 配置为允许访问。

接下来,数据库管理员可以使用 sde.gdb_util.update_open_cursors 存储过程来同步 Oracle 和地理数据库之间的 open_cursor 设置

运行 Python 脚本

如果想要通过从 ArcGIS ServerArcGIS DesktopArcGIS Engine 安装程序运行脚本来创建地理数据库,则可使用此处提供的脚本。

  1. 在 ArcGIS 客户端计算机上创建文本文件,然后将以下脚本复制到该文件中。

    """
    Name: enable_enterprise_gdb.py
    Description: Provide connection information to an enterprise database
    and enable enterprise geodatabase.
    Type enable_enterprise_gdb.py -h or enable_enterprise_gdb.py --help for usage
    """
    
    # 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 ("--DBMS", dest="Database_type", type="choice", choices=['SQL_SERVER', 'ORACLE', 'POSTGRESQL', 'DB2','INFORMIX','DB2ZOS', ''], default="", help="Type of enterprise DBMS:  SQL_SERVER, ORACLE, POSTGRESQL, DB2, INFORMIX, or DB2ZOS.")
    parser.add_option ("-i", dest="Instance", type="string", default="", help="DBMS instance name")
    parser.add_option ("--auth", dest="account_authentication", type ="choice", choices=['DATABASE_AUTH', 'OPERATING_SYSTEM_AUTH'], default='DATABASE_AUTH', help="Authentication type options (case-sensitive):  DATABASE_AUTH, OPERATING_SYSTEM_AUTH.  Default=DATABASE_AUTH")
    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 ("-D", dest="Database", type="string", default="none", help="Database name:  Not required for Oracle")
    parser.add_option ("-l", dest="Authorization_file", type="string", default="", help="Full path and name of authorization file")
    
    
    # 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
    	database_type = options.Database_type.upper()
    	instance = options.Instance
    	account_authentication = options.account_authentication.upper()
    	username = options.User.lower() 
    	password = options.Password	
    	database = options.Database.lower()
    	license = options.Authorization_file
    
    
    	if( database_type ==""):	
    		print " \n%s: error: \n%s\n" % (sys.argv[0], "DBMS type (--DBMS) must be specified.")
    		parser.print_help()
    		sys.exit(3)		
    		
    	if (license == ""):
    		print " \n%s: error: \n%s\n" % (sys.argv[0], "Authorization file (-l) must be specified.")
    		parser.print_help()
    		sys.exit(3)
    
    		
    	# Get the current product license
    	product_license=arcpy.ProductInfo()
    	
    	if (license == ""):
    		print " \n%s: error: %s\n" % (sys.argv[0], "Authorization file (-l) must be specified.")
    		parser.print_help()
    		sys.exit(3)
    	
    	# Checks required license level
    	if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
    		print "\n" + product_license + " license found!" + "  Enabling enterprise geodatabase functionality requires an ArcGIS Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS Server license."
    		sys.exit("Re-authorize ArcGIS before enabling an enterprise geodatabase.")
    	else:
    		print "\n" + product_license + " license available!  Continuing to enable..."
    		arcpy.AddMessage("+++++++++")
    	
    	# Local variables
    	instance_temp = instance.replace("\\","_")
    	instance_temp = instance_temp.replace("/","_")
    	instance_temp = instance_temp.replace(":","_")
    	Conn_File_NameT = instance_temp + "_" + 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.CreateDatabaseConnection_management(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")
            for i in range(arcpy.GetMessageCount()):
    		if "000565" in arcpy.GetMessage(i):   #Check if database connection was successful
    			arcpy.AddReturnMessage(i)
    			arcpy.AddMessage("\n+++++++++")
    			arcpy.AddMessage("Exiting!!")
    			arcpy.AddMessage("+++++++++\n")
    			sys.exit(3)            
    		else:
    			arcpy.AddReturnMessage(i)
    			arcpy.AddMessage("+++++++++\n")
    	
    	
    	# Process: Enable geodatabase...
    	try:
    		print "Enabling Enterprise Geodatabase...\n"
    		arcpy.EnableEnterpriseGeodatabase_management(input_database=Connection_File_Name_full_path, authorization_file=license)
    		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)

  2. .py 扩展名保存该文件。
  3. 运行脚本,同时提供特定于您的站点的选项和信息。

    在从 Linux 计算机上运行的以下示例中,针对 SID 为 orcl 的 Oracle 实例运行文件 enable_gdb.py。该实例在服务器 gisprod 上运行。默认 ArcGIS Server 位置中指定的密钥代码文件用于授权地理数据库。

    enable_gdb.py --DBMS ORACLE -i gisprod/orcl --auth DATABASE_AUTH 
    -u sde -p Tgdbst@rtsh3r3 -l '/usr/arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License/sysgen/keycodes'

    在此示例中,在 Windows 计算机中运行相同的脚本:

    create_gdb.py --DBMS ORACLE -i gisprod/orcl --auth DATABASE_AUTH -U sys
     -P N0pe3king! -u sde -p Tgdbst@rtsh3r3 -t sde -l '\\Program Files\ESRI\License\sysgen\keycodes'
    提示:

    Type -h or --help at the command prompt to get syntax help.

您现已在 Oracle 数据库中具有一个地理数据库。

将创建地理数据库的相关消息写入 sde_setup.log 文件,该文件是在为运行脚本的计算机上的 TEMP 或 TMP 变量指定的目录中创建的。如果在创建地理数据库时出现任何问题,可查看此日志文件以解决这些问题。

接下来,数据库管理员可以使用 sde.gdb_util.update_open_cursors 存储过程来同步 Oracle 和地理数据库之间的 open_cursor 设置