# Upgrade OpenResty Edge Offline

Notice:

  • Please make an appointment with OpenResty colleagues to upgrade before upgrading.

# 1. Get offline package

If you don't have the offline package named Edge-Offline-[% date %].tar.gz, please login and download it at OpenResty Download Center using your email address.

tar xf Edge-Offline-[% date %].tar.gz

# 如: tar xf Edge-Offline-20210721.tar.gz

Usually the offline package will contain the following files:

  • openresty-postgresql.tar.gz
  • openresty-edge-admin.tar.gz
  • openresty-edge-node.tar.gz
  • openresty-edge-log-server.tar.gz
  • update-admin-db-[% version %].sh, use only when upgrading
  • update-log-server-db-[% version %].sh, use only when upgrading
  • init_admin_db_[% version %].sh, use only during installation
  • init_log_server_db_[% version %].sh, use only during installation

# 2. Upgrade Log Server Database

  • Upgrade database program

    # Transfer openresty-postgresql.tar.gz to the machine where the Log Server database is located
    tar xf openresty-postgresql.tar.gz
    cd openresty-postgresql
    
    sudo bash -x upgrade.sh
    
  • Upgrade database schame

    # Transfer update-log-server-db-[% version %].sh to the machine where the Log Server database is located
    bash update-log-server-db-[% version %].sh
    
    # Example: bash update-log-server-db-40.sh
    

# 3. Upgrade Log Server

  • Check and record the software version before the upgrade:

    # centos/redhat/fedora
    rpm -q openresty-edge-log-server
    # or
    rpm -q openresty-edge-log-server-prod
    
    # debian/ubuntu
    dpkg -l | grep openresty-edge-log-server
    # or
    dpkg -l | grep openresty-edge-log-server-prod
    
  • Upgrade:

    # Transfer openresty-edge-log-server.tar.gz to the machine where the Log Server is located
    
    tar xf openresty-edge-log-server.tar.gz
    cd openresty-edge-log-server
    sudo bash -x upgrade.sh
    
  • Downgrade:

    If the upgrade fails, the following steps can be performed to downgrade.

    # Download the downgrade script
    curl -O https://openresty.com/client/oredge/downgrade-edge-log-server-offline.sh
    
    # Place the script in the directory of the old Edge Log Server offline installation package
    cp downgrade-edge-log-server-offline.sh <old-packages-dir>
    
    # Run the downgrade script
    sudo bash -x downgrade-edge-log-server-offline.sh
    

# 4. Upgrade Node

Upgrade 1~2 Nodes first, and then upgrade all Node after there are no problems, please pay attention to the error log during the upgrade.

  • Check and record the software version before the upgrade:

    # centos/redhat/fedora
    rpm -q openresty-edge-node
    # or
    rpm -q openresty-edge-node-prod
    
    # debian/ubuntu
    dpkg -l | grep openresty-edge-node
    # or
    dpkg -l | grep openresty-edge-node-prod
    
  • Cut away traffic. If you are using Edge's DNS, follow these steps; otherwise, proceed as you see fit.

    • Take the Node you want to upgrade offline.

      • Enter the [Gateway Clusters].
      • [Edit] The cluster where the node is located.
      • Modify the node’s [status] to [Disable DNS, disable caching cluster].
      • [Save]
    • Wait for the node to no longer have traffic. You could confirm by checking the access log:

      tail -f /usr/local/oredge-node/logs/access.log
      

      This process requires waiting for DNS to expire, which can be time-consuming.

  • Upgrade:

    # Transfer openresty-edge-node.tar.gz to the machine where the Node is located
    
    tar xf openresty-edge-node.tar.gz
    cd openresty-edge-node
    sudo bash -x upgrade.sh
    
  • Downgrade:

    If the upgrade fails, the following steps can be performed to downgrade.

    # Download the downgrade script
    curl -O https://openresty.com/client/oredge/downgrade-edge-node-offline.sh
    
    # Place the script in the directory of the old Edge Node offline installation package
    cp downgrade-edge-node-offline.sh <old-packages-dir>
    
    # Run the downgrade script
    sudo bash -x downgrade-edge-node-offline.sh
    

# 5. Upgrade Admin database

  • Backup database

Before executing the backup command, please check if there is enough disk space.

# Please replace 127.0.0.1 with the actual IP and 5432 with the actual port.
/usr/local/openresty-postgresql12/bin/pg_dump or_edge_admin                       \
    -h 127.0.0.1 -p 5432 -U postgres --schema-only                              \
    | gzip > db_edge_admin_schema_$(date '+%Y-%m-%d').sql.gz

/usr/local/openresty-postgresql12/bin/pg_dump or_edge_admin                      \
    -h 127.0.0.1 -p 5432 -U postgres --data-only                                \
    | gzip > db_edge_admin_data_$(date '+%Y-%m-%d').sql.gz
  • Upgrade database program

    # Transfer openresty-postgresql.tar.gz to the machine where the Admin database is located
    tar xf openresty-postgresql.tar.gz
    cd openresty-postgresql
    
    sudo bash -x upgrade.sh
    
  • Upgrade database schame

    # Transfer openresty-postgresql.tar.gz to the machine where the Admin database is located
    bash update-admin-db-[% version %].sh
    
    # 如:bash update-admin-db-179.sh
    

# 6. Upgrade Admin

  • Check and record the software version before the upgrade:

    # centos/redhat/fedora
    rpm -q openresty-edge-admin
    # or
    rpm -q openresty-edge-admin-prod
    
    # debian/ubuntu
    dpkg -l | grep openresty-edge-admin
    # or
    dpkg -l | grep openresty-edge-admin-prod
    
  • Upgrade:

    # Transfer openresty-postgresql.tar.gz to the machine where the Admin is located
    
    tar xf openresty-edge-admin.tar.gz
    cd openresty-edge-admin
    sudo bash -x upgrade.sh
    
  • Downgrade:

    If the upgrade fails, the following steps can be performed to downgrade.

    # Download the downgrade script
    curl -O https://openresty.com/client/oredge/downgrade-edge-admin-offline.sh
    
    # Place the script in the directory of the old Edge Admin offline installation package
    cp downgrade-edge-admin-offline.sh <old-packages-dir>
    
    # Run the downgrade script
    sudo bash -x downgrade-edge-admin-offline.sh
    

# 7. Recompile

It is recommended to recompile the application in the following order:

  1. Recompile a few applications with less traffic first
  2. Recompile several high-traffic applications
  3. Recompile all applications
  4. Recompile global rules
cd /usr/local/oredge-admin/
# recompile the specified application (replace APP-ID with application ID)
sudo bash utils/recompile-apps.sh http APP-ID
# recompile all applications
sudo bash utils/recompile-apps.sh http
sudo bash utils/recompile-apps.sh http_proxy
sudo bash utils/recompile-apps.sh socks5_proxy
# recompile global rules
sudo bash utils/recompile-apps.sh global
# recompile waf rules
sudo bash utils/recompile-apps.sh waf
# recompile DNS applications
sudo bash utils/recompile-apps.sh dns
# recompile global actions
sudo bash utils/recompile-apps.sh global-action
# recompile gateway (may trigger OpenResty Edge Node reload)
sudo bash utils/recompile-apps.sh gateway

If you have any questions, please contact us.