I recently wrote a document for my team to install asterisk on two failover servers.
/etc/network/interfaces
auto eth0
iface eth0 inet static
address 172.17.250.201
netmask 255.255.0.0
gateway 172.17.1.1
dns-nameserver 172.18.99.251 172.18.99.252 172.18.98.150
dns-search {ourdomain}
#Update and Install applications and dependancies
apt-get update
apt-get dist-upgrade
shutdown -r now
apt-get install keepalived ntp mysql-server mysql-client unixODBC unixODBC-dev libmyodbc php5 php5-cli php5-mysql phpmyadmin festival build-essential subversion libncurses5-dev libssl-dev libxml2-dev libsqlite3-dev uuid-dev vim-nox linux-headers-uname -r libjansson-dev libiksemel-dev libssl-dev wget libxml2-dev sox libsox-fmt-all libcurl4-openssl-dev libneon27-dev libical-dev
shutdown -r now
#Copy source code to /usr/src (core and extra sounds can be found at downloads.asterisk.org/pub/telep ⊠/releases/)
tar zxvf libpri-1.4-current.tar.gz
tar zxvf dahdi-linux-complete-current.tar.gz
tar zxvf asterisk-13.5.0.tar.gz
#Copy sound files to /usr/src/asterisk-13.5.0/sounds because the firewall will block downloads
cp /usr/src/asterisk-core-sounds-en-* /usr/src/asterisk-13.5.0/sounds/
cp /usr/src/asterisk-extra-sounds-en-* /usr/src/asterisk-13.5.0/sounds/
cp /usr/src/asterisk-moh-opsound-* /usr/src/asterisk-13.5.0/sounds/
#Install libpri
cd /usr/src/libpri-1.4.15
make
make install
#Install dahdi
cd /usr/src/dahdi-linux-complete-2.10.2+2.10.2
make
make install
make config
#Install asterisk
cd /usr/src/asterisk-13.5.0
./configure
make menuconfig
#Change to ODBC_STORAGE under Voicemail Build Options
#Add All *EN-WAV *EN-ULAW *EN-ALAW *EN-GSM *EN-G722 files under Core Sound Packages
#Add All *EN-WAV *EN-ULAW *EN-ALAW *EN-GSM *EN-G722 files under Music On Hold File Packages
#Add All *EN-WAV *EN-ULAW *EN-ALAW *EN-GSM *EN-G722 files under Extra Sound Packages
make
make install
make config
shutdown -r now
#Copy /etc/asterisk/* from another server
scp * mkozusnik@172.17.250.202:/etc/asterisk/
#Copy /var/lib/asterisk/agi-bin/* from another server
scp * mkozusnik@172.17.250.202:/var/lib/asterisk/agi-bin/
#Copy /etc/keepalived/keepalived.conf from another serverâŠchange virtual ip in the file and make the priority lower on the second server
nano /etc/odbc.ini
[asterisk-connector]
Description = MySQL connection to âasteriskâ database
Driver = MySQL
Database = asterisk
Server = localhost
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
nano /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1
shutdown -r now
#Create database user, replication user, and asterisk database.
#Set up mysql replication
nano /etc/my/my.cnf
#Comment out bindaddr
#bindaddr 127.0.0.1
#Change server section
#Set server-id to 1 or 2 depending on which server youâre setting up.
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1
local-infile = 0
binlog-format = mixed
#Restart MySQL
/etc/init.d/mysql restart
#Once both servers are set up, set up the replication.
#2
mysql> show master status;
±-----------------±---------±-------------±-----------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
±-----------------±---------±-------------±-----------------+
| mysql-bin.000001 | 107 | | |
±-----------------±---------±-------------±-----------------+
1 row in set (0.00 sec)
#1
stop slave;
CHANGE MASTER TO MASTER_HOST = â172.17.250.202â, MASTER_USER = âreplicatorâ, MASTER_PASSWORD = â--------â, MASTER_LOG_FILE = âmysql-bin.000001â, MASTER_LOG_POS = 107;
start slave;
show slave status\G;
#1
mysql> show master status;
±-----------------±---------±-------------±-----------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
±-----------------±---------±-------------±-----------------+
| mysql-bin.000020 | 40159 | | |
±-----------------±---------±-------------±-----------------+
1 row in set (0.00 sec)
#2
stop slave;
CHANGE MASTER TO MASTER_HOST = â172.17.250.201â, MASTER_USER = âreplicatorâ, MASTER_PASSWORD = â--------â, MASTER_LOG_FILE = âmysql-bin.000020â, MASTER_LOG_POS = 40159;
start slave;
show slave status\G;
#Export database from another server to a sql file
#Import database to this cluster
#To allow more open files.
nano /etc/security/limits.conf
#Add
root soft nofile 40000
root hard nofile 40000
nano /etc/pam.d/common-session
#Add
session required pam_limits.so