WAS v8.5 > Script the application serving environment (wsadmin) > Configure servers with scripting

Configure database session persistence using scripting

We can use scripting and wsadmin to configure database persistence.

Before starting this task, wsadmin must be running. See the Start the wsadmin scripting client using wsadmin.sh topic for more information. Configure database persistence. Within these steps, the following variables apply to the Jython and Jacl commands:

  1. Retrieve the configuration ID of the server to enable database persistence and store its values in the server variable.

    • Jacl:

        set server [$AdminConfig getid /Node:node_name/Server:server_name/]

      Example output:

      server_name(cells/cell_name/nodes/node_name/servers/server_name
      |server.xml#Server_1265038035855)
    • Jython:

        server = AdminConfig.getid('/Node:node_name/Server:server_name/')

      Example output: None

  2. Retrieve the name of the session manager, which is associated with the server values in the previous step, and assign the session manager to the sm variable.

    • Jacl:

        set sm [$AdminConfig list SessionManager $server]

      Example output:

      (cells/cell_name/nodes/node_name/servers/server_name
      |server.xml#SessionManager_1256932276179)
    • Jython:

        sm = AdminConfig.list('SessionManager', server)

      Example output: None

  3. Add the database session persistence mode value to the sm variable, which already contains the session manager value from the previous steps.

    • Jacl:

        $AdminConfig modify $sm {{sessionPersistenceMode "DATABASE"}}

      Example output: None

    • Jython:

        AdminConfig.modify(sm,'[[sessionPersistenceMode "DATABASE"]]')

      Example output: None

  4. Retrieve the database session persistence value for the session manager and the database session persistence mode that are set to the sm variable. Set this value to the sesdb variable.

    • Jacl:

        set sesdb [$AdminConfig list SessionDatabasePersistence $sm]

      Example output:

      (cells/cell_name/nodes/node_name/servers/server_name
      |server.xml#SessionDatabasePersistence_1256932276179)
    • Jython:

        sesdb = AdminConfig.list('SessionDatabasePersistence',sm)

      Example output: None

  5. Modify the sesdb variable to include the user ID and password to access the database and the table space name; and the naming and directory interface (JNDI) name.

    • Jacl:

      $AdminConfig modify $sesdb { {userId "db2_administrator"} {password "db2_password"}
       {tableSpaceName ""} {datasourceJNDIName "jdbc/SessionDataSource"} }

      Example output: None

    • Jython:

      AdminConfig.modify(sesdb,'[[userId "db2_administrator"] [password "db2_password"] 
      [tableSpaceName ""] [datasourceJNDIName "jdbc/SessionDataSource"]]')

      Example output: None

  6. Save the configuration changes. For more information, see the documentation on saving configuration changes with wsadmin.


Related


Save configuration changes with wsadmin
Use the wsadmin scripting AdminConfig object for scripted administration


Reference:

Commands for the AdminConfig object using wsadmin.sh
Configure for database session persistence


+

Search Tips   |   Advanced Search