Stopping the database

There are many occasions when you must stop a database, for example, before an upgrade or performing various maintenance tasks.

There are many occasions when you must stop a database, for example, before an upgrade or performing various maintenance tasks. You can stop a running database through one of the following:

You cannot stop a running database if any users are connected or Database Designer is building or deploying a database design.

Administration tools

To stop a running database with admintools:

  1. Verify that all cluster nodes are up. If any nodes are down, identify and restart them.

  2. Close all user sessions:

    • Identify all users with active sessions by querying the SESSIONS system table. Notify users of the impending shutdown and request them to shut down their sessions.

    • Prevent users from starting new sessions by temporarily resetting configuration parameter MaxClientSessions to 0:

      => ALTER DATABASE DEFAULT SET MaxClientSessions = 0;
      
    • Close all remaining user sessions with Vertica functions CLOSE_SESSION and CLOSE_ALL_SESSIONS.

  3. Open Vertica Administration Tools.

  4. From the Main Menu:

    • Select Stop Database

    • Click OK

  5. Select the database to stop and click OK.

  6. Enter the password (if asked) and click OK.

  7. When prompted that database shutdown is complete, click OK.

Command line

You can stop a database with the command line tool stop_db:

$ /opt/vertica/bin/admintools -t stop_db -d db-name [-p password] [-F | --force]

If you omit the -F (or --force) option, the command checks for active sessions. If users are connected to the database, the command aborts with an error message and lists all active sessions. For example:

$ /opt/vertica/bin/admintools -t stop_db -d VMart
Info: no password specified, using none

         Active session details
| Session id                     | Host Ip       | Connected User |
| ------- --                     | ---- --       | --------- ---- |
| v_vmart_node0001-91901:0x162   | 10.20.100.247 | ryan           |
Database VMart not stopped successfully for the following reason:
Unexpected output from shutdown: Shutdown: aborting shutdown
NOTICE: Cannot shut down while users are connected

Use the option -F (or --force) to override user connections and force a shutdown.