Difference between revisions of "External Recordings Server"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(32 intermediate revisions by 6 users not shown)
Line 4: Line 4:


<br>
<br>
<big><big>'''NOTE: Configuration applies ONLY for fresh CentOS server.'''</big></big>
<big><big>'''NOTE: Configuration applies for fresh CentOS 6 or CentOS 7 server.'''</big></big>


<br>
<br>
==Configuration in GUI==
==Configuration in GUI and Asterisk servers==


External Recordings Server can be configured in '''Recordings -> Settings'''
External Recordings Server can be configured in '''ADDONS -> Recordings -> Settings'''


[[File:Recordings external server.png]]
[[File:Recordings external server.png]]
Line 16: Line 16:


'''NOTE: make sure that servers are configured with SSH keys! Login by password will not work for External Recordings Server.'''<br>
'''NOTE: make sure that servers are configured with SSH keys! Login by password will not work for External Recordings Server.'''<br>
'''This must be done on each GUI and Asterisk server!!!


External recordings server must be accessible using both root (/root/.ssh/id_rsa) and special GUI /var/www/.ssh/id_rsa) SSH keys.
Just execute script below and it will check SSH keys and connectivity and will print exact command you need to enter for correct configuration. Make sure that External Recordins Server details: (IP, Port, Login) are already entered as shown in sreenshot above before executing these commands:
svn update /usr/src/mor
On Centos 6:
/usr/src/mor/x16/maintenance/test_fix_scripts/various/check_external_recordings_server_access.sh
On Centos 7:
/usr/src/mor/x16/maintenance/test_fix_scripts_c7/various/check_external_recordings_server_access.sh
<br>
<br>
In '''SETTINGS -> Billing -> Servers''' add new server, where
"Hostname for SIP" and "Server IP for SIP" are External Recordings Server IP,
"Type" is "Other",
"GUI" and "DB" are disables (red cross).
<br>
==Configuration in Database server==
In Database Server create MySQL user for External Recordings Server:
  CREATE USER 'mor'@''''IP_OF_RECORDINGS_SERVER'''' IDENTIFIED BY 'mor';
  GRANT ALL PRIVILEGES ON `mor`.* TO 'mor'@''''IP_OF_RECORDINGS_SERVER'''' WITH GRANT OPTION ;
<br>
==Configuration in External Recordings server==
==Configuration in External Recordings server==


1. Dowload sources:
1. Install required packages and dowload sources:
 
yum -y install subversion gcc wget perl-IO-Socket-SSL
svn co http://svn.kolmisoft.com/mor/install_script/trunk/ /usr/src/mor
 
2. Install Apache (change MOR version accordingly in the script):


  yum -y install subversion
'''#Centos 6 only'''
  svn co http://svn.kolmisoft.com/mor/install_script/trunk/ /usr/src/mor
/usr/src/mor/x16/gui/apache_install.sh
/usr/src/mor/x16/gui/apache_uid_fix.sh
iptables -F
/etc/init.d/iptables save


2. Install GNU Compiler Collection:
'''#Centos 7 only'''
/usr/src/mor/x16/gui/apache_install_c7.sh
/usr/src/mor/x16/gui/apache_uid_fix_c7.sh
/usr/src/mor/x16/gui/rvm_install_c7.sh
/usr/src/mor/x16/gui/ruby_install_c7.sh


  yum -y install gcc
3. Install MySQL (change MOR version accordingly in the script):


3. Install Wget:
'''#Centos 6 only'''
/usr/src/mor/x16/mysql/mysql_install.sh


  yum -y install wget
'''#Centos 7 only'''
/usr/src/mor/x16/mysql/mysql_install_c7.sh


4. Install Apache (change MOR version accordingly in the script):
4. Create needed directories and permissions:


  /usr/src/mor/x8/gui/apache_install.sh
mkdir -p /var/log/mor
  /usr/src/mor/x8/gui/apache_uid_fix.sh
chmod 755 -R /var/log/mor
  iptables -F
mkdir -p /etc/mor/
  /etc/init.d/iptables save
mkdir -p /var/lib/asterisk/agi-bin/
mkdir -p /usr/local/mor/recordings/
chmod 777 -R /usr/local/mor/


5. Install MySQL (change MOR version accordingly in the script):
5. Install scripts (change MOR version accordingly in the script):


  /usr/src/mor/x8/mysql/mysql_install.sh
cd /usr/src/mor/x16/scripts/


6. Create needed directories and permissions:
gcc -Wall -Wunused -g -I/usr/include/mysql mor_record_remote.c -o mor_record_remote -lmysqlclient -lnsl -lm -lz -L/usr/lib/mysql -L/usr/lib64/mysql
cp -fr mor_record_remote /usr/local/mor


  mkdir -p /var/log/mor
gcc -Wall -g -I/usr/include/mysql mor_record_control.c -o mor_record_control -lmysqlclient -lnsl -lm -lz -L/usr/lib/mysql -L/usr/lib64/mysql
  chmod 777 -R /var/log/mor
cp -fr mor_record_control /usr/local/mor
  mkdir -p /etc/mor/
  mkdir -p /var/lib/asterisk/agi-bin/
  mkdir -p /usr/local/mor/recordings/
  chmod 777 -R /usr/local/mor/


7. Install scripts (change MOR version accordingly in the script):
gcc -g -Wall -o mor_delete_old_recordings mor_delete_old_recordings.c -L/usr/lib/mysql -L/usr/lib64/mysql -lmysqlclient -lm
cp -fr mor_delete_old_recordings /usr/local/mor/


  cd /usr/src/mor/x8/scripts/
gcc -Wall -g -o mor_server_loadstats mor_server_loadstats.c -L/usr/lib/mysql -L/usr/lib64/mysql -lmysqlclient -lpthread
  gcc -Wall -Wunused -g -I/usr/include/mysql mor_record_remote.c -o mor_record_remote -lmysqlclient -lnsl -lm -lz -L/usr/lib/mysql -L/usr/lib64/mysql
cp -fr mor_server_loadstats /usr/local/mor/mor_server_loadstats
  cp -fr mor_record_remote /usr/local/mor
cp -fr mor_server_loadstats_service /etc/init.d/mor_server_loadstats
  rm -rf mor_record_control
chmod +x /etc/init.d/mor_server_loadstats
  gcc -Wall -g -I/usr/include/mysql mor_record_control.c -o mor_record_control -lmysqlclient -lnsl -lm -lz -L/usr/lib/mysql -L/usr/lib64/mysql
chkconfig --add mor_server_loadstats
  cp -fr mor_record_control /usr/local/mor
chkconfig --level 2345 mor_server_loadstats on
 
  gcc -Wall -g -o mor_server_loadstats mor_server_loadstats.c -L/usr/lib/mysql -L/usr/lib64/mysql -lmysqlclient -lpthread
  cp -fr mor_server_loadstats /usr/local/mor/mor_server_loadstats
  cp -fr mor_server_loadstats_service /etc/init.d/mor_server_loadstats
  chmod +x /etc/init.d/mor_server_loadstats
  chkconfig --add mor_server_loadstats
  chkconfig --level 2345 mor_server_loadstats on


8. Install Lame (change MOR version accordingly in the script):
cp -fr cronjobs/mor_delete_old_recordings /etc/cron.d/


  /usr/src/mor/x8/helpers/lame_install.sh
cp -fr sendEmail /usr/local/mor/


9. Symlink directories:
/usr/src/mor/x16/maintenance/logrotates_enable.sh
echo "0 0 * * * root /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1" > /etc/cron.d/mor_logrotate
chmod 644 /etc/cron.d/mor_logrotate


  ln -s /usr/local/mor/recordings /var/www/html/recordings
service crond restart


10. Create configuration files:
6. Install Lame (change MOR version accordingly in the script):


  cd /etc/mor/
/usr/src/mor/x16/helpers/lame_install.sh
 
7. Symlink directories:
 
ln -s /usr/local/mor/recordings /var/www/html/recordings
 
8. Create configuration files:


Create file:
Create file:


  vi system.conf
vi /etc/mor/system.conf


Enter:
Enter:


  # database connection settings
# database connection settings
  dbhost = '''Database_server_IP'''
dbhost = '''Database_server_IP'''
  dbname = mor
dbname = mor
  dbuser = mor
dbuser = mor
  dbsecret = mor
dbsecret = mor
  dbport = 3306
dbport = 3306
 
  server_id = '''unique server ID; same as on GUI'''
server_id = '''unique server ID; same as on GUI'''


Save file.
Save file.
  cd /var/lib/asterisk/agi-bin/


Create file:
Create file:


  vi mor.conf
vi /var/lib/asterisk/agi-bin/mor.conf


Enter:
Enter:


  host = '''Database_server_IP'''
host = '''Database_server_IP'''
  db = mor
db = mor
  user = mor
user = mor
  secret = mor
secret = mor
  port = 3306
port = 3306


Save file.
Save file.


11. Edit ''/etc/httpd/conf/httpd.conf''
9. Edit ''/etc/httpd/conf/httpd.conf''
 
Change to:


Change from:
<Directory />
    Options FollowSymLinks
    AllowOverride '''All'''
</Directory>


  <Directory />
10. Run:
      Options FollowSymLinks
      AllowOverride '''None'''
  </Directory>


To:
chcon -R -h -t httpd_sys_content_t /var/www/html/recordings/
service httpd restart


  <Directory />
11. Edit ''/etc/selinux/config''
      Options FollowSymLinks
      AllowOverride '''All'''
  </Directory>


And change from:
Change from:


  # AllowOverride controls what directives may be placed in .htaccess files.
SELINUX=enforcing
  # It can be "All", "None", or any combination of the keywords:
  #  Options FileInfo AuthConfig Limit
  #
      AllowOverride '''None'''


To:
To:


      AllowOverride '''All'''
SELINUX=disabled
 
12. Run:
 
  chcon -R -h -t httpd_sys_content_t /var/www/html/recordings/
  service httpd restart


13. Edit ''/etc/selinux/config''
12. Reboot server:


Change from:
reboot


  SELINUX=enforcing
13. Centos 7 firewall configuration:
Checking which zone is active


To:
firewall-cmd --get-active-zones
public
  interfaces: eth0


  SELINUX=disable
Adding to the public zone IP and port


14. Reboot server:
firewall-cmd --zone=public --add-source=GUI_IP/32
firewall-cmd --zone=public --add-port=80/tcp


  reboot
Checking if it works and save to permanent


<br>
firewall-cmd --runtime-to-permanent


==Configuration in Database server==
If iptables are used instead or firewalld:
iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -s 11.11.11.11/32 -p tcp -j ACCEPT
iptables -A INPUT -s 11.11.11.11/32 -p udp -j ACCEPT
# repeat for each system server and your IP
iptables -A INPUT -j DROP
service iptables save


In Database Server create MySQL user for External Recordings Server:
14. Optionally, if you want to relocate old local recordings to an external server, after moving files, you have to update records in "recordings" table to local=0.


  CREATE USER 'mor'@''''IP_OF_RECORDINGS_SERVER'''' IDENTIFIED BY 'mor';
15. Install ntpd:
  GRANT ALL PRIVILEGES ON `mor`.* TO 'mor'@''''IP_OF_RECORDINGS_SERVER'''' WITH GRANT OPTION ;
yum -y install ntp
service ntpd start
chkconfig ntpd on


16. Install zabbix agent:
/usr/src/k_framework/helpers/zabbix/zabbix_agent_install.sh
<br>
<br>



Latest revision as of 09:19, 8 November 2024

Configuration

External Recordings Server allows to convert and store Recordings in external server thus increasing storage space on switch server (Asterisk). It will also reduce load on switch server because wav to mp3 convertion is executed in external server.


NOTE: Configuration applies for fresh CentOS 6 or CentOS 7 server.


Configuration in GUI and Asterisk servers

External Recordings Server can be configured in ADDONS -> Recordings -> Settings

Recordings external server.png

Check 'User external Server' checkbox, enter external server IP, SSH port and login username.

NOTE: make sure that servers are configured with SSH keys! Login by password will not work for External Recordings Server.
This must be done on each GUI and Asterisk server!!!

External recordings server must be accessible using both root (/root/.ssh/id_rsa) and special GUI /var/www/.ssh/id_rsa) SSH keys. Just execute script below and it will check SSH keys and connectivity and will print exact command you need to enter for correct configuration. Make sure that External Recordins Server details: (IP, Port, Login) are already entered as shown in sreenshot above before executing these commands:

svn update /usr/src/mor

On Centos 6:

/usr/src/mor/x16/maintenance/test_fix_scripts/various/check_external_recordings_server_access.sh

On Centos 7:

/usr/src/mor/x16/maintenance/test_fix_scripts_c7/various/check_external_recordings_server_access.sh


In SETTINGS -> Billing -> Servers add new server, where

"Hostname for SIP" and "Server IP for SIP" are External Recordings Server IP,

"Type" is "Other",

"GUI" and "DB" are disables (red cross).

Configuration in Database server

In Database Server create MySQL user for External Recordings Server:

 CREATE USER 'mor'@'IP_OF_RECORDINGS_SERVER' IDENTIFIED BY 'mor';
 GRANT ALL PRIVILEGES ON `mor`.* TO 'mor'@'IP_OF_RECORDINGS_SERVER' WITH GRANT OPTION ;


Configuration in External Recordings server

1. Install required packages and dowload sources:

yum -y install subversion gcc wget perl-IO-Socket-SSL
svn co http://svn.kolmisoft.com/mor/install_script/trunk/ /usr/src/mor

2. Install Apache (change MOR version accordingly in the script):

#Centos 6 only
/usr/src/mor/x16/gui/apache_install.sh
/usr/src/mor/x16/gui/apache_uid_fix.sh
iptables -F
/etc/init.d/iptables save
#Centos 7 only
/usr/src/mor/x16/gui/apache_install_c7.sh
/usr/src/mor/x16/gui/apache_uid_fix_c7.sh
/usr/src/mor/x16/gui/rvm_install_c7.sh
/usr/src/mor/x16/gui/ruby_install_c7.sh

3. Install MySQL (change MOR version accordingly in the script):

#Centos 6 only
/usr/src/mor/x16/mysql/mysql_install.sh
#Centos 7 only
/usr/src/mor/x16/mysql/mysql_install_c7.sh

4. Create needed directories and permissions:

mkdir -p /var/log/mor
chmod 755 -R /var/log/mor
mkdir -p /etc/mor/
mkdir -p /var/lib/asterisk/agi-bin/
mkdir -p /usr/local/mor/recordings/
chmod 777 -R /usr/local/mor/

5. Install scripts (change MOR version accordingly in the script):

cd /usr/src/mor/x16/scripts/
gcc -Wall -Wunused -g -I/usr/include/mysql mor_record_remote.c -o mor_record_remote -lmysqlclient -lnsl -lm -lz -L/usr/lib/mysql -L/usr/lib64/mysql
cp -fr mor_record_remote /usr/local/mor
gcc -Wall -g -I/usr/include/mysql mor_record_control.c -o mor_record_control -lmysqlclient -lnsl -lm -lz -L/usr/lib/mysql -L/usr/lib64/mysql
cp -fr mor_record_control /usr/local/mor
gcc -g -Wall -o mor_delete_old_recordings mor_delete_old_recordings.c -L/usr/lib/mysql -L/usr/lib64/mysql -lmysqlclient -lm
cp -fr mor_delete_old_recordings /usr/local/mor/
gcc -Wall -g -o mor_server_loadstats mor_server_loadstats.c -L/usr/lib/mysql -L/usr/lib64/mysql -lmysqlclient -lpthread
cp -fr mor_server_loadstats /usr/local/mor/mor_server_loadstats
cp -fr mor_server_loadstats_service /etc/init.d/mor_server_loadstats
chmod +x /etc/init.d/mor_server_loadstats
chkconfig --add mor_server_loadstats
chkconfig --level 2345 mor_server_loadstats on
cp -fr cronjobs/mor_delete_old_recordings /etc/cron.d/
cp -fr sendEmail /usr/local/mor/
/usr/src/mor/x16/maintenance/logrotates_enable.sh
echo "0 0 * * * root /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1" > /etc/cron.d/mor_logrotate
chmod 644 /etc/cron.d/mor_logrotate
service crond restart

6. Install Lame (change MOR version accordingly in the script):

/usr/src/mor/x16/helpers/lame_install.sh

7. Symlink directories:

ln -s /usr/local/mor/recordings /var/www/html/recordings

8. Create configuration files:

Create file:

vi /etc/mor/system.conf

Enter:

# database connection settings
dbhost = Database_server_IP
dbname = mor
dbuser = mor
dbsecret = mor
dbport = 3306

server_id = unique server ID; same as on GUI

Save file.

Create file:

vi /var/lib/asterisk/agi-bin/mor.conf

Enter:

host = Database_server_IP
db = mor
user = mor
secret = mor
port = 3306

Save file.

9. Edit /etc/httpd/conf/httpd.conf

Change to:

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

10. Run:

chcon -R -h -t httpd_sys_content_t /var/www/html/recordings/
service httpd restart

11. Edit /etc/selinux/config

Change from:

SELINUX=enforcing

To:

SELINUX=disabled

12. Reboot server:

reboot

13. Centos 7 firewall configuration: Checking which zone is active

firewall-cmd --get-active-zones
public
 interfaces: eth0

Adding to the public zone IP and port

firewall-cmd --zone=public --add-source=GUI_IP/32
firewall-cmd --zone=public --add-port=80/tcp

Checking if it works and save to permanent

firewall-cmd --runtime-to-permanent

If iptables are used instead or firewalld:

iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -s 11.11.11.11/32 -p tcp -j ACCEPT
iptables -A INPUT -s 11.11.11.11/32 -p udp -j ACCEPT
# repeat for each system server and your IP
iptables -A INPUT -j DROP

service iptables save

14. Optionally, if you want to relocate old local recordings to an external server, after moving files, you have to update records in "recordings" table to local=0.

15. Install ntpd:

yum -y install ntp
service ntpd start
chkconfig ntpd on

16. Install zabbix agent:

/usr/src/k_framework/helpers/zabbix/zabbix_agent_install.sh


Troubleshooting

If Recordings are not displayed in GUI check the following log files in both servers:

/var/log/mor/mor_record_file.log
/var/log/mor/record_file.log