CentOS8 已经停更了,但还是有人用
尝试了下,特记录如下
CentOS8 最小安装,之后,是这样的:
- 下载国内 yum 源文件
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
yum clean all && yum makecache
- kamailio 编译
dnf group install -y "Development Tools"
yum install -y mysql-devel curl-devel
yum install -y wget curl autoconf openssl-libs openssl-devel libcurl-devel libxml2-devel pcre-devel uuid libuuid-devel libwebsockets-devel libunistring-devel
yum install -y jansson jansson-devel libev libevent-devel lua-devel libmaxminddb-devel
cd /usr/local/src
curl https://www.kamailio.org/pub/kamailio/5.7.6/src/kamailio-5.7.6_src.tar.gz -o kamailio-5.7.6_src.tar.gz
tar zxvf kamailio-5.7.6_src.tar.gz
cd kamailio-5.7.6
make include_modules="db_mysql http_client http_async_client jansson tls uuid utils app_lua geoip2 websocket" cfg
make all
make installln -sf /usr/local/etc/kamailio /etc/kamailio
- rtpengine 编译
yum install -y git
yum -y install dnf-plugins-core
yum config-manager --set-enabled PowerTools
dnf -y install https://download.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf -y localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm
dnf -y install --nogpgcheck https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
dnf -y install http://rpmfind.net/linux/epel/7/x86_64/Packages/s/SDL2-2.0.10-1.el7.x86_64.rpm
dnf -y install ffmpeg
dnf -y install ffmpeg-devel
yum -y install iptables-devel kernel-devel kernel-headers xmlrpc-c xmlrpc-c-client
yum -y install kernel-devel
yum -y install glib2 glib2-devel gcc zlib zlib-devel openssl openssl-devel pcre pcre-devel libcurl libcurl-devel xmlrpc-c-devel libwebsockets-devel
yum -y install libevent-devel glib2-devel json-glib-devel gperf gperftools-libs gperftools gperftools-devel libpcap libpcap-devel git hiredis hiredis-devel redis perl-IPC-Cmd
yum -y install spandsp-devel spandsp
yum -y install epel-release
yum -y install elfutils-libelf-devel gcc-toolset-9-elfutils-libelf-devel
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
cd /usr/local/src
git clone https://github.com/sipwise/rtpengine.git -b mr9.5.8
cd /usr/local/src/rtpengine/daemon/
makecp rtpengine /usr/bin
把 rtpengine 配置成服务,这个后面讲
- rtpengine 配置成服务
mkdir -p /etc/rtpengine
先编辑 /etc/rtpengine/rtpengine.conf, 内容为:
[rtpengine]
# 需要根据实际情况进行修改
interface=127.0.0.1
#interface=priv/127.0.0.1;pub/127.0.0.1!154.92.108.215
#interface=priv/ens3;pub/ens3!154.92.108.215
#foreground=true
log-stderr=true
listen-ng=127.0.0.1:2223
port-min=10000
port-max=20000
recording-dir=/tmp
#recording-method=pcap
#recording-format=eth
log-level=6
delete-delay=30
log-facility=local1
#listen-http=LOCAL_IP:8222
编辑 /lib/systemd/system/rtpengine.service, 内容为:
[Unit]
Description=Kernel based rtp proxy
#After=syslog.target
After=network-online.target
#After=iptables.service
Requires=network-online.target
[Service]
Type=forking
PIDFile=/var/run/rtpengine.pid
#EnvironmentFile=-/etc/sysconfig/rtpengine
ExecStart=/usr/bin/rtpengine --no-log-timestamps --pidfile /var/run/rtpengine.pid --config-file /etc/rtpengine/rtpengine.conf
User=root
Group=root
SyslogFacility=local1
LimitNOFILE=150000
#TimeoutSec=45s
#Restart=always
RestartSec=3s
TimeoutSec=15s
Restart=on-failure
[Install]
WantedBy=multi-user.target
接下来运行下面的命令:
systemctl daemon-reload
systemctl enable rtpengine
systemctl start rtpengine
- kamailio 配置成服务
编辑 /lib/systemd/system/kamailio.service,内容为:
[Unit]
Description=Kamailio - the Open Source SIP Server
Wants=network-online.target
After=network-online.target
[Service]
Type=forking
User=root
Group=root
#Environment='CFGFILE=/etc/kamailio/kamailio.cfg'
#Environment='SHM_MEMORY=64'
#Environment='PKG_MEMORY=8'
#EnvironmentFile=-/etc/default/kamailio
#EnvironmentFile=-/etc/default/kamailio.d/*
# PIDFile requires a full absolute path
PIDFile=/run/kamailio/kamailio.pid
# ExecStart requires a full absolute path
ExecStart=/usr/local/sbin/kamailio -P /run/kamailio/kamailio.pid -m 2048 -M 64 --atexit=no
Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable kamailio
systemctl start kamailio
- syslog 配置
local0.* /var/log/kamailio.log
local1.* /var/log/rtpengine.log
还要配置 syslog 轮转
请参考相关资料,不难
附我的 /etc/rsyslog.conf
# /etc/rsyslog.conf configuration file for rsyslog
#
# For more information install rsyslog-doc and see
# /usr/share/doc/rsyslog-doc/html/configuration/index.html
#################
#### MODULES ####
#################
module(load="imuxsock") # provides support for local system logging
module(load="imklog") # provides kernel logging support
#module(load="immark") # provides --MARK-- message capability
# provides UDP syslog reception
#module(load="imudp")
#input(type="imudp" port="514")
# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")
###########################
#### GLOBAL DIRECTIVES ####
###########################
#
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog
#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf
###############
#### RULES ####
###############
#
# Log anything besides private authentication messages to a single log file
#
*.*;auth,authpriv.none;local0.none;local1.none -/var/log/syslog
#
# Log commonly used facilities to their own log file
#
auth,authpriv.* /var/log/auth.log
cron.* -/var/log/cron.log
kern.* -/var/log/kern.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
#
# Emergencies are sent to everybody logged in.
#
*.emerg :omusrmsg:*
local0.* /var/log/kamailio.log
local1.* /var/log/rtpengine.log
附 /etc/logrotate.d/kam_rtpe
{
missingok
daily
copytruncate
rotate 7
notifempty
}
- sngrep 安装
yum install -y https://packages.irontec.com/centos/8/x86_64/sngrep-1.4.7+20200521.20+b132ce9-0.el8.x86_64.rpm
- 参考链接:
https://github.com/fredposner/scripts/blob/master/kamailio/centos8_install.md