Microsoft Exchange Server requires maintenance and periodic testing to make sure that it remains healthy and up-to-date. In this post, we will be discussing ways on how to check and keep the Exchange databases healthy.
Before checking the databases, it would be best to perform a health check on the services of your Exchange Server. This can be done by checking if all the services of the Exchange Server are up, along with other dependent services. Alternatively, you can use the below PowerShell cmdlet. This will give you a complete overview of the Exchange Services status.
First things first, you need to check if the databases in the Exchange Server are mounted. If there are no complaints by the users, it does not mean that all is fine. It may happen that the database where the archives are stored is down. To check this, you can use the Exchange Admin Center (EAC). Here’s how:
- Open the Exchange Admin Center (EAC) by browsing the Exchange Server and adding the /ecp at the end of the URL,
- Once you log in with correct credentials, click on the Servers section in the left pane
- Click on databases
- Make sure that the databases’ status is showing as mounted
On the other hand, you can use PowerShell to check the status of database, by running the Get-MailboxDatabase cmdlet.
Get-MailboxDatabase -Status | Format-List name,server,mounted
With this simple command, you can see all the databases and their mounting status. If the database ‘Mounted’ status is ‘False’, it indicates a problem. You can try to mount the database by using the PowerShell cmdlet below.
Mount-Database -Identity DB2
If the database doesn’t mount, there could be some issues that need further investigation. You can use the native tool ESEUtil that can help in identifying the possible cause of the issue, along with two recovery options - Soft and Hard Recovery. First, you need to confirm the status of the database. You can use the /mh parameter to know the status of database.
If the state is shown as Dirty Shutdown, it means that the database or logs are corrupted, or a log is missing. In this case, you can perform Soft Recovery by running the ESEUtil command with /r parameter.
EseUtil /r E00 /l C:\EDB /d C:\EDB\db2.edb
Depending on the size of the database, this may take some time. If it is successful, you can try to mount the database. If it mounts, take a backup of the database to make sure that all is fine.
If it is not successful, you may need to perform Hard Recovery. However, it is suggested to avoid Hard Recovery as it brings data loss. Basically, it crops out all the data which is deemed corrupted. Apart from this, after Hard Recovery, Microsoft will not provide support, if you face an issue. Also, there’s no guarantee that the database would mount after this process.
After successful recovery, it is highly suggested to perform defragmentation of the database. It is to be noted that the database will not be mounted during this process. The defrag process will remove all the white space or, some would say, empty space in the database to improve performance and size of the database. Before running the defrag process, it is good to see the status, and the size and free space of the database. This can be done by running the Get-MailboxDatabase with some parameters.
Get-MailboxDatabase -Status | ft name, databasesize, availablenewmailboxspace -auto
Here, you can see that DB3 has a size of 247 MB, with 118 MB free space. So, it needs defragmentation to clear that space. To run the defrag process, it is best to have ample storage space as it will create a new EDB file to work on.
To defrag a database, you need to use the ESEUtil with the /d parameter, as given below.
Eseutil /d "DB3.edb" /t "temp_db3.edb"
This will defrag the database. After that you can again run the Get-MailboxDatabase to see the shrunk database.
In this post, you have seen how to check the health of Exchange databases through the manual process. However, in a large setup, it is strongly suggested to have a monitoring system in place with alerts that constantly checks the status of the Exchange Server, its services, and databases, apart from CPU, storage, and other resources.
You have also seen how you can mitigate the issues and their repercussions. If something fails, you will end up with a huge administrative effort to recover the data or end up with data loss as you would need to restore from the previous day’s backup. Alternatively, you can cut down on administrative effort and resources by using Stellar Repair for Exchange software that can open any version of the Exchange Server database - healthy or not. By using the software, you can export EDB data to PST and other formats. You can also export directly to a new live Exchange database or Office 365 tenant. The software is easy-to-use, fast, and can reduce downtime and efforts to the minimum.