在 FreePBX 下使用 RAMDisk 方式來改善電話錄音的效能。
原文:http://shyju.wordpress.com/2011/07/2...g-and-ramdisk/
Asterisk call recording is resource intensive especially when the number of calls in the PBX is high. If you record all the calls directly to the HDD in asterisk pbx and you got a large call volume (number of calls) then it will damage your PBX’s HDD very soon. On such cases using RAMDISK and seperate HDD may solve the problem.
Install freepbx. If you are not using SAN use 2 HDDs for better results. One for OS+asterisk and one as a storage for recorded files. Here I’m using /record as the storage location and /astrec as the mount point for RAMDISK. Format and mount the 2nd HDD to /record at the time of OS installation(or create an fstab entry if you are doing it later). After installation give write permission or assign asterisk user as the owner of /record & /astrec.
/bin/chown -R asterisk.asterisk /record /bin/mkdir /astrec /bin/chown -R asterisk.asterisk /astrec
After the freepbx installation edit “/boot/grub/grub.conf” and put the the ramdisk size.
#boot=/dev/hda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title Elastix (2.6.18-194.3.1.el5) root (hd0,0) kernel /vmlinuz-2.6.18-194.3.1.el5 ro root=LABEL=/ ramdisk_size=1000000 initrd /initrd-2.6.18-194.3.1.el5.img
Here I used RAMDISK size as 1GB(1000000) . The size depends on the number of calls,the average time for one call,and the recording format.
Remove the 3 directories from asterisk spool directory because we are going to use ramdisk instead of those.
rm -rf /var/spool/asterisk/monitor rm -rf /var/spool/asterisk/system rm -rf /var/spool/asterisk/tmp
Edit the file “/etc/rc.local” and append the below code.
#Put this in rc.local to create ramdisk during bootup /sbin/mke2fs -m 0 /dev/ram0 /bin/mount /dev/ram0 /astrec /bin/mkdir /astrec/monitor /bin/mkdir /astrec/system /bin/mkdir /astrec/tmp /bin/chown -R asterisk.asterisk /astrec #For more infor on ramdisk: #http://www.vanemery.com/Linux/Ramdisk/ramdisk.html #Link asterisk's default folders to our ramdisk /bin/ln -s /astrec/system /var/spool/asterisk /bin/ln -s /astrec/tmp /var/spool/asterisk /bin/ln -s /astrec/monitor /var/spool/asterisk
At the time of booting the above lines in rc.local creates RAMDISK and mount it to “/astrec”.
Create the file “/var/lib/asterisk/agi-bin/mvrec.sh” and put the below contents.
#!/bin/bash /bin/mv $1/$2.$3 /record 3>&1 1>&2 2>&3 | tee /var/log/asterisk/mvrec.log
The above code will transfer the recorded file from RAMDISK to the location /record., Use the file “/var/log/asterisk/mvrec.log” for troubleshooting purpose. Make the script executable.
chmod 755 /var/lib/asterisk/agi-bin/mvrec.sh
Log in to freepbx interface and change the General Settings as shown in screen shot.
Extension Recording Override:Enabled Call recording format: wav Recording Location: /var/spool/asterisk/monitor/ Run after record: /var/lib/asterisk/agi-bin/mvrec.sh ^{MIXMON_DIR} ^{CALLFILENAME} ^{MIXMON_FORMAT}
[mvrec]