TASSTA Documentation Center TASSTA Documentation Center More products
Hide table of contents Hide details Search My account

Cleaning up the TASSTA database

What problems you can prevent

If your TASSTA databases grow too large, you may experience T.Lion performance issues, and recovery after a server failure takes an unacceptably long time. The time costs of upgrading and maintenance also increase dramatically.

The recommended best practice is to keep the size of each database under 3GB. In a T.Lion – T.Brother configuration, the maximum sizes of the databases of either node need to be further reduced to about 2GB.

Voice and video recordings contribute the most to the growth of a database. Another major contributor is geo-positions of users — these records are small but very numerous. If there is a lot of voice and video communication going on in your TASSTA network, configuring a short retention period is recommended.

What you need

The vclean.sh script is intended specifically for fixing the issues described above. The script should be available as part of your T.Lion server deployment and located in the /usr/local/tassta/tools directory on the server. If the script is missing, contact the Support team to obtain it.

You also need to know the basics of scheduling cron jobs.

How to proceed

Set up periodic database cleanups to avoid server performance degradation.

Before you begin, check the size of your TASSTA database. For that, take the following steps:

  1. Log in as root.
  2. Run mysql to enter the MySQL command line.
  3. Execute the following query:
SELECT table_schema "tassta", 
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" 
FROM   information_schema.tables 
GROUP  BY table_schema;

The largest databases will probably be maptool, recorder and tassta.

Next, check how much disk space is in use on the partition where the databases are located. For that, you can use the df command as follows:

df -h

See the necessary percentage value in the output. If your database sizes don't exceed the recommended 3GB, make a note of that percentage. If your databases are too large, make a correction to that value — estimate what the percentage would be if the database sizes were reduced to 3GB maximum. You will use the resulting percentage when you configure database cleanup parameters.

Next, you should decide on the retention policy for your data: how many days to keep data for. Your organization may have formal requirements in this regard.

After you have made these preparations, proceed to configure the cleanup parameters.

Adjusting cleanup parameters

The vclean.sh script exposes a number of configurable parameters. For the task at hand, the following parameters are most important:

Parameter Meaning What value to set
DEFAULT_CAPACITY Maximum percentage of total occupied disk space on the partition where the database is located. If you have chosen a reference percentage (as suggested earlier), use this value here.
DEFAULT_DATA_AGE_KEEP How many days' worth of data (from now) must be retained no matter what. Set this to the number of days that is mandated by your retention policy.
DEFAULT_DATA_AGE Data that is newer than DEFAULT_DATA_AGE but older than DEFAULT_DATA_AGE_KEEP can potentially be deleted. The oldest data in that range is cleared if that is necessary for satisfying the DEFAULT_CAPACITY condition. Specify any convenient number.

Script run modes

You can run the vclean.sh script in two ways:

  1. Without parameters
    In this case, you have to edit the parameter values directly in the script code. Locate the definitions of the parameters, modify them as necessary and save your changes.
    Note: Removing data for multiple days requires multiple automatic iterations (from older to newer data) — one day's worth of obsolete data requires one iteration. Each iteration also checks if the DEFAULT_CAPACITY condition is met; when this value is achieved, the iterations stop.
  2. With two parameters: server ID followed by DEFAULT_DATA_AGE_KEEP
    Example:
    /usr/local/tassta/tools/vclean.sh 2 30
    Here, 2 is the ID of the TASSTA server for which you are performing the database cleanup, and 30 is the maximum age of retainable data. You can look up the server ID in T.Commander if you want to use this method.
    Note: In this mode, all obsolete data is removed at once; this is not recommended if you have more that three days' worth of old data.
Important:

The DEFAULT_CAPACITY parameter will not necessarily be met. For example, if DEFAULT_DATA_AGE_KEEP is set to 7 and DEFAULT_CAPACITY to 80, and all data older than seven days has been cleared but disk use is still at 90%, then no more cleanup will occur until some of the data gets old enough for removal.

Scheduling cleanups

Set up a periodic schedule for database cleanups using cron. If cron is not available on your server, install it as root:

apt-get install cron

To set a schedule, run crontab -e and specify a job definition using cron syntax for running the vclean.sh script, with or without parameters.. Examples:

  • Run the script every day at one in the morning:
    0 1 * * * /bin/bash /usr/local/tassta/tools/vclean.sh
  • Run the script every 30 minutes:
    */30 * * * * /bin/bash /usr/local/tassta/tools/vclean.sh

Use a schedule that is convenient to you, preferably during non-business hours.

Important:

Cleanup can be resource-intensive, so frequent cleanups of small amounts of data can be better than big cleanups that are far apart.