How to configure Realtime Database Connection on Asterisk on Oracle Linux 9.3
To Configure Realtime Database Connection On Asterisk On Oracle Linux 9.3
Introduction:
Configuring a real-time database connection on Asterisk involves setting up Asterisk to dynamically read its configuration and state information from a database instead of using static configuration files.
Procedure:
Step 1: Check the OS version by using the below command
[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3
Step 2: Check the status of asterisk service by using the below command
[root@linuxhelp ~]# systemctl status asterisk.service
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
Active: active (running) since Mon 2024-02-19 04:02:05 IST; 3 months 17 days ago
Docs: man:systemd-sysv-generator(8)
Process: 1001 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
Main PID: 1062
Tasks: 37 (limit: 21739)
Memory: 65.0M
CPU: 6.277s
CGroup: /system.slice/asterisk.service
├─1056 /bin/sh /usr/sbin/safe_asterisk
└─5831 /usr/sbin/asterisk -f -vvvg -c
Feb 19 04:02:05 linuxhelp systemd[1]: Starting LSB: Asterisk PBX...
Feb 19 04:02:05 linuxhelp asterisk[1001]: Starting asterisk:
Feb 19 04:02:05 linuxhelp systemd[1]: asterisk.service: Can't open PID file /run/asterisk/asterisk.pid (yet?) after start: Operation not permitted
Feb 19 04:02:05 linuxhelp systemd[1]: asterisk.service: Supervising process 1062 which is not our child. We'll most likely not notice when it exits.
Feb 19 04:02:05 linuxhelp systemd[1]: Started LSB: Asterisk PBX.
Step 3: Install the Mysql service by using the below command
[root@linuxhelp ~]# dnf install mysql* -y
Last metadata expiration check: 0:00:19 ago on Friday 07 June 2024 02:42:31 AM.
Dependencies resolved.
=============================================================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================================================
Installing:
mysql x86_64 8.0.36-1.el9_3 ol9_appstream 2.7 M
mysql-common x86_64 8.0.36-1.el9_3 ol9_appstream 101 k
mysql-errmsg x86_64 8.0.36-1.el9_3 ol9_appstream 523 k
mysql-release-el9 x86_64 1.0-1.el9 ol9_baseos_latest 14 k
mysql-selinux noarch 1.0.10-1.el9 ol9_appstream 35 k
mysql-server x86_64 8.0.36-1.el9_3 ol9_appstream 17 M
Upgrading:
selinux-policy noarch 38.1.35-2.0.2.el9_4 ol9_baseos_latest 57 k
selinux-policy-targeted noarch 38.1.35-2.0.2.el9_4 ol9_baseos_latest 7.8 M
Installing dependencies:
mecab x86_64 0.996-3.el9.4 ol9_appstream 384 k
protobuf-lite x86_64 3.14.0-13.el9 ol9_appstream 233 k
yum-utils noarch 4.3.0-11.0.1.el9_3 ol9_baseos_latest 53 k
Transaction Summary
=============================================================================================================================================================================================
Install 9 Packages
Upgrade 2 Packages
Total download size: 29 M
Is this ok [y/N]: y
Downloading Packages:
(1/11): mysql-release-el9-1.0-1.el9.x86_64.rpm 75 kB/s | 14 kB 00:00
(2/11): yum-utils-4.3.0-11.0.1.el9_3.noarch.rpm 256 kB/s | 53 kB 00:00
(3/11): mecab-0.996-3.el9.4.x86_64.rpm 1.6 MB/s | 384 kB 00:00
(4/11): mysql-common-8.0.36-1.el9_3.x86_64.rpm 2.4 MB/s | 101 kB 00:00
(5/11): mysql-selinux-1.0.10-1.el9.noarch.rpm 820 kB/s | 35 kB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 10 MB/s | 29 MB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: selinux-policy-targeted-38.1.35-2.0.2.el9_4.noarch 1/1
Preparing : 1/1
Installing : mysql-common-8.0.36-1.el9_3.x86_64 1/13
Upgrading : selinux-policy-38.1.35-2.0.2.el9_4.noarch 2/13
Running scriptlet: selinux-policy-38.1.35-2.0.2.el9_4.noarch 2/13
Running scriptlet: selinux-policy-targeted-38.1.35-2.0.2.el9_4.noarch 3/13
Upgrading : selinux-policy-targeted-38.1.35-2.0.2.el9_4.noarch 3/13
Running scriptlet: selinux-policy-targeted-38.1.35-2.0.2.el9_4.noarch 3/13
Running scriptlet: mysql-selinux-1.0.10-1.el9.noarch 4/13
Installing : mysql-selinux-1.0.10-1.el9.noarch 4/13
Running scriptlet: mysql-selinux-1.0.10-1.el9.noarch 4/13
libsemanage.semanage_direct_install_info: Overriding mysql module at lower priority 100 with module at priority 200.
Verifying : mysql-release-el9-1.0-1.el9.x86_64 1/13
Verifying : yum-utils-4.3.0-11.0.1.el9_3.noarch 2/13
Verifying : mecab-0.996-3.el9.4.x86_64 3/13
Verifying : mysql-8.0.36-1.el9_3.x86_64 4/13
Verifying : mysql-common-8.0.36-1.el9_3.x86_64 5/13
Upgraded:
selinux-policy-38.1.35-2.0.2.el9_4.noarch selinux-policy-targeted-38.1.35-2.0.2.el9_4.noarch
Installed:
mecab-0.996-3.el9.4.x86_64 mysql-8.0.36-1.el9_3.x86_64 mysql-common-8.0.36-1.el9_3.x86_64 mysql-errmsg-8.0.36-1.el9_3.x86_64 mysql-release-el9-1.0-1.el9.x86_64
mysql-selinux-1.0.10-1.el9.noarch mysql-server-8.0.36-1.el9_3.x86_64 protobuf-lite-3.14.0-13.el9.x86_64 yum-utils-4.3.0-11.0.1.el9_3.noarch
Complete!
Step 4: Check the status of MySQL service by using the below command
[root@linuxhelp ~]# systemctl status mysqld.service
○ mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; preset: disabled)
Active: inactive (dead)
Step 5: Start the mysql service by using the below command
[root@linuxhelp ~]# systemctl start mysqld.service
Step 6: Check the status of mysql service by using the below command
[root@linuxhelp ~]# systemctl status mysqld.service
● mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; preset: disabled)
Active: active (running) since Fri 2024-06-07 02:44:41 IST; 18s ago
Process: 8496 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 8518 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
Main PID: 8594 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 21739)
Memory: 456.2M
CPU: 7.404s
CGroup: /system.slice/mysqld.service
└─8594 /usr/libexec/mysqld --basedir=/usr
Jun 07 02:44:33 linuxhelp systemd[1]: Starting MySQL 8.0 database server...
Jun 07 02:44:33 linuxhelp mysql-prepare-db-dir[8518]: Initializing MySQL database
Jun 07 02:44:41 linuxhelp systemd[1]: Started MySQL 8.0 database server.
Step 7: Edit the res_config_mysql.conf file by using the below command
[root@linuxhelp ~]# vim /etc/asterisk/res_config_mysql.conf
Add those following lines
[general]
dbhost = 127.0.0.1
dbname = asterisk
dbuser = asteriskuser
dbpass = asteriskpass
dbport = 3306
Step 8: Edit the extconfig.conf file by using the below command
[root@linuxhelp ~]# vim /etc/asterisk/extconfig.conf
Add those following lines
[settings]
sippeers => mysql,asterisk,ast_sipfriends
sipusers => mysql,asterisk,ast_sipfriends
Step 9: Edit the sip.conf file by using the following command
[root@linuxhelp ~]# vim /etc/asterisk/sip.conf
Add those following lines
[general]
rtcachefriends=yes
rtupdate=yes
rtautoclear=yes
ignoreregexpire=yes
srvlookup=yes
Step 10: Reload the Asterisk service by using the below command
[root@linuxhelp ~]# asterisk -rx "module reload"
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to configure Realtime Database Connection on Asterisk 9.3. Your feedback is much welcome.
mysql -u asteriskuser -p asterisk < /usr/share/doc/asterisk/realtime/mysql/realtime.sql
sudo asterisk -rx "module reload"
Scalability: Easier to manage large configurations by centralizing them in a database.
Integration: Facilitates integration with other systems and applications.