关于操作系统:Varnish-620-移植指南openEuler-2003-LTS-SP1

9次阅读

共计 4806 个字符,预计需要花费 13 分钟才能阅读完成。

介绍

简要介绍

Varnish 是一款高性能且开源的反向代理服务器和 HTTP 加速器,与传统的缓存服务器相比,Varnish 具备性能更高、速度更快、治理更加不便等诸多长处,很多大型的网站都开始尝试应用 Varnish 来替换 Squid,这些都促成 Varnish 迅速倒退起来。

开发语言:C++

一句话形容:反向代理服务器和 HTTP 加速器

倡议的版本

倡议应用版本为“Varnish 6.2.0”。

环境要求

硬件要求

硬件要求如表 1 所示。
表 1 硬件要求

我的项目 阐明
服务器 TaiShan 200 服务器(型号 2280)
CPU 鲲鹏 920 5250 处理器
磁盘分区 对磁盘分区无要求

操作系统要求

操作系统要求如表 2 所示。
表 2 操作系统要求

我的项目 版本 版本查看命令
openEuler 20.03 LTS SP1 cat /etc/openEuler-release
Kernel 4.19.90 uname -r

配置编译环境

配置 Yum 源

阐明:
如果组网环境处于外网受限状况下,服务器 yum 命令无奈通过外界获取依赖包时,可参考本节内容进行本地源配置。

  1. 将操作系统镜像文件 openEuler-20.03-LTS-SP1-everything-aarch64-dvd.iso 文件拷贝到每台服务器的“/root”目录下。
  2. 镜像文件挂载。
    a. 将“/root”目录下的 openEuler 操作系统对应 iso 文件挂载到“/mnt”目录下。
    mount /root/openEuler-20.03-LTS-SP1-everything-aarch64-dvd.iso /mnt
    阐明:
    该操作单次失效,重启后生效。若须要配置开机启动主动挂载镜像(可选),可参考上面步骤。

    1. 关上 fstab 文件。
      vi /etc/fstab
    2. 编辑 fstab 文件,在文件开端增加如下信息:
      /root/openEuler-20.03-LTS-SP1-everything-aarch64-dvd.iso /mnt iso9660 loop 0 0
    3. 保留并退出 fstab 文件。
  3. 增加本地源文件。
    a. 进入“/etc/yum.repos.d”目录。
    cd /etc/yum.repos.d
    阐明:
    此时,倡议将此目录下的 *.repo 文件移到任意其余备份目录下。
    b. 创立 local.repo 文件。

    1. 关上 local.repo 文件。
      vi local.repo
    2. 编辑 local.repo 文件,在 local.repo 文件中增加如下内容:

      [local]
      name=local.repo
      baseurl=file:///mnt
      enabled=1
      gpgcheck=0

      阐明:
      其中,baseurl 中 file 门路为镜像挂载门路,与镜像文件挂载中的目录“/mnt”对应。

    3. 保留并退出 local.repo 文件。
  4. 失效本地源。

    yum clean all
    yum makecache
    yum list

装置依赖包

下载并装置依赖包

  1. 装置所需依赖。

    yum install -y autoconf automake jemalloc-devel libedit-devel libtool ncurses-devel pcre-devel pkgconfig python-docutils python-sphinx graphviz httpd
  2. 查看 Python3 版本

    [[email protected]]# python3 --version
    Python 3.7.9

装置

装置形式介绍

本文将介绍源码编译装置形式

源码编译装置

获取源码

  1. 在本地浏览器下载 Varnish 源码。
    下载地址:https://varnish-cache.org/_do…
  2. 将源码复制至服务器“/home”目录。
    阐明:
    若服务器能够拜访网络,则能够间接在服务器上应用 wget 命令下载源码。

编译和装置

  1. 进入“home”目录。
    cd /home/
  2. 解压源码包。
    tar -zxvf varnish-6.2.0.tgz
  3. 进入“varnish-6.2.0”目录。
    cd /home/varnish-6.2.0/
  4. 执行主动编译。
    sh autogen.sh
  5. 查看依赖。
    ./configure --prefix=/usr/local/varnish

    [[email protected] varnish-6.2.0]# ./configure --prefix=/usr/local/varnish
    checking for gcc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... no
    checking for suffix of  files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes

    阐明:
    –prefix=PATH:指定 Varnish 的装置目录。

  6. 编译装置 Varnish。
    make && make install

    [[email protected] varnish-6.2.0]# make  && make install
    make  all-recursive
    make[1]: Entering directory '/home/varnish-6.2.0'
    Making all in include
    make[2]: Entering directory '/home/varnish-6.2.0/include'
    make  all-am
    make[3]: Entering directory '/home/varnish-6.2.0/include'

配置文件

  1. 在 Varnish 装置门路中创立配置文件所需的文件夹。
    cd /usr/local/varnish && mkdir config
  2. 复制配置文件到“config”中。
    cp /usr/local/varnish/share/doc/varnish/example.vcl /usr/local/varnish/config/default.vcl

运行与验证

以本机作为 Varnish 后端对象为例,运行和验证 Varnish。

  1. 批改后端地址端口用于反向代理测试。
    若需配置缓存策略,请从官网获取最新的 Varnish Book)。此处配置本机作为后端对象,端口默认 80。

    a. 关上配置文件。
    vi /usr/local/varnish/config/default.vcl

    b. 配置如下内容后,保留并退出。

    vcl 4.0;
    # Default backend definition. Set this to point to your content server.
    backend default {
    .host = "127.0.0.1";
    .port = "80";
    }
    
    sub vcl_recv {
    }
    sub vcl_backend_response {
    }
    sub vcl_deliver {}
  2. 启动后端对象的 HTTP 服务。
    systemctl start httpd
  3. 启动 Varnish。
    /usr/local/varnish/sbin/varnishd -a :12345 -T 127.0.0.1:6082 -s malloc,10GB -f /usr/local/varnish/config/default.vcl

    [[email protected] ~]# /usr/local/varnish/sbin/varnishd  -a :12345 -T 127.0.0.1:6082 -s malloc,10GB -f /usr/local/varnish/config/default.vcl
    Debug: Version: varnish-6.2.0 revision b14a3d38dbe918ad50d3838b11aa596f42179b54
    Debug: Platform: Linux,4.19.90-2012.4.0.0053.oe1.aarch64,aarch64,-jnone,-smalloc,-sdefault,-hcritbit
    Debug: Child (30634) Started

    Varnish 启动参数阐明见表 Varnish 启动参数阐明。
    参数 : 阐明

    -a address:port : 示意 Varnish 对 HTTP 的监测地址及其端口, 此处 IP 默认为本机。

    -T address:port : 设定 Varnish 的 Telnet 治理地址及其端口。

    -s : 指定 Varnish 缓存寄存的形式,此处采纳 malloc 的模式,总共调配 10GB 内存空间。

    -f : 指定 Varnish 的配置文件地位。

  4. 拜访本机即可看到后端服务的测试页面。
    curl http://localhost:80

    ...
       <div class="content-middle">
        This page is used to test the proper operation of the Apache HTTP server after it has been installed. If you can read this page, it means that the Apache HTTP server installed at this site is working properly.
       </div>
       <hr>
    
       <div class="content-columns">
        <div class="content-column-left">
         <h2>If you are a member of the general public:</h2>
    
         The fact that you are seeing this page indicates that the website you just visited is either experiencing problems, or is undergoing routine maintenance.
    
         If you would like to let the administrators of this website know that you've seen this page instead of the page you expected, you should send them e-mail. In general, mail sent to the name"webmaster"and directed to the website's domain should reach the appropriate person.
    
         For example, if you experienced problems while visiting www.example.com, you should send e-mail to "[email protected]".
    
         For information on openEuler Linux, please visit the <a href="#" class="white">openEuler, Inc. website</a>. The ation for openEuler Linux is <a href="#" class="white">available on the openEuler, Inc. website</a>.
     
    ...

    阐明:

    • 若须要进行 Varnish,则应用如下命令,业务运行中不须要执行该命令。

    pkill varnish

    • 卸载 Varnish,并查问。

    卸载源码形式装置的 Varnish。
    rm -rf /usr/local/varnish/

相干链接:

  1. openEuler 官网:www.openeuler.org/
  2. OS 迁徙专区: https://www.openeuler.org/zh/…
  3. openEuler 兼容性列表:https://www.openeuler.org/zh/…
  4. openEuler 迁徙指南:https://www.openeuler.org/zh/…
正文完
 0