Create a geodatabase in Db2

Available with Standard or Advanced license.

Install and configure IBM Db2 and an ArcGIS client and use the Enable Enterprise Geodatabase geoprocessing tool or a Python script to create a geodatabase in a Db2 database.

When you create a geodatabase from ArcGIS Pro 3.5, the geodatabase version is 11.5.0.x.

Prerequisites

Complete the following before you create a geodatabase in Db2:

  • Confirm the ArcGIS, Db2, and operating system versions you want to use are compatible.
  • Obtain the Db2 client required to connect to the version of Db2 you'll use to store the geodatabase.
  • Obtain an ArcGIS Server keycodes file—which is created when you authorize ArcGIS Server—and place it in a location you can access from the ArcGIS client you'll use to create the geodatabase.
  • Install and configure Db2.

Install and configure Db2

Before you can run the Enable Enterprise Geodatabase tool or script to create a geodatabase in Db2, you (or your IT department or database administrator) must install and configure the Db2 database management system.

First follow the instructions provided by IBM to install and configure the Db2 instance. Then follow these steps to configure a database and login to use for your geodatabase:

  1. Create an operating system login named sde on the Db2 server.

    You will connect to the database with the sde login to create a geodatabase.

  2. Create a Db2 database and register it with the Spatial Extender module.
  3. Grant the sde user DBADM authority in the database.
  4. Create a temporary table space and grant geodatabase users access to the table space.

    The temporary table space must have a minimum of 8K of page space.

    In the following example, a user temporary table space named geospace is created with page size 8K. Use of the table space is granted to a group named geodatausers, which contains all database users who perform geodatabase operations such as creating geodatabase archives, using feature bins, and making large selection sets that generate log file tables in the geodatabase.

    CREATE USER TEMPORARY TABLESPACE geospace PAGESIZE 8 K MANAGED BY AUTOMATIC STORAGE BUFFERPOOL IBMDEFAULTBP;
    
    GRANT USE OF TABLESPACE geospace TO geodatausers WITH GRANT OPTION;

Next, configure the ArcGIS client from which you will connect and create a geodatabase in the Db2 database.

Configure clients

You can run a Python script from ArcGIS Pro (Desktop Standard or Desktop Advanced) or ArcGIS Server (enterprise edition) to create a geodatabase. To run the Enable Enterprise Geodatabase geoprocessing tool instead of a script, use ArcGIS Pro.

Note:

You need an ArcGIS Server (enterprise) keycodes file to authorize your geodatabase in the next section. Even if you do not run a Python script from an ArcGIS Server machine to create the geodatabase, you must install and authorize ArcGIS Server to get the keycodes file. You may need to copy the file from the ArcGIS Server machine to a location the geoprocessing tool or Python script can access.

  1. Install the ArcGIS client you'll use to create the geodatabase.

    Follow the instructions provided in the software installation guides.

  2. In most cases, the ArcGIS client will be installed on a different computer than the Db2 server; therefore, install and configure a Db2 client on the ArcGIS client computer.

    You can download the IBM Data Server Runtime Client for Db2 from My Esri, or you can use your own installation of the Db2 client. See the Db2 documentation for instructions to install. If you are installing the Db2 client on a 64-bit operating system, run the 64-bit executable; it installs both 32- and 64-bit files, allowing you to connect from both 32- and 64-bit ArcGIS clients.

  3. Optionally, catalog the database to allow connections using a data source name.

    See the IBM Db2 documentation for instructions to create a data source name.

    A data source name is not required to connect from ArcGIS to a Db2 database; you can use a DSNless connection string instead.

Now you can create a geodatabase.

Create a geodatabase

Use one of the following methods to create a geodatabase in the Db2 database:

Use the Enable Enterprise Geodatabase tool

If you installed and configured ArcGIS Pro to connect to your Db2 database, you can run the Enable Enterprise Geodatabase tool.

Follow these steps to create a geodatabase from ArcGIS Pro:

  1. Start ArcGIS Pro.
  2. Connect to the Db2 database using the sde login.

    Save the sde user's password on the Database Connection dialog box. If you do not, the connection file will not work with the Enable Enterprise Geodatabase tool.

  3. Open the Enable Enterprise Geodatabase tool.

    See Find a geoprocessing tool for general information about opening geoprocessing tools.

  4. In the Input Database text box, add the database connection file you created in step 2.
  5. Browse to the ArcGIS Server keycodes file that was created when you authorized ArcGIS Server and add the file to the Authorization File text box.

    When you use the authorization wizard to authorize ArcGIS Server, a keycodes file is written to the machine where the software is installed. If you have not already done so, authorize ArcGIS Server to create this file. If you authorize ArcGIS Server on a Linux machine, the file was created in /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release>/sysgen. If you authorize on a Microsoft Windows server, the file was created in Program Files\ESRI\License<release>\sysgen. Copy this file to a location you can access from the Enable Enterprise Geodatabase tool.

  6. Click Run.

    You can find messages related to geodatabase creation in the sde_setup.log file, which is created in the directory specified for the %TEMP% variable on the computer where the tool is run. If you have problems creating a geodatabase, check this file to troubleshoot the problem.

A geodatabase is created in the Db2 database.

Next, create users to load data into the geodatabase. See the IBM Db2 Information Center for instructions to create users.

Use a Python script

You can run a Python script from an ArcGIS Pro (Desktop Standard or Desktop Advanced) or ArcGIS Server (enterprise edition) client machine to create a geodatabase in a Db2 database.

Tip:

For information about running Python from an ArcGIS Server machine, see ArcGIS Server and ArcPy.

Follow these steps to run a Python script for geodatabase creation in a Db2 database:

  1. Create a text file on the ArcGIS client machine and copy the following script into the file, providing information specific to your site:

    # Name: enable_enterprise_gdb.py
    # Description: Create an enterprise geodatabase in an existing Db2 database
    
    # Import system modules
    import arcpy, os
    
    # Local variables
    # Replace paths to work on your machine
    license = "/arcgis/path/to/authorization_file/keycodes"
    tempdir = "/tmp/"
    connection_file_name = "egdb_connection.sde"
    
    # Check for the .sde file and delete it if present
    connection_file_name_path = os.path.join(tempdir, connection_file_name)
    
    arcpy.env.overwriteOutput=True
    if os.path.exists(connection_file_name_path):
    	os.remove(connection_file_name_path)
    
    # Create a connection to the geodatabase as the geodatabase administrator
    # Replace "db2prod" with the name of your database, and replace "mysdepassword" with the password of the sde user
    arcpy.CreateDatabaseConnection_management(tempdir,
                                              connection_file_name,
                                              "DB2",
                                              "db2prod",
                                              "DATABASE_AUTH",
                                              "sde",
                                              "mysdepassword",
                                              "SAVE_USERNAME")
    # Enable geodatabase
    try:
        arcpy.EnableEnterpriseGeodatabase_management(connection_file_name_path, license)
    except:
        for i in range(arcpy.GetMessageCount()):
            arcpy.AddReturnMessage(i)

  2. Replace values as noted in the script.
  3. Save the file with a .py extension.
  4. Run the script.

    You can find messages related to geodatabase creation in the sde_setup.log file, which is created in the directory specified for your TEMP or TMP variable on the computer where the Python script is run. If you have any problems creating a geodatabase, check this file to troubleshoot the problem.

A geodatabase is created in the Db2 database.

Next, create users to load data into the geodatabase. See the IBM Db2 Information Center for instructions to create users and grant privileges to load data.