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

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 命令路径,如不同,请修改为正确路径。

重启informat-account服务

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

重启informat-biz服务

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