CentOS 7.4 下 Apache Traffic Server 安装部署

系统:CentOS 7.4

更新yum yum update yum -y install epel* 先安装bzip2

yum -y install bzip2

1.下载源代码

我这里下载的是 7.1版本的源代码 最新的已经有8.0版本

需要访问这个url里面有链接 用wget 下载

下载后解压缩

bzip2 -d .tar.bz2 //将文件解压成.tar
tar -xf **.tar //解包

下载完成后不要着急编译 先优化下系统 如果是美国机器做视频站用的话 最好做个锐速

开始优化Linux参数

执行下面这些命令

cat << 'EOT' >> /etc/sysctl.conf fs.file-max=655350 net.ipv4.tcp_max_tw_buckets = 300000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_max_syn_backlog = 65536 net.core.netdev_max_backlog = 32768 net.core.somaxconn = 32768 net.core.rmem_default=98304 net.core.wmem_default=98304 net.core.rmem_max=2097152 net.core.wmem_max=2097152 net.ipv4.tcp_rmem=4096 98304 2097152 net.ipv4.tcp_wmem=4096 98304 2097152 net.ipv4.tcp_low_latency=1 net.ipv4.tcp_slow_start_after_idle=0 net.ipv4.tcp_timestamps = 1 net.ipv4.tcp_fin_timeout = 20 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 net.ipv4.tcp_syncookies = 0 #net.ipv4.tcp_tw_len = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.ip_local_port_range = 1024 65000 EOT 修改完参数执行

sysctl -p /etc/sysctl.conf

继续修改文件最大打开数 cat << 'EOT' >> /etc/security/limits.d/nofile.conf * soft nofile 655350 * hard nofile 655350 EOT cat <<EOF>>/etc/rc.local #open files ulimit -HSn 655350 #stack size ulimit -s 655350 EOF 安装ATS的必须的环境 yum install -y gcc gcc-c++ pkgconfig pcre-devel tcl-devel expat-devel openssl-devel perl-ExtUtils-MakeMaker bzip2 yum install -y libcap libcap-devel hwloc hwloc-devel ncurses-devel libcurl-devel libunwind libunwind-devel autoconf automake libtool yum -y install git gcc gcc-c++ autoconf automake libtool pkgconfig pcre-devel tcl-devel expat-devel openssl-devel xz-devel boost-devel perl-ExtUtils-MakeMaker libcap libcap-devel hwloc hwloc-devel libunwind libunwind-devel curl curl-devel ncurses ncurses-devel yum install centos-release-scl -y yum install devtoolset-6-gcc* -y scl enable devtoolset-6 bash 准备开始编译ATS 创建属组和用户 groupadd ats useradd -g ats ats

进入ATS目录开始编译 编译安装需要一会时间 请耐心等待

cd /root/trafficserver-7.1.4 ./configure --prefix=/ --with-user=ats --with-group=ats --enable-experimental-plugins make -j $(nproc) make install 等待编译完成 执行启动下看看

trafficserver start

常用的命令 1.1.启动 2.trafficserver start 3.2.关闭 4.trafficserver stop 5.3.重启 6.trafficserver restart 7.4.重载配置文件(很多情况下好像都没有生效) 8.traffic_ctl config reload 9.5.监控ats的状况 类似于top命令 10.traffic_top 11.6.清理所有缓存 12.traffic_server -Cclear 跨域问题解决 vi add_header.config add-header Access-Control-Allow-Origin * vi plugin.config header_rewrite.so add_header.config 然后重载配置文件 清除浏览器缓存 清除ats缓存 同步时间并修改时区 yum install -y ntpdate /sbin/ntpdate cn.pool.ntp.org #同步时间 tzselect timedatectl set-timezone Asia/Shanghai #设置时区

复制root目录下的脚本到新服务器 (查看权限是否相同,以及属主属组)
修改iD配置文件auto.sh autolog.sh
server=6 数字为卧龙后台播放列表竖列,没有空着的就联系主管新增一列,从左往右数新增在第几列id就为几

复制线上配置文件/etc/trafficserver下所以配置文件到新增服务器
修改vi records.config下
##############################################################################
CONFIG proxy.config.http.insert_request_via_str INT 0
CONFIG proxy.config.http.insert_response_via_str INT 2
CONFIG proxy.config.http.response_server_str STRING wlzy_cdn(BGP)/1.0
CONFIG proxy.config.http.response_via_str STRING wlzy_cdn(BGP)
##############################################################################

编辑配置文件 vim /etc/trafficserver/storage.conf /data/ats/cache 750G 分区,格式化,挂载,自动挂载 创建目录 mkdir -p /data/ats/cache chown -R ats.ats /data

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/3d52d7a919f93c6dd123118492871cf1.html