Implementing high-availability deployment of Zhiqingyun based on NGINX

This article explains the applicable scenarios, operation steps, and key configurations of high-availability deployment to help users complete environment deployment and verification.

Resource purchase

Configuration: centos7.9, 4 cores, 16GB memory

  • Server 1: nfs shared disk service
  • Shared Disk: Mounted to Server 1
  • Server 2: NGINX load balancing service
  • Server 3: Install Zhiqingyun1
  • Server 4: Install Zhiqingyun2
  • Server 5: Install Zhiqingyun3
Server namePublic IPIntranet IP
Server 147.92.73.226172.16.215.85
Server 239.100.69.110172.16.215.84
Server 347.92.198.55172.16.215.86
Server 447.92.1.129172.16.215.87
Server 547.92.5.96172.16.215.83

Mount disk

Server 1 mounts the disk, refer to the document: linux mounts the disk

Install nfs service

Server 1 installs nfs service, refer to the document: linux install nfs service

Mount shared disk

Mount the server's shared disk to server 3, server 4, and server 5. Reference document: linux mount shared disk

Install Zhiqingyun service

Install the Zhiqingyun service on Server 3, Server 4, and Server 5. Refer to the document: Zhiqingyun Offline Deployment

Modify the configuration file and point the resource directory to the shared disk

Contains the following configuration items: spring.datasource.url: database data directory (use shared disk) isx-app.resources-path: Resource file directory (use shared disk)

vim zhiqingyun/conf/application-local.yml
server:
  port: 8080

spring:

  security:
    user:
      name: admin
      password: admin123

  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:file:/data/zhiqingyun/h2/data;AUTO_SERVER=TRUE
    username: root
    password: root1234

isx-app:
  resources-path: /data/zhiqingyun
  admin-passwd: admin123
  use-ssl: false

Note: Copy the database driver files to the shared disk Only needs to be executed once, no need to execute it repeatedly

mkdir -p /data/zhiqingyun
cp -r zhiqingyun/resources/jdbc /data/zhiqingyun/

Start a project

All three servers must start the Zhiqingyun service.

bash zhiqingyun/bin/start.sh

Install NGINX load service

Install NGINX load service on server 2 Reference document: NGINX load balancing configuration

upstream zhiqingyun_servers {
    server 172.16.215.86:8080 weight=1 max_fails=3 fail_timeout=60s;
    server 172.16.215.85:8080 weight=1 max_fails=3 fail_timeout=60s;
    # 所有节点挂掉后使用
    server 172.16.215.84:8080 backup;
}
   
server {
    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://zhiqingyun_servers/;
    }
}

Access Zhiqingyun through NGINX