# Create a Database Service

If you want to run an Apache NiFi cluster, you must set up a Database Service so that the following information can be shared between nodes in the cluster:

- State information for your NiFi Ingest connectors.
- Dependency information managed by a document registry service (for more information, see Index Documents in the Correct Sequence).

The database service uses standard ODBC and SQL, so you should be able to use any database server. Micro Focus recommends PostgreSQL and MySQL as these have been most fully tested. Oracle is not supported.

To create a database service to communicate with an external database

1. Ensure that your external database server is running and create a new, empty database.

2. Complete the following steps on each machine that hosts Apache NiFi:

   1. (Linux only) Install the unixODBC driver manager.
   2. Install the ODBC driver for the database that you have chosen to use.

   3. (Linux only) Configure the name and path of the ODBC driver in the unixODBC `odbcinst.ini` configuration file. By default, the database service expects to find this file at `/etc/odbcinst.ini`. Micro Focus recommends configuring the full path to the driver, for example:

          [PostgreSQL]
          Driver=/usr/pgsql-11/lib/psqlodbcw.so

          [MySQL ODBC 8.0 Unicode Driver]
          Driver=/usr/lib64/libmyodbc8w.so

   4. (Optional) Create a DSN that the database service can use to connect to the database. If you do not create a DSN you must specify a full connection string when you configure the NiFi Ingest database service. On Windows you can create a DSN using the 64-bit ODBC Data Sources administration utility at Windows Control Panel > Administrative Tools > ODBC Data Sources 64-bit. On Linux, you can define a DSN in the unixODBC `odbc.ini` configuration file. By default the database service expects to find this file at `/etc/odbc.ini`.

      TIP: On Linux, you can use the environment variable `ODBCSYSINI` to set the path of the directory that contains both `odbcinst.ini` and `odbc.ini`.

      The following example shows a DSN configured in `odbc.ini`. The name of the DSN is `MyDSN`. Notice that the driver name matches one of the entries in `odbcinst.ini`.

          [MyDSN]
          Driver=PostgreSQL
          ServerName=server.example.com
          Port=5432
          UserName=nifi
          Password=password
          Database=db123

      Setting the user name and password in the DSN is optional, because you can specify these in the connection string (in the NiFi database service configuration) instead.

3. Open the Apache NiFi user interface in your web browser.
4. Click a blank area of the canvas, to de-select all of the components on the canvas.

5. In the Operate Palette, click Configuration .

   The NiFi Flow Configuration dialog box opens.

6. Click the Controller Services tab.

7. Click Create a new controller service .

   The Add Controller Service dialog box opens.

8. In the Source list, click idol.nifi.

9. In the list, click DatabaseServiceImpl, and click ADD.

   The new service is added.

10. At the end of the row for the controller service, click Configure .

    The Configure Controller Service dialog box opens.

11. Click the Properties tab and set the following properties:

    Connection String | The connection string to use to connect to the external database through ODBC.

12. Click Apply.

    You are returned to the NiFi Flow Configuration dialog box. NiFi validates the connection string. If the connection string is valid, you are able to start the service. If not, NiFi displays a warning:

13. Enable the service. At the end of the row for the controller service, click Enable .

    The Enable Controller Service dialog box opens.

14. Click ENABLE and then click CLOSE.

15. Close the NiFi Flow Configuration dialog box.

    When you configure a NiFi Ingest connector, set the property State Database Service to the name of the service you created in this procedure.

    When you configure a DocumentRegistryServiceImpl, set the property Database Service to the name of the service you created in this procedure.

_FT_HTML5_bannerTitle.htm