Maintenance of Applications Manager backend database

Maintenance of Applications Manager backend database

Note: Please take complete database backup without fail prior to these steps.

I. Applications Manager with PostgreSQL Database.

  1. Shutdown all Applications Manager related process as follows:
    1. For windows:
      1. Open services.msc --> stop ManageEngine Applications Manager service.
      2. Open Command Prompt as an Administrator, go to AppManager_Home\ and then execute the below command
        shutdownApplicationsManager.bat -force 
        (execute this until you get a message that, all process have been shutdown)
    2. For Linux
      1. Open Command Prompt with proper privileges' go to AppManager_Home/ and then execute the below commands
        sh shutdownApplicationsManager.sh
        sh shutdownApplicationsManager.sh -force
  2. Start PostgreSQL using these steps:
    1. For windows, In Administrator Command Prompt, go to AppManager_Home\working\ folder and execute the below command to start PGSQL database:
      bin\startPGSQL.bat
    2. For Linux, In Command Prompt, go to AppManager_Home/working/ folder and execute the below command to start PGSQL database:
      ./bin/startPGSQL.sh
  3. Connect to PostgreSQL database from command prompt using the steps provided in this link: https://pitstop.manageengine.com/portal/en/kb/articles/connecting-to-applications-managers-bundled-database
  4. Once connected to the Applications Manager database (amdb) in PostgreSQL, execute below query to repair / reindex database: 
    Quote
    VACUUM VERBOSE ANALYZE;
  5. Once execution completes, you can exit the PostgreSQL's Command Line using the meta-command \q
  6. Stop PostgreSQL using these steps:
    1. For windows, In Administrator Command Prompt, go to AppManager_Home\working\bin folder and execute the below command to start PGSQL database:
      stopPGSQL.bat
    2. For Linux, In Command Prompt, go to AppManager_Home/working/bin folder and execute the below command to start PGSQL database:
      ./stopPGSQL.sh
  7. Go to AppManager_Home directory rename the logs folder to logs_old, create a new folder name it as logs. Then proceed to start Applications Manager.


II. Applications Manager with Microsoft SQL Database

  1. Shutdown all Applications Manager related process as follows:
    1. For windows:
      1. Open services.msc --> stop ManageEngine Applications Manager service.
      2. Open Command Prompt as an Administrator, go to AppManager_Home\ and then execute the below command
        shutdownApplicationsManager.bat -force 
        (execute this until you get a message that, all process have been shutdown)
    2. For Linux
      1. Open Command Prompt with proper privileges' go to AppManager_Home/ and then execute the below commands
        sh shutdownApplicationsManager.sh
        sh shutdownApplicationsManager.sh -force
  2. Connect to Applications Manager backend Microsoft SQL database using SQL Server Management Studio (SSMS) and execute the below queries:
    1. To check for any database corruption or errors, connect to the backend SQL instance via SQL Server Management Studio and execute the following command:
      Quote
      DBCC CHECKDB WITH NO_INFOMSGS, ALL_ERRORMSGS, EXTENDED_LOGICAL_CHECKS;
      If errors are reported in the output of the above command, troubleshooting and remediation can be performed following this Microsoft guide: Troubleshoot DBCC CHECKDB errors.
    2. To reduce index fragmentation and improve query performance, rebuild all indexes in Applications Manager backend database (AMDB) via SQL Server Management Studio:
      Quote
      DECLARE @sql NVARCHAR(MAX) = N'';
      DECLARE @edition INT = CONVERT(INT, SERVERPROPERTY('EngineEdition'));
      IF @edition IN (3, 8) -- 'Enterprise/Developer Edition detected - Running ONLINE rebuild'
          SELECT @sql += N'RAISERROR(''Rebuilding ' + QUOTENAME(s.name) + '.' + QUOTENAME(t.name) + ''',0,1) WITH NOWAIT; ALTER INDEX ALL ON ' + QUOTENAME(s.name) + '.' + QUOTENAME(t.name) + ' REBUILD WITH (ONLINE = ON); ' FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE t.is_ms_shipped = 0;
      ELSE -- 'Standard/Other Edition detected - Running OFFLINE rebuild'
          SELECT @sql += N'RAISERROR(''Rebuilding ' + QUOTENAME(s.name) + '.' + QUOTENAME(t.name) + ''',0,1) WITH NOWAIT; ALTER INDEX ALL ON ' + QUOTENAME(s.name) + '.' + QUOTENAME(t.name) + ' REBUILD; ' FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE t.is_ms_shipped = 0;
      EXEC sp_executesql @sql;
      EXEC sp_updatestats; -- Update statistics
  3. Go to AppManager_Home directory rename the logs folder to logs_old, create a new folder name it as logs. Then proceed to start Applications Manager.
Notes
Notes
  1. Ensure sufficient disk space and transaction log space are available before executing this command, as index rebuild operations are fully logged in the SQL Server transaction log.
  2. Consider running this operation during non-business hours, as it may take significant time depending on database size and may consume substantial CPU, memory, and I/O resources.
  3. In SQL Server Standard Edition, index rebuild operations are performed offline and may lock tables during execution.

                  New to ADSelfService Plus?