5. Asterisk 15 LXC basic configuration of realtime

Asterisk 15 installation on Centos 7 and basic configuration of realtime

 

Данный опус является частью единого цикла заметок o CLI.  Для его написания использовалось множество различных источников (скилы крутых специалистов, статьи с тематических сайтов, техническая документация, комментарии с форумов и социальных сетей и т. д и т. п.).  К сожалению, указать все источники точно не представляется  возможным!  По этому,  в конце заметки,  будет указана ссылка только  на основной источник.  Материалы,  использованные для написания заметки, изменялись автором под конкретную задачу! Вам, скорее всего, тоже  придется поступить аналогичным образом для получения желаемого результата) 

 

Нужна консультация или помощь в решении IT вопроса? Пожалуйста, в таком случае  заполните форму запроса на Sytes.ru!

В статье предполагается, что сервер терминалов уже прошел предварительную настройку и работает. Все скриншоты соответствуют Windows Server 2016.

Данная реализация позволяет хранить конфигурацию АТС и данные(звонки и логи)  в двух БД.

Disabled SELinux

sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config

Dependencies

 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
 yum install -y kernel-devel kernel-headers
yum install -y e2fsprogs-devel  keyutils-libs-devel krb5-devel libogg \
libselinux-devel libsepol-devel libxml2-devel libtiff-devel gmp php-pear \
php php-gd php-mysql php-pdo php-mbstring ncurses-devel \
mysql-connector-odbc unixODBC unixODBC-devel \
audiofile-devel libogg-devel openssl-devel zlib-devel  \
perl-DateManip sox git wget net-tools psmisc
yum install -y gcc gcc-c++ make gnutls-devel \
libxml2-devel ncurses-devel subversion doxygen \
texinfo curl-devel net-snmp-devel neon-devel  \
uuid-devel libuuid-devel sqlite-devel sqlite \
speex-devel gsm-devel libtool libtool-ltdl libtool-ltdl-devel \
libsrtp libsrtp-devel xmlstarlet
Update
yum update -y
Reboot
 reboot

Installing MySQL (mariadb)

1: Install Mariadb (MySQL)

yum -y install mariadb-server mariadb mariadb-devel

2: Start and enable Mariadb (MySQL)

 systemctl start mariadb.service
 systemctl enable mariadb.service

3: Optional. Run the interactive configurator (You will be prompted for a root password and other)

mysql_secure_installation

Installing Asterisk

 cd /usr/src
 wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-15-current.tar.gz
 tar zxvf asterisk-15-current.tar.gz
 cd asterisk*
 contrib/scripts/get_mp3_source.sh
 contrib/scripts/install_prereq install
 ./configure --with-pjproject-bundled --with-crypto --with-ssl=ssl --with-srtp
 make menuselect

Set options as you need

In the screenshots, shown, the minimum installation of add-ons, codecs and channel drivers


Install

 make && make install && make config && ldconfig

At the end of the installation, install the required set of configs

 make basic-pbx
 

Нажмите, чтобы отобразить 


Run an Asterisk on behalf of the same user

 sed -i 's/ASTARGS=""/ASTARGS="-U asterisk"/g'  /usr/sbin/safe_asterisk

Create an Asterisk user and change own

useradd -m asterisk &&
chown asterisk.asterisk /var/run/asterisk &&
chown -R asterisk.asterisk /etc/asterisk &&
chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk &&
chown -R asterisk.asterisk /usr/lib/asterisk

Let's check Asterisk

/etc/init.d/asterisk start
Starting asterisk (via systemctl):                         [  OK  ]
ps aux | grep asterisk
root       872  0.0  0.0 115300   780 ?        S    12:12   0:00 /bin/sh /usr/sbin/safe_asterisk
asterisk   881  2.4  0.9 1314384 36532 ?       Sl   12:12   0:01 /usr/sbin/asterisk -f -U asterisk -vvvg -c

If the prompt is:

 Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

just restart the sever and:

 asterisk -vvvr
 

Нажмите, чтобы отобразить 

Configuring ODBC

   yum install -y mysql-connector-odbc unixODBC unixODBC-devel

*for reference, was established during the preparation of the system.

Create a required databases and grant privileges

asteriskcdrdb
 mysqladmin -p create asteriskcdrdb
 mysql -p -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* to CDR_DB_USER@localhost identified by 'CDR_DB_PASSWORD';"
 mysql -p -e "FLUSH PRIVILEGES;"
 

asteriskcdrdb.cdr schema 


realtimedb
 mysqladmin -p create realtimedb
 mysql -p -e "GRANT ALL PRIVILEGES ON realtimedb.* to RT_DB_USER@localhost identified by 'RT_DB_PASSWORD';"
 mysql -p -e "FLUSH PRIVILEGES;"
 

realtimedb SQL schema 


Where CDR_DB_USERRT_DB_USER and CDR_DB_PASSWORDRT_DB_PASSWORD It's YOUR data.

insert into the odbc.ini file (create, if it does not exist)

cat >> /etc/odbc.ini << EOF
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/lib/mysql/mysql.sock
option=3
 
EOF

and

cat >> /etc/odbc.ini << EOF
[MySQL-realtimedb]
Description=MySQL connection to 'realtimedb' database
driver=MySQL
server=localhost
database=realtimedb
Port=3306
Socket=/var/lib/mysql/mysql.sock
option=3
 
EOF

Reference. What is the correct location of mysql.sock file on linux?

# mysql -e -p "show variables like 'socket';"
+---------------+---------------------------+
| Variable_name | VALUE                     |
+---------------+---------------------------+
| socket        | /var/lib/mysql/mysql.sock |
+---------------+---------------------------+

Asterisk Realtime Configuration

Enabled autoload modules

Hidden because of the length, please read. Important 

Restart Asterisk

 asterisk -rx 'core restart now'

Create Asterisk res_odbc config

 touch /etc/asterisk/res_odbc.conf &&
 chown asterisk. /etc/asterisk/res_odbc.conf
cat >> /etc/asterisk/res_odbc.conf << EOF
[realtimedb]
enabled => yes
dsn => MySQL-realtimedb
username => RT_DB_USER
password => RT_DB_PASSWORD
pre-connect => yes
 
[asteriskcdrdb]
enabled => yes
dsn => MySQL-asteriskcdrdb
username => CDR_DB_USER
password => CDR_DB_PASSWORD
pre-connect => yes
 
EOF
Check ODBC Connections
 asterisk -rx 'odbc show'

It's so good:

ODBC DSN Settings
-----------------
 
  Name:   realtimedb
  DSN:    MySQL-realtimedb
    Number of active connections: 1 (out of 1)
 
  Name:   asteriskcdrdb
  DSN:    MySQL-asteriskcdrdb
    Number of active connections: 1 (out of 1)
 

create /etc/asterisk/sorcery.conf

 touch /etc/asterisk/sorcery.conf &&
 chown asterisk. /etc/asterisk/sorcery.conf
cat >> /etc/asterisk/sorcery.conf << EOF
[res_pjsip] ; Realtime PJSIP configuration wizard
endpoint=realtime,ps_endpoints
auth=realtime,ps_auths
aor=realtime,ps_aors
domain_alias=realtime,ps_domain_aliases
contact=realtime,ps_contacts
 
[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips
 
EOF

Create /etc/asterisk/extconfig.conf

 touch /etc/asterisk/extconfig.conf &&
 chown asterisk. /etc/asterisk/extconfig.conf
cat >> /etc/asterisk/extconfig.conf << EOF
[settings]
sipusers => odbc,realtimedb,sippeers
sippeers => odbc,realtimedb,sippeers
 
dp_internal => odbc,realtimedb,dp_internal
dp_external => odbc,realtimedb,dp_external
dp_agents  => odbc,realtimedb,dp_agents
 
confbridge_static.conf => odbc,realtimedb,confbridge_ast_config
followme_static.conf => odbc,realtimedb,follow_ast_config
features_static.conf => odbc,realtimedb,feat_ast_config
 
ps_endpoints => odbc,realtimedb
ps_auths => odbc,realtimedb
ps_aors => odbc,realtimedb
ps_domain_aliases => odbc,realtimedb
ps_endpoint_id_ips => odbc,realtimedb
ps_contacts => odbc,realtimedb
 
queues => odbc,realtimedb
queue_members => odbc,realtimedb
queue_rules => odbc,realtimedb
 
EOF

Edit /etc/asterisk/extensions.conf

Enabled static storage configuration.
Include file 'extensions_rt.conf'

cat >> /etc/asterisk/extensions.conf << EOF
[general]
static=yes
 
#include extensions_rt.conf
 
EOF

Create /etc/asterisk/extensions_rt.conf

 touch /etc/asterisk/extensions_rt.conf &&
 chown asterisk. /etc/asterisk/extensions_rt.conf
cat >> /etc/asterisk/extensions_rt.conf << EOF
[from-internal]
switch => Realtime/internal@dp_internal
 
[from-external]
switch => Realtime/external@dp_external
 
[from-agents] 
switch => Realtime/agents@dp_agents
 
EOF

Create /etc/asterisk/sip.conf

 touch /etc/asterisk/sip.conf &&
 chown asterisk. /etc/asterisk/sip.conf

Источник: https://asterisk-pbx.ru/wiki/asterisk_install/asterisk-15_centos-7_realtime

  • Asterisk 15 LXC
  • 0 Uživatelům pomohlo
Byla tato odpověď nápomocná?

Související články

Настройка аsterisk 17 - SIP АТС LXC CentOS 7

  Здесь  показана рабочая инструкция, по которой можно выполнить настройка Аsterisk 17 для LXC...

Установка настроек, подключение абонентов и проверка внутренних звонков в Asterisk

Астериск у нас уже установлен. Для отладки использую бесплатную софтовую звонилку 3CXPhone 6-й...

Установка голосовой почты в Asterisk

Устанавливаем  голосовую почту в в Asterisk   Продолжаем наращивать функционал voip атс. В...

Установка asterisk в OS CentOS 7

Asterisk  и Freepbx  на Centos 7 Asterisk — бесплатное решение для организации voip телефонии....

Установка и настройка Freepbx в OS Сentos 7

Установка и настройка Freepbx на Сentos 7 Скачиваем последнюю версию Freepbx с сайта...