一 系统解析
OAI开源代码分为两部分:核心网EPC(openair-cn)+基站eNB(openairinterface5g)。EPC中包括MME/HSS/SPGW等核心网的功能模块;
二 系统环境
基站eNB(openairinterface5g)都搭建在Ubuntu 14.04.2TLS上, 核心网EPC(openair-cn)搭建在Ubuntu 16.04.2上,搭建EPC的系统需要将内核换成4.7。
三 安装步骤
3.1准备工作
1)通过sudo gedit /etc/apt/sources.list进入源文件,替换源。推荐使用阿里源(国内速度较快,也可根据实际情更换其他源)。
切换到源文件所在路径:cd /etc/apt
将sources.list备份到sources.list.bak:sudo cp sources.list sources.list.bak
打开文件,把原来内容替换成以下内容:sudo gedit sources.list(参考网址:阿里镜像源)
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
更新软件源:sudo apt-get update
2)安装git (便于以后从git上下载资源):
下载安装git:sudoapt-get install git
3)从git下载并安装linux4.7版本的内核:(uname -r :查看你的内核版本,大于4.7就不用重新下载)
cd /usr/src
git clone https://gitlab.eurecom.fr/oai/linux-4.7.x.git
cd linux-4.7.x
sudo dpkg -i linux-headers-4.7.7-oaiepc_4.7.7-oaiepc-10.00.Custom_amd64.deb linux-image-4.7.7-oaiepc_4.7.7-oaiepc-10.00.Custom_amd64.deb
内核安装完成重启电脑,uname -r查看当前的内核版本。(出现4.7.7-oaiepc即可)
四.准备工作结束,开始正式安装配置
1)下载源码
普通用户(非root用户),cd ~ 的意思是进入用户主目录,工作目录就在 /home/abc,直接克隆,这样源码包就位于/home/abc中
进入用户主目录:cd ~
克隆下载源码:git clone https://gitlab.eurecom.fr/oai/openair-cn.git
如果出现http缓存不够的情况,执行以下命令设置缓存空间:
git config --global http.postBuffer 524288000
2)配置FQDN(全域名)
执行:su root,输入密码,切换到root用户
执行hostname 查询主机名
执行sudo gedit /etc/hosts,在文件开头加上下面三句
127.0.0.1 localhost
127.0.1.1 主机名.openair4G.eur 主机名 (#假设你的hostname叫buntu,这里就是127.0.1.1 ubuntu.openair4G.eur ubuntu)
127.0.1.1 hss.openair4G.eur hss
编辑完之后,执行hostname -f,查看主机名是否为:主机名.openair4G.eur
3)安装额外软件包,已经有的可以不用安装
3.1) 安装apache2:
sudo apt-get install apache2
测试apache2:
浏览器访问 localhost或者127.0.0.1 会出现apache2主页
3.2) 安装php
apt-get install php7.0
apt-get install libapache2-mod-php7.0
重启apache2: service apache2 restart 或者 sudo/etc/init.d/apache2 restart
测试php
在/var/www/html里面新建info.php
vim /var/www/html/info.php或者 gedit /var/www/html/info.php
在该文件里添加php语句: 保存退出
然后浏览器访问localhost/info.php或者127.0.0.1/info.php 浏览器会显示hello world页面
3.3) 安装mysql
sudo apt-get install mysql-server mysql-client
测试mysql
输入 mysql –uroot –p 输入安装mysql时设置的root密码
会出现mysql操作界面
3.4) 安装 phpmyadmin
sudo apt-get install phpmyadmin
然后
sudo ln -s /usr/share/phpmyadmin /var/www/html
测试phpmyadmin
然后浏览器访问localhost/phpmyadmin或者127.0.0.1/phpmyadmin 浏览器会显示数据库登录页面
如果报错:mbstringextension is missing.Please check your PHP configuration.
解决办法:
将/etc/php/7.0/mods-available/json.ini文件里第二行的分号去掉
然后重启apache2(service apache2 restart)
4)退出root用户,再执行cd ~ ,进去EPC源码文件夹openair-cn ,执行自动安装命令,如果没红色报错,表示安装成功
执行:cd openair-cn
git checkout develop
git pull
cd scripts
./build_mme -i
./build_hss -i
./build_spgw -i
5)配置EPC
5.1)执行如下命令,将配置文件放到该放的位置。由于源码版本不同大小写不同,具体情况看openair-cn文件夹里面是大写还是小写。我用的是develop版本,是小写。
5.2)执行以下命令
sudo mkdir -p /usr/local/etc/oai/freeDiameter
sudo cp ~/openair-cn/etc/mme.conf /usr/local/etc/oai
sudo cp ~/openair-cn/etc/hss.conf /usr/local/etc/oai
sudo cp ~/openair-cn/etc/spgw.conf /usr/local/etc/oai
sudo cp ~/openair-cn/etc/acl.conf /usr/local/etc/oai/freeDiameter
sudo cp ~/openair-cn/etc/mme_fd.conf /usr/local/etc/oai/freeDiameter
sudo cp ~/openair-cn/etc/hss_fd.conf /usr/local/etc/oai/freeDiameter
5.3)切换到root用户,ifconfig查看自己网卡,IP地址(如下图所示:网卡ens33 ,ip地址:192.168.216.188)
5.4) 执行 sudo gedit /usr/local/etc/oai/mme.conf 配置MME
# MME binded interface for S1-C or S1-MME communication (S1AP), can be ethernetinterface, virtual ethernet interface, we don't advise wireless interfaces
MME_INTERFACE_NAME_FOR_S1_MME = “网卡名”; # YOUR NETWORK CONFIGHERE
MME_IPV4_ADDRESS_FOR_S1_MME = "ip地址"; # YOUR NETWORK CONFIG HERE
# MME binded interface for S11communication (GTPV2-C)
MME_INTERFACE_NAME_FOR_S11_MME = "lo"; # YOUR NETWORKCONFIG HERE
MME_IPV4_ADDRESS_FOR_S11_MME = "127.0.11.1/8"; # YOUR NETWORK CONFIG HERE
MME_PORT_FOR_S11_MME = 2123; # YOUR NETWORKCONFIG HERE}
5.5)执行sudo gedit /usr/local/etc/oai/spgw.conf 配置spgw
NETWORK_INTERFACES :
{
# S-GW bindedinterface for S11 communication (GTPV2-C), if none selected the ITTI messageinterface is used
SGW_INTERFACE_NAME_FOR_S11 = "lo"; # STRING, interface name, YOUR NETWORK CONFIG HERE
SGW_IPV4_ADDRESS_FOR_S11 ="127.0.11.2/8"; #STRING, CIDR, YOUR NETWORK CONFIG HERE
# S-GW bindedinterface for S1-U communication (GTPV1-U) can be ethernet interface, virtualethernet interface, we don't advise wireless interfaces
SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP = "网卡名"; # STRING, interface name, YOUR NETWORK CONFIG HERE, USE "lo"if S-GW run on eNB host
SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP = "IP地址"; # STRING,CIDR, YOUR NETWORK CONFIG HERE
SGW_IPV4_PORT_FOR_S1U_S12_S4_UP = 2152; #INTEGER, port number, PREFER NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING
# S-GW bindedinterface for S5 or S8 communication, not implemented, so leave it to none
SGW_INTERFACE_NAME_FOR_S5_S8_UP = "none"; # STRING, interfacename, DO NOT CHANGE (NOT IMPLEMENTED YET)
SGW_IPV4_ADDRESS_FOR_S5_S8_UP = "0.0.0.0/24"; # STRING, CIDR, DO NOT CHANGE (NOT IMPLEMENTED YET)
NETWORK_INTERFACES :
{
# P-GW bindedinterface for S5 or S8 communication, not implemented, so leave it to none
PGW_INTERFACE_NAME_FOR_S5_S8 = "none"; # STRING, interfacename, DO NOT CHANGE (NOT IMPLEMENTED YET)
# P-GW bindedinterface for SGI (egress/ingress internet traffic)
PGW_INTERFACE_NAME_FOR_SGI = "网卡名"; # STRING, YOUR NETWORK CONFIG HERE
PGW_MASQUERADE_SGI = "yes"; # STRING, {"yes","no"}. YOUR NETWORK CONFIG HERE, will do NAT for you if you put"yes".(将原文件中的no改为yes)
UE_TCP_MSS_CLAMPING = "no"; # STRING,{"yes", "no"}.
};
5.6) 执行sudo gedit /usr/local/etc/oai/hss.conf 配置hss
HSS :
{
## MySQL mandatory options
MYSQL_server = "127.0.0.1"; # HSS S6a bind address
MYSQL_user = "root"; #Database server login
MYSQL_pass = "设置的密码"; # Database server password
MYSQL_db ="oai_db"; # Yourdatabase name
## HSS options(注释下面一句,第二句解除注释)
#OPERATOR_key ="1006020f0a478bf6b699f15c062e42b3"; # OP key matching your database
OPERATOR_key ="11111111111111111111111111111111"; # OP key matching your database(把这句的注释符号删除)
RANDOM = "true"; # True random or only pseudorandom (for subscriber vector generation)
## Freediameter options
FD_conf ="/usr/local/etc/oai/freeDiameter/hss_fd.conf";
};
5.7)sudo gedit /usr/local/etc/oai/freeDiameter/hss_fd.conf ,确保信息如下:
Identity = "hss.openair4G.eur"
Realm = "openair4G.eur"
5.8) 执行sudo gedit /usr/local/etc/oai/freeDiameter/mme_fd.conf 确保信息如下:
Identity = "主机名.openair4G.eur"; #需要注意,文件里面原来是yang.openair4G.eur,需要更改
Realm = "openair4G.eur";
ConnectPeer= "hss.openair4G.eur" { ConnectTo ="127.0.0.1"; No_SCTP ; No_IPv6; Prefer_TCP; No_TLS; port = 3868; realm = "openair4G.eur";};
六.编译与运行
6.1)安装证书
cd /openair-cn/scripts
./check_hss_s6a_certificate /usr/local/etc/oai/freeDiameter/ hss.openair4G.eur
./check_mme_s6a_certificate /usr/local/etc/oai/freeDiameter/ 主机名.openair4G.eur
6.2)编译运行hss(要先运行hss,sudo 或者root)
使用普通用户:cd ~/openair-cn/scripts
登录root用户:su root
./build_hss
./run_hss -i ~/openair-cn/SRC/OAI_HSS/db/oai_db.sql (只在初次运行HSS,执行一次,导入HSS数据库,以后运行hss直 接./run_hss)
6.3)编译&运行MME
进入 /openair-cn/scripts
./build_mme
./run_mme
d) 编译运行spgw
./build_spgw
./run_spgw