Example of minimally configuring for and testing the automatic addition of more space
This example shows how you can minimally configure and then test the automatic addition of more space. You can do this by creating a dbspace, filling the space, adding an entry to the OneDB storage pool, and loading tables into the space. When the space fills, OneDB automatically expands it.
About this task
To minimally configure for and test the automatic addition of more space:
- Create a dbspace.
For example, create a dbspace named
expandable_dbs
and allocate an initial chunk using the first 10000 KB of a cooked file named /my_directory/my_chunk, as follows:onspaces -c -d expandable_dbs -p /my_directory/my_chunk -o 0 -s 10000
- Fill the dbspace.
For example, fill the dbspace without loading a row of data. Instead, create a table and allocate a large set of contiguous free pages to the first extent, as follows:
CREATE TABLE large_tab (col1 int) IN expandable_dbs EXTENT SIZE 10000000;
You can monitor the free pages in your chunks by using the onstat -d command . If your dbspace is full, you receive out-of-space errors when attempting to create and load data into another new table.
- Add an entry to the OneDB storage
pool.
For example, add the $ONEDB_HOME/tmp directory to the storage pool, as follows:
DATABASE sysadmin; EXECUTE FUNCTION task("storagepool add", "$ONEDB_HOME/tmp", "0", "0", "10000", "2");
- In the SP_THRESHOLD configuration parameter, set a threshold for the minimum amount of free KB that can exist in a storage space before OneDB automatically runs a task to expand the space.
- Create and load new tables into your database.
Now, if a storage space becomes full, instead of receiving an out-of-space error, OneDB automatically creates a cooked file in the $ONEDB_HOME/tmp file and add a chunk to the expandable_dbs database using the new cooked file. As you continue to fill this chunk, the server automatically extends it. The server will always extend chunks if possible before adding new ones to a dbspace.
- Reduce the free space in a storage space to test the value in
the SP_THRESHOLD configuration parameter.
Allocate enough pages in a storage space to reduce the free space so it is below the threshold indicated by SP_THRESHOLD. However, do not completely fill the space.
You must see the space automatically expanded the next time that the mon_low_storage task runs.
- Create an out-of-space condition.
Allocate all pages in a storage space. Then try to allocate more pages. The allocation must be successful and you must not receive an out-of-space error.
OneDB writes messages to the log whenever it extends or adds a chunk and marks new chunks as extendable.
Run the onstat -d command to display all chunks in the instance. Look for extendable chunks, which are marked with an
E
flag. The command output shows that the server automatically expanded the space, either through the addition of a new chunk or by extending the size of an existing chunk.