系統環境:
CentOS 5.4
dahdi-linux-current
Asterisk-1.6.1-20
Linux domU-12-31-39-14-69-89 2.6.18-xenU-ec2-v1.0 (uname -a)
請參考這篇教學 Install Elastix on Amazon EC2
// 檢查並安裝所有相依性的套件
# rpm -q gcc-c++ zlib-devel openssl-devel ncurses-devel gtk2-devel iksemel-devel libogg-devel libvorbis-devel curl-devel unixODBC-devel libtool-ltdl-devel net-snmp-devel bzip2-devel newt-devel lm_sensors-devel openldap-devel postgresql-devel gtk+-devel mysql-server mysql-devel # yum install gcc-c++ zlib-devel openssl-devel ncurses-devel gtk2-devel iksemel-devel libogg-devel libvorbis-devel curl-devel unixODBC-devel libtool-ltdl-devel net-snmp-devel bzip2-devel newt-devel lm_sensors-devel openldap-devel postgresql-devel gtk+-devel mysql-server mysql-devel # wget http://www.lfarkas.org/linux/packages/centos/5/i386/gstreamer/speex-1.2-0.10.rc1.i386.rpm # wget http://www.lfarkas.org/linux/packages/centos/5/i386/gstreamer/speex-devel-1.2-0.10.rc1.i386.rpm # wget http://www.lfarkas.org/linux/packages/centos/5/i386/gstreamer/speex-tools-1.2-0.10.rc1.i386.rpm # rpm -ivh speex-*.rpm
NOTES:
speex 套件請不要使用 yum 安裝。
// Install asterisk
# cd /usr/src # wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.1.20.tar.gz # tar xzf asterisk-1.6.1-20.tar.gz # cd asterisk-1.6.1.20/ # contrib/scripts/get_ilbc_source.sh ;安裝 iLBC codec # ./configure # make menuselect
NOTES:
* 檢查所有需要的模組項目是否不會呈現 XXXX,否則回上一步重新檢查需要的相依性套件。
*編譯模組的選單,選擇 Core Sound Packages,安裝所有項目(按 Enter),還有 Music On Hold File Packages,Extras Sound Packages 也都做相同的處理。
# make # make install # make samples # make config
// 檢查 asterisk 是否可執行
# asterisk -vvvvvvvvvvc CLI> stop now
// 安裝 asterisk-addons
# cd /usr/src # wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.6.1.4.tar.gz # tar asterisk-addons-1.6.1.4.tar.gz # cd asterisk-addons-1.6.1.4/ # make clean # ./configure # make menuselect
這裡的選單顯示有關與 MySQL 連結的所有模組是否可以安裝。
# make # make install # make samples
// 為了改善 asterisk 的安全性,設定為不使用 root 來執行
// 新增帳號 asterisk,群組 asterisk
# groupadd asterisk # useradd -r -d /var/lib/asterisk -g asterisk asterisk
// 修改 /etc/asterisk/asterisk.conf
# cd /etc/asterisk # vi asterisk.conf [directories] ;移除(!) astrundir => /var/run/asterisk # mkdir /var/run/asterisk
// 修改 /etc/init.d/asterisk
# vi /etc/init.d/asterisk
// 重設相關目錄檔案權限
# chown -R -L asterisk:asterisk /var/lib/asterisk # chown -R -L asterisk:asterisk /var/log/asterisk # chown -R -L asterisk:asterisk /var/run/asterisk # chown -R -L asterisk:asterisk /var/spool/asterisk # chown -R -L asterisk:asterisk /etc/asterisk # chmod -R 0755 /var/lib/asterisk # chmod -R 0755 /var/log/asterisk # chmod -R 0755 /var/run/asterisk # chmod -R 0755 /var/spool/asterisk # chmod 0775 /etc/asterisk # chmod -R 0664 /etc/asterisk/* # chmod +x /etc/init.d/asterisk
// 啟動 asterisk 服務
# chkconfig asterisk on # service asterisk start
因為 Amazon EC2 Instance 的系統如果有 shutdown,其所有的資料都不會被保留,也就是最初開啟新的 Instance 的那時的系統狀態;如果想隨時保留 asterisk 的所有資料包含有主程式、設定檔、佇列檔、語音留言等等,請繼續以下的章節。
首先說明,Amazon EC2 所提供可供用戶儲存資料的申請項目有二:EBS 及 S3,因為這兩種方式對用戶的使用方式有些不同,EBS 類似系統的內部磁碟,而 S3 就類似外部的儲存空間,EBS 僅供系統使用,而 S3 可直接由用戶存取,因此藉由這些特性,我們將所有 asterisk 會用到的所有目錄(包含主程式等),都放在 EBS,而 S3 僅用來放語音留言(Voicemail)。
// 透過 Amazon 申請一個 EBS (1GB) 空間
請參閱 Amazon 官方教學
// 使用 Elasticfox UI 掛載 EBS volume
Elasticfox UI > Instances > Select your instance > Attach an EBS volume
VOL ID = <所新增的 EBS volume>
Device = /dev/sdb
//檢查 EBS volume
# fdisk -l Disk /dev/sdb: 1073 MB, 1073741824 bytes 255 heads, 63 sectors/track, 130 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
// 格式化檔案系統
# yum install xfsprogs # mkfs.xfs -f /dev/sdb meta-data=/dev/sdb isize=256 agcount=8, agsize=32768 blks = sectsz=512 attr=0 data = bsize=4096 blocks=262144, imaxpct=25 = sunit=0 swidth=0 blks, unwritten=1 naming =version 2 bsize=4096 log =internal log bsize=4096 blocks=2560, version=1 = sectsz=512 sunit=0 blks, lazy-count=0 realtime =none extsz=4096 blocks=0, rtextents=0
// 新增 mount point 及開機設定
# mkdir /mnt/sdb-ast # echo "/dev/sdb /mnt/sdb-ast xfs noatime 0 0" >> /etc/fstab # mount /mnt/sdb-ast
// 複製 Asterisk 相關目錄至 EBS volume(/mnt/sdb-ast)
# service asterisk stop # cd /mnt/sdb-ast # mkdir etc # cp -a /etc/asterisk/ etc/ # mkdir -p var/lib # cp -a /var/lib/asterisk/ var/lib/ # mkdir -p var/spool # cp -a /var/spool/asterisk/ var/spool/ # mkdir -p var/log # cp -a /var/log/asterisk/ var/log/ # mkdir -p usr/lib # cp -a /usr/lib/asterisk/ usr/lib/
// 設定目錄連結
# cd /etc/ # mv asterisk/ asterisk_orig/ # ln -s /mnt/sdb-ast/etc/asterisk asterisk # cd /var/lib # mv asterisk/ asterisk_orig/ # ln -s /mnt/sdb-ast/var/lib/asterisk asterisk # cd /var/spool # mv asterisk/ asterisk_orig/ # ln -s /mnt/sdb-ast/var/spool/asterisk asterisk # cd /var/log # mv asterisk/ asterisk_orig/ # ln -s /mnt/sdb-ast/var/log/asterisk asterisk # cd /usr/lib # mv asterisk/ asterisk_orig/ # ln -s /mnt/sdb-ast/usr/lib/asterisk asterisk
// 移除舊目錄
# rm -rf /etc/asterisk_orig/ # rm -rf /var/lib/asterisk_orig/ # rm -rf /var/spool/asterisk_orig/ # rm -rf /var/log/asterisk_orig/ # rm -rf /usr/lib/asterisk_orig/
//