Database Administration: UDR and SDR

Up to version 14, only one built-in database is used: UDR (User Data Repository), intended for persistent storage of data about services, policing, and other FastDPI settings.

Starting from version 14, UDR is split into UDR and SDR. The split occurs automatically during the version upgrade.
SDR (System Data Repository) is intended for storing FastDPI settings not related to subscribers. It can be considered a continuation of fastdpi.conf. No special SDR activation is required – the necessary .mdb files are created automatically when the corresponding mode is enabled in fastdpi.conf.

Global rules for vlan drop/pass/hide/permit, previously set using the CLI command vlan group, will be converted and moved from UDR to SDR and deleted from UDR. When downgrading from version 14 to 13, data from SDR will be lost, so manual transfer is required by saving a copy of SDR before the update.

List of Tables in UDR

Table	Purpose
bindings	Link between login and address
bindings_multi	Link between login and address for multi-subscriber (multiple IPs)
ip_props	BRAS subscriber properties
policing	Policing settings for subscribers
profile_names	Profile names
profiles	Service and policing profiles
services	Subscriber service settings
vchannel_policing	Policing settings for channels

SDR Structure

In the SDR directory /var/db/dpisdr, depending on the enabled modes, the database files are located:

fdpi.mdb: general data

bras.mdb: data related to BRAS mode

router.mdb: data related to router mode

Contents of these DBs for version 14:

fdpi.mdb:

acl_vlan_rule - stores VLAN rules (rules are set using CLI commands in vlan rule group)

acl_qinq_rule - stores QinQ rules (rules are set using CLI commands in vlan rule group)

bras.mdb:

l2tp_server_props - L2TP servers served by BRAS and their properties (rules set using CLI commands in l2tp server group)

router.mdb:

neighbor4 - IPv4 neighborDB, see "ARP Management" section for details

neighbor6 - IPv6 neighborDB, see "ARP Management" section for details

The maximum size of each .mdb file is set by the udr_size parameter.

Backup and Restore

Stop fastDPI

Creating a backup: save copies of the .mdb files from the SDR directory: /var/db/dpisdr/

Restoring a backup: copy the saved .mdb files to the SDR directory: /var/db/dpisdr/

Activation of Built-in UDR

UDR activation is mandatory when using dynamic IP addresses and to support subscribers with multiple IPs. No special activation of SDR is required – the necessary .mdb files are created automatically when the corresponding mode is enabled in fastdpi.conf.

UDR is activated using the configuration parameter in the file /etc/dpi/fastdpi.conf

udr=1

The created database is located in the directory /var/db/dpi

You can create a DB copy without stopping DPI using the backup command mdb_copy /var/db/dpi ./DB and then perform further manipulations on the DB copy.

Increasing the Size of UDR and SDR DB

By default, the size of the UDR and SDR DB is limited to 1GB. If your number of policing profiles exceeds 1 million, you need to increase the default size:

udr_size=2147483648

sets the DB size to 2GB

The built-in DB does not require administration and is fault-tolerant. However, in rare cases the built-in DB has been corrupted. In this case, the following actions are possible:

DB Recovery with Data Migration

Stop fastDPI

service fastdpi stop

Run the script

rm -rf /var/db/dpi.recover/*
mkdir -p /var/db/dpi.recover/tmp
for table in $(mdb_dump -l /var/db/dpi); do
mdb_dump -f /var/db/dpi.recover/tmp/dump.$table.load -s $table /var/db/dpi
mdb_load -f /var/db/dpi.recover/tmp/dump.$table.load /var/db/dpi.recover
done
rm /var/db/dpi/lock.mdb
mv /var/db/dpi/data.mdb /var/db/dpi.recover/data.mdb.backup
cp -f /var/db/dpi.recover/data.mdb /var/db/dpi/

Start fastDPI

service fastdpi start

Deleting the DB and Reloading Data from External Source (e.g., billing system)

Stop fastDPI

service fastdpi stop

Delete DB

/bin/rm /var/db/dpi/*

Start fastDPI

service fastdpi start

Reload all settings into the DB using your own scripts

Experimental Section

DB Recovery in fdpi_ctrl Command Format

Stop fastDPI

service fastdpi stop

Run the script

mdb_dump -p -a -f dump.sh /var/db/dpi
/bin/rm /var/db/dpi/*

Start fastDPI

service fastdpi start

Run the script

chmod +x dump.sh
./dump.sh

Recovery of Individual DB Tables in fdpi_ctrl Command Format

Stop fastDPI

service fastdpi stop

Run the script

for table in $(mdb_dump -l /var/db/dpi); do
mdb_dump -p -f dump.$table.sh -s $table /var/db/dpi
done
/bin/rm /var/db/dpi/*

Start fastDPI

service fastdpi start

Select the required scripts and run them, example

chmod +x dump.bindings.sh
./dump.bindings.sh