Maintenance of Applications Manager backend database
Note: Please take complete database backup without fail prior to these steps. I. Applications Manager with PostgreSQL Database.
Shutdown all Applications Manager related process as follows:
For windows:
Open services.msc --> stop ManageEngine Applications Manager service.
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)
For Linux
Open Command Prompt with proper privileges' go to AppManager_Home/ and then execute the below commands
sh shutdownApplicationsManager.sh
sh shutdownApplicationsManager.sh -force
Start PostgreSQL using these steps:
For windows, In Administrator Command Prompt, go to AppManager_Home\working\ folder and execute the below command to start PGSQL database:
bin\startPGSQL.bat
For Linux, In Command Prompt, go to AppManager_Home/working/ folder and execute the below command to start PGSQL database:
./bin/startPGSQL.sh
Once connected to the Applications Manager database (amdb) in PostgreSQL, execute below query to repair / reindex database:
Once execution completes, you can exit the PostgreSQL's Command Line using the meta-command \q
Stop PostgreSQL using these steps:
- For windows, In Administrator Command Prompt, go to AppManager_Home\working\bin folder and execute the below command to start PGSQL database:
stopPGSQL.bat - For Linux, In Command Prompt, go to AppManager_Home/working/bin folder and execute the below command to start PGSQL database:
./stopPGSQL.sh
- 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
- Shutdown all Applications Manager related process as follows:
- For windows:
- Open services.msc --> stop ManageEngine Applications Manager service.
- 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)
- For Linux
- Open Command Prompt with proper privileges' go to AppManager_Home/ and then execute the below commands
sh shutdownApplicationsManager.sh
sh shutdownApplicationsManager.sh -force
- Connect to Applications Manager backend Microsoft SQL database using SQL Server Management Studio (SSMS) and execute the below queries:
To check for any database corruption or errors, connect to the backend SQL instance via SQL Server Management Studio and execute the following command:
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. To reduce index fragmentation and improve query performance, rebuild all indexes in Applications Manager backend database (AMDB) via SQL Server Management Studio:
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
- 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
- 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.
- 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.
- In SQL Server Standard Edition, index rebuild operations are performed offline and may lock tables during execution.
New to ADSelfService Plus?