Skip to content

手动升级

下载织信安装包

通过织信安装包源地址,获取对应版本的安装包链接地址。

shell
informat_next_2.23.zip  informat_next_installer

示例:

下载2.23版本的织信安装包到服务器的/tmp目录下

shell
cd /tmp/
curl -O https://repo.informat.cn/downloads/packages/informat_next_2.23.zip

备份数据库

重要提示:升级前请务必备份数据库,确保数据安全!

执行升级脚本

使用以下命令执行升级:

shell
./informat-upgrade.sh /tmp/informat_next_2.23.zip

升级脚本 informat-upgrade.sh 内容如下:

shell

#!/bin/bash

is_integer() {
  local str="$1"
  # 先检查空字符串
  if [[ -z "$str" ]]; then
    return 1  # 空字符串不是整数
  fi
  # 正则匹配:可选负号 + 至少一个数字
  if [[ "$str" =~ ^-?[0-9]+$ ]]; then
    return 0  # 是整数
  else
    return 1  # 不是整数
  fi
}

INFORMAT_PACKAGE=$1   #informat_next_2.23.zip	
current=`date "+%Y%m%d%H%M%S"`
unzip_dir=informat_next_${current}
unzip ${INFORMAT_PACKAGE} -d ${unzip_dir}
cat ${unzip_dir}/VERSION

oldAppVersion=`curl -s http://127.0.0.1:8881/web/main/app_version | grep -o '"appVersion":"[^"]*"' | sed 's/"appVersion":"//;s/"//'`
echo "oldAppVersion:"${oldAppVersion}
newAppVersion=`grep -o '"db":"[^"]*"' ${unzip_dir}/VERSION | sed 's/"db":"//;s/"//'`
echo "newAppVersion:"${newAppVersion}

# 
if is_integer "${oldAppVersion}";then
        echo 'oldAppVersion is digit'
else
        echo 'oldAppVersion is not digit'
        exit 1
fi
if is_integer "${newAppVersion}";then
        echo 'newAppVersion is digit'
else
        echo 'newAppVersion is not digit'
        exit 1
fi
if [ "$oldAppVersion" -ge "$newAppVersion" ]; then
    echo "error app version is to low"
    exit 1
fi
export PGPASSWORD="数据库密码"
DB_VERSION_DIR=${unzip_dir}"/db/version"
for ((version = oldAppVersion + 1; version <= newAppVersion; version++)); do
	account_file="${DB_VERSION_DIR}/${version}_account.sql"
	echo "/usr/local/pgsql/bin/psql -U postgres -d db_informat2_account_prd -f ${account_file}"
	/usr/local/pgsql/bin/psql -U postgres -d db_informat2_account_prd -f ${account_file}
	biz_file="${DB_VERSION_DIR}/${version}_biz.sql"
	echo "/usr/local/pgsql/bin/psql -U postgres -d db_informat2_biz_prd_0 -f ${biz_file}"
	/usr/local/pgsql/bin/psql -U postgres -d db_informat2_biz_prd_0 -f ${biz_file}
done

# ===== 知识库升级 =====
# 知识库依赖 vector / pg_trgm / zhparser 三个 PG 扩展,需提前在数据库安装好对应扩展二进制
KB_DIR="${unzip_dir}/db/knowledgebase"
KB_DB="db_informat2_biz_prd_0"
PSQL="/usr/local/pgsql/bin/psql"

if [ ! -d "${KB_DIR}" ]; then
    echo "[KB] ${KB_DIR} 不存在,跳过知识库sql执行"
else
    for ext in vector pg_trgm zhparser; do
        ${PSQL} -U postgres -d ${KB_DB} -c "CREATE EXTENSION IF NOT EXISTS ${ext};" \
            || echo "[KB] WARN: CREATE EXTENSION ${ext} 失败"
    done

    # 与 biz 一致,只执行高于当前版本的知识库 SQL
    for ((version = oldAppVersion + 1; version <= newAppVersion; version++)); do
        kb_file="${KB_DIR}/${version}_biz.sql"
        [ -f "${kb_file}" ] || continue
        echo "[KB] current kb file index: ${version}"
        ${PSQL} -U postgres -d ${KB_DB} -f "${kb_file}" \
            || echo "[KB] WARN: ${kb_file} 执行失败,跳过"
    done
fi

cp -fv /informat-next/instance/informat-account/informat-account-1.0.0.jar /informat-next/instance/informat-account/informat-account-1.0.0.jar${current}
cp -fv ${unzip_dir}/informat-account-1.0.0.jar /informat-next/instance/informat-account/informat-account-1.0.0.jar
cp -fv /informat-next/instance/informat-biz/informat-biz-1.0.0.jar /informat-next/instance/informat-biz/informat-biz-1.0.0.jar${current}
cp -fv ${unzip_dir}/informat-biz-1.0.0.jar /informat-next/instance/informat-biz/informat-biz-1.0.0.jar

注意事项

本脚本默认数据库用户名为 postgres,如实际不符,请根据需要修改。 export PGPASSWORD="数据库密码" 请替换为实际数据库密码。 /usr/local/pgsql/bin/psql 是默认 PostgreSQL 命令路径,如不同,请修改为正确路径。

知识库升级说明

  • 知识库(向量检索)依赖 PostgreSQL 的 vectorpg_trgmzhparser 三个扩展,升级前请确认数据库已安装对应扩展二进制,否则 CREATE EXTENSION 会失败。
  • 安装包内若不含 db/knowledgebase/ 目录(旧版本安装包),该段会自动跳过,不影响主升级。
  • 知识库 SQL 执行失败只打印 [KB] WARN 警告并继续,不会中断主升级流程;若需要使用知识库功能,请在补齐扩展后重新执行该段。

重启informat-account服务

shell
# cd /informat-next
# ./informat restart informat-account

重启informat-biz服务

shell
# cd /informat-next
# ./informat restart informat-biz