!47 【回合代码】fix opengauss upgrade

From: @hengliue 
Reviewed-by: @zhang_xubo 
Signed-off-by: @zhang_xubo
This commit is contained in:
openeuler-ci-bot 2024-06-20 03:10:47 +00:00 committed by Gitee
commit 2edc2d111d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 1751 additions and 58 deletions

View File

@ -1,6 +1,9 @@
version=5.0.1
server_repo=https://gitee.com/opengauss/openGauss-server.git
plugin_repo=https://gitee.com/opengauss/Plugin.git
git clone $server_repo -b v5.0.1 openGauss-server-$version
git clone $plugin_repo -b v5.0.1 Plugin-$version
cp -rf Plugin-$version/contrib/* openGauss-server-$version/contrib/
cd openGauss-server-$version
gitcommit=$(git log 2>/dev/null | grep commit | head -1 | awk '{print $2}' | cut -b 1-8)
echo $gitcommit > ../COMMIT
@ -11,7 +14,6 @@ rm -rf src/test/regress/sql
rm -rf src/test/regress/data
rm -rf src/test/regress/jdbc_test
rm -rf src/test/regress/input
rm -rf src/test/regress/jdbc_client_lib
rm -rf .git
rm -rf ./docker
cd ..

View File

@ -275,3 +275,61 @@ diff -crN '--exclude=.git' '--exclude=.gitee' '--exclude=.vscode' openGauss-serv
}
}
}
diff -crN '--exclude=.git' '--exclude=.gitee' '--exclude=.vscode' Plugin-5.0.1/contrib/dolphin/cmake.sh Plugin-5.0.1-edit/contrib/dolphin/cmake.sh
*** Plugin-5.0.1/contrib/dolphin/cmake.sh 2024-06-12 20:17:51.731405913 +0800
--- Plugin-5.0.1-edit/contrib/dolphin/cmake.sh 2024-06-12 20:43:24.223308216 +0800
***************
*** 1,5 ****
#!/bin/bash
! CMAKE_OPT="-DENABLE_MULTIPLE_NODES=OFF -DENABLE_PRIVATEGAUSS=OFF -DENABLE_THREAD_SAFETY=ON -DENABLE_LITE_MODE=ON"
cpus_num=$(grep -w processor /proc/cpuinfo|wc -l)
rm -f dolphin--1.0.sql
touch dolphin--1.0.sql
--- 1,5 ----
#!/bin/bash
! CMAKE_OPT="-DENABLE_MULTIPLE_NODES=OFF -DENABLE_PRIVATEGAUSS=OFF -DENABLE_THREAD_SAFETY=ON -DENABLE_LITE_MODE=ON -DENABLE_OPENEULER_MAJOR=ON -DWITH_OPENEULER_OS=ON"
cpus_num=$(grep -w processor /proc/cpuinfo|wc -l)
rm -f dolphin--1.0.sql
touch dolphin--1.0.sql
***************
*** 9,14 ****
--- 9,15 ----
touch dolphin--1.2.sql
cat dolphin--1.0.sql >> dolphin--1.2.sql
cat upgrade_script/dolphin--1.0--1.2.sql >> dolphin--1.2.sql
+ BUILD_TUPLE=$(uname -p)
cp llvmir/openGauss_expr_dolphin_${BUILD_TUPLE}.ir openGauss_expr_dolphin.ir
DOLPHIN_CMAKE_BUILD_DIR=`pwd`/tmp_build
[ -d "${DOLPHIN_CMAKE_BUILD_DIR}" ] && rm -rf ${DOLPHIN_CMAKE_BUILD_DIR}
diff -crN '--exclude=.git' '--exclude=.gitee' '--exclude=.vscode' openGauss-server-5.0.1/src/bin/pg_ctl/backup.cpp openGauss-server-5.0.1-edit/src/bin/pg_ctl/backup.cpp
*** openGauss-server-5.0.1/src/bin/pg_ctl/backup.cpp 2024-05-09 14:48:32.000000000 +0800
--- openGauss-server-5.0.1-edit/src/bin/pg_ctl/backup.cpp 2024-06-19 16:22:57.390413059 +0800
***************
*** 1939,1945 ****
}
while (1) {
de = readdir(dir);
! if (de <= 0) {
break;
}
if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) {
--- 1939,1945 ----
}
while (1) {
de = readdir(dir);
! if (de == NULL) {
break;
}
if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) {
***************
*** 2799,2802 ****
/* free sysidentifier after use */
pg_free(sysidentifier);
sysidentifier = NULL;
! }
\ No newline at end of file
--- 2799,2802 ----
/* free sysidentifier after use */
pg_free(sysidentifier);
sysidentifier = NULL;
! }

Binary file not shown.

View File

@ -1,4 +1,4 @@
export GAUSSHOME=/usr/local/opengauss/
export GAUSSHOME=/usr/local/opengauss
export LD_LIBRARY_PATH=/usr/local/opengauss/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/opengauss/bin:$PATH
export PGDATA=/var/lib/opengauss/data

View File

@ -7,10 +7,11 @@
%define port 7654
%define datapath /var/lib/opengauss
%define apppath %{_prefix}/local/opengauss
%define tmppath /var/lib/opengauss/pkg_5.0.1
Name: opengauss
Version: 5.0.1
Release: 12
Release: 14
Summary: openGauss is an open source relational database management system
License: MulanPSL-2.0 and MIT and BSD and zlib and TCL and Apache-2.0 and BSL-1.0
URL: https://gitee.com/opengauss/openGauss-server
@ -21,11 +22,17 @@ Source4: %{xgboost_name}-%{xgboost_version}.tar.gz
Source5: opengauss-bashprofile
Source6: opengauss.service
Source7: autostart.sh
Source8: version.cfg
Source9: opengauss_upgrade_start.sh
Source10: opengauss_upgrade_common.sh
Source11: opengauss_upgrade_config.sh
Source12: opengauss_upgrade_errorcode.sh
Patch0: og-edit.patch
Patch1: cmake_compile.patch
Patch2: compile_2309.patch
Patch3: openssl3-adptor.patch
Patch4: upgrade.patch
Patch20: zlib.patch
Patch21: zlib-CVE-2022-37434.patch
@ -60,11 +67,14 @@ openGauss kernel : openGauss is an open source relational database management sy
%setup -q -D -T -a 3
%setup -q -D -T -a 4
pushd openGauss-server-%{version}
pushd openGauss-server-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
popd
pushd %{zlib_name}-%{zlib_version}
@ -135,15 +145,19 @@ export LD_LIBRARY_PATH=$THIRD_BIN_PATH/kernel/dependency/zlib1.2.11/comm/lib:$LD
export LD_LIBRARY_PATH=$THIRD_BIN_PATH/kernel/dependency/xgboost/comm/lib:$LD_LIBRARY_PATH
export PREFIX_HOME=${opengauss_source_dir}/mppdb_temp_install
mkdir -p %{buildroot}/var/lib/opengauss/data
mkdir -p %{buildroot}/%{apppath}/script
mkdir -p tmp_build
cd tmp_build
cmake .. -DENABLE_MULTIPLE_NODES=OFF -DENABLE_PRIVATEGAUSS=OFF -DENABLE_THREAD_SAFETY=ON -DENABLE_LITE_MODE=ON -DENABLE_OPENEULER_MAJOR=ON -DWITH_OPENEULER_OS=ON &&
cmake .. -DENABLE_MULTIPLE_NODES=OFF -DENABLE_PRIVATEGAUSS=OFF -DENABLE_THREAD_SAFETY=ON -DENABLE_LITE_MODE=ON -DENABLE_OPENEULER_MAJOR=ON -DWITH_OPENEULER_OS=ON
make %{?_smp_mflags}
make install
# clean build root
rm -rf %{buildroot}/*
mkdir -p %{buildroot}/var/lib/opengauss/data
mkdir -p %{buildroot}%{apppath}/script
mkdir -p %{buildroot}%{tmppath}/script
# separate_debug_symbol.sh dir
cd ${opengauss_source_dir}/build/script
chmod +x ./separate_debug_information.sh
@ -151,10 +165,45 @@ chmod +x ./separate_debug_information.sh
rm -rf ${opengauss_source_dir}/mppdb_temp_install/packages
rm -rf ${opengauss_source_dir}/mppdb_temp_install/symbols
# copy binarylibs packages to /usr/local/opengauss/
cp -r ${opengauss_source_dir}/mppdb_temp_install/* %{buildroot}/usr/local/opengauss
function get_os_kernel() {
kernel=""
if [[ -f "/etc/euleros-release" ]]; then
kernel=$(cat /etc/euleros-release | awk -F ' ' '{print $1}' | tr a-z A-Z)
if [[ "${kernel}" = "Euleros" ]]; then
kernel="Euler"
fi
elif [[ -f "/etc/openEuler-release" ]]; then
kernel=$(cat /etc/openEuler-release | awk -F ' ' '{print $1}')
elif [[ -f "/etc/centos-release" ]]; then
kernel=$(cat /etc/centos-release | awk -F ' ' '{print $1}')
else
kernel=$(lsb_release -d | awk -F ' ' '{print $2}')
fi
}
get_os_kernel
platform_arch=$(uname -p)
cd ${opengauss_source_dir}/mppdb_temp_install
tar -zcf openGauss-Lite-%{version}-${kernel}-${platform_arch}.bin *
sha256sum openGauss-Lite-%{version}-${kernel}-${platform_arch}.bin | awk '{print $1}' > openGauss-Lite-%{version}-${kernel}-${platform_arch}.sha256
# copy binarylibs packages to %{tmppath}
cp -r ${opengauss_source_dir}/mppdb_temp_install/* %{buildroot}%{tmppath}
sed -i "/wal_insert_status_entries/d" ${opengauss_source_dir}/build/script/opengauss_config_file_mini
cp ${opengauss_source_dir}/build/script/opengauss_config_file_mini %{buildroot}/%{apppath}/share/postgresql/
cp ${opengauss_source_dir}/build/script/opengauss_config_file_mini %{buildroot}%{tmppath}/share/postgresql/
# make package upgrade sql
cd ${opengauss_source_dir}/tmp_build
cp -r ${opengauss_source_dir}/src/include/catalog/upgrade_sql ./upgrade_sql
tar -zcf upgrade_sql.tar.gz ./upgrade_sql
rm -rf ./upgrade_sql > /dev/null 2>&1
sha256sum upgrade_sql.tar.gz | awk '{print $1}' > upgrade_sql.sha256
if [ $? -ne 0 ]; then
echo "Generate upgrade_sql.sha256 failed."
exit 1
fi
cp -r upgrade_sql.tar.gz %{buildroot}%{tmppath}
cp -r upgrade_sql.sha256 %{buildroot}%{tmppath}
popd
# opengauss datanode dir.
@ -163,15 +212,25 @@ install -d -m 700 $RPM_BUILD_ROOT%{?_localstatedir}/lib/opengauss/data
# opengauss .bash_profile
install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{?_localstatedir}/lib/opengauss/.bash_profile
# auto start files
install -m 644 %{SOURCE6} %{buildroot}/%{apppath}/script/opengauss.service
install -m 700 %{SOURCE7} %{buildroot}/%{apppath}/script/autostart.sh
install -m 644 %{SOURCE6} %{buildroot}%{tmppath}/script/opengauss.service
install -m 700 %{SOURCE7} %{buildroot}%{tmppath}/script/autostart.sh
# upgrade script
install -m 644 %{SOURCE8} %{buildroot}%{tmppath}/version.cfg
install -m 644 %{SOURCE9} %{buildroot}%{tmppath}/opengauss_upgrade_start.sh
install -m 644 %{SOURCE10} %{buildroot}%{tmppath}/opengauss_upgrade_common.sh
install -m 644 %{SOURCE11} %{buildroot}%{tmppath}/opengauss_upgrade_config.sh
install -m 644 %{SOURCE12} %{buildroot}%{tmppath}/opengauss_upgrade_errorcode.sh
%pre
/usr/sbin/groupadd -r opengauss >/dev/null 2>&1 || :
/usr/sbin/useradd -M -N -g opengauss -r -d %{datapath} -s /bin/bash -c "openGauss Server" opengauss >/dev/null 2>&1 || :
# for install step
if [ $1 = 1 ]; then
# for install step
# 1:install 2:upgrade
if [ $1 -gt 1 ]; then
echo "upgrade pre"
else
portinfo=$(lsof -i:%{port})
if [ "${portinfo}" != "" ]; then
echo "The port[%{port}] is occupied. Please use command 'lsof -i:%{port} to check it.'"
@ -179,12 +238,6 @@ if [ $1 = 1 ]; then
fi
fi
# upgrade installation
if [ $1 = 2 ]; then
pushd openGauss-server-%{version}/liteom
sh upgrade_GAUSSv5.sh upgrade_pre
popd
fi
%post
# set opengauss mini config parameters
@ -212,7 +265,7 @@ set_mini_configparam(){
}
start_opengauss(){
process_id=$(ps -ef | grep /usr/local/opengauss/bin/gaussdb | grep /var/lib/opengauss/data | grep -v grep | awk '{print $2}')
process_id=$(ps -ef | grep /var/lib/opengauss/data | grep -v grep | awk '{print $2}')
if [ "$process_id" != "" ]; then
echo "A process of opengauss already exists. Use command (ps -ef | grep /var/lib/opengauss/data) to confirm."
echo "Please kill the process and reinstall opengauss."
@ -225,7 +278,7 @@ start_opengauss(){
return 0
fi
result=$(su - opengauss -c "source ~/.bash_profile; gs_initdb -D /var/lib/opengauss/data -U opengauss --nodename=single_node")
result=$(su - opengauss -c "source ~/.bash_profile; gs_initdb -D /var/lib/opengauss/data -U opengauss -w "openGauss@123" --nodename=single_node")
if [ $? -ne 0 ]; then
echo "Init openGauss database failed."
exit $result
@ -239,41 +292,77 @@ add_service(){
systemctl daemon-reload
}
copy_bashrc(){
copyResult=$(su - opengauss -c "echo 'export GAUSSHOME=/usr/local/opengauss/' >> ~/.bashrc &&
echo 'export LD_LIBRARY_PATH=/usr/local/opengauss/lib:$LD_LIBRARY_PATH' >> ~/.bashrc &&
echo 'export PATH=/usr/local/opengauss/bin:$PATH' >> ~/.bashrc &&
echo 'export PGDATA=/var/lib/opengauss/data' >> ~/.bashrc &&
echo 'export PORT=7654' >> ~/.bashrc && source ~/.bashrc")
if [ $? -ne 0 ]; then
exit $result
fi
}
# for install step
if [ $1 = 1 ]; then
# 1:install 2:upgrade
if [ $1 -eq 1 ]; then
echo "install" > /var/lib/opengauss/recode_install_flag
if [ -d /usr/local/opengauss ]; then
rm -rf /usr/local/opengauss
fi
mkdir -p /usr/local/opengauss
cp -r /var/lib/opengauss/pkg_%{version}/* /usr/local/opengauss
chmod -R 755 /usr/local/opengauss
chown -R opengauss:opengauss /usr/local/opengauss
set_mini_configparam
start_opengauss
add_service
copy_bashrc
fi
elif [ $1 -eq 2 ]; then
echo "upgrade" > /var/lib/opengauss/recode_install_flag
mkdir -p /var/lib/opengauss/opengauss_upgrade
mkdir -p /var/lib/opengauss/opengauss_upgrade/bak
mkdir -p /var/lib/opengauss/opengauss_upgrade/tmp
cp -r /var/lib/opengauss/pkg_%{version} /var/lib/opengauss/opengauss_upgrade
chmod -R 755 /var/lib/opengauss/opengauss_upgrade
chown -R opengauss:opengauss /var/lib/opengauss/opengauss_upgrade
chmod -R 755 /usr/local/opengauss
chown -R opengauss:opengauss /usr/local/opengauss
chmod -R 755 /var/lib/opengauss/pkg_%{version}
chown -R opengauss:opengauss /var/lib/opengauss/pkg_%{version}
echo "start upgrade..."
echo "upgrade pre"
su - opengauss -c "source ~/.bash_profile; cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_pre"
if [ $? -ne 0 ]; then
echo "Upgrade pre-check failed."
echo "Please cd /var/lib/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_pre"
exit 1
fi
echo "upgrade bin"
su - opengauss -c "source ~/.bash_profile; cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_bin"
if [ $? -ne 0 ]; then
echo "Upgrade binary failed."
exit 1
fi
echo "upgrade post"
su - opengauss -c "source ~/.bash_profile; cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_post"
if [ $? -ne 0 ]; then
echo "Upgrade post-check failed."
echo "Please cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_post"
exit 1
fi
su - opengauss -c "source ~/.bash_profile; cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_commit"
if [ $? -ne 0 ]; then
echo "Upgrade commit failed."
exit 1
fi
# upgrade installation
if [ $1 = 2 ]; then
pushd openGauss-server-%{version}/liteom
sh upgrade_GAUSSv5.sh upgrade_bin
servicename=/usr/lib/systemd/system/opengauss.service
if [ -f $servicename ]; then
systemctl restart opengauss.service
fi
sh upgrade_GAUSSv5.sh upgrade_post
sh upgrade_GAUSSv5.sh upgrade_commit
popd
if [ -f $servicename ]; then
systemctl disable opengauss.service
rm $servicename
fi
cp %{tmppath}/script/opengauss.service /usr/lib/systemd/system/
systemctl daemon-reload
# upgrade backup
pid=$(ps -ef | grep /var/lib/opengauss/data | grep -v grep | awk '{print $2}')
if [ "$pid" != "" ]; then
kill -9 $pid
fi
cp -rf /usr/local/opengauss /usr/local/opengauss_%{version}
fi
%postun
%preun
remove_service(){
servicename=/usr/lib/systemd/system/opengauss.service
if [ -f $servicename ]; then
@ -281,35 +370,74 @@ remove_service(){
rm $servicename
fi
}
# 0: uninstall 1:upgrade
if [ $1 -eq 0 ]; then
echo "remove opengauss service"
remove_service
fi
%postun
clear_database(){
pid=$(ps -ef | grep /var/lib/opengauss/data | grep -v grep | awk '{print $2}')
if [ "$pid" != "" ]; then
kill -9 $pid
fi
if [ -d /var/lib/opengauss/data ]; then
rm -rf /var/lib/opengauss/data
fi
if [ -d /usr/local/opengauss ]; then
rm -rf /usr/local/opengauss
fi
if [ -d /usr/local/opengauss_%{version} ]; then
rm -rf /usr/local/opengauss_%{version}
fi
if [ -f /var/lib/opengauss/recode_install_flag ]; then
rm -rf /var/lib/opengauss/recode_install_flag
fi
if [ -d /var/lib/opengauss/pkg_%{version} ]; then
rm -rf /var/lib/opengauss/pkg_%{version}
fi
if [ -d /var/lib/opengauss/opengauss_upgrade ]; then
rm -rf /var/lib/opengauss/opengauss_upgrade
fi
}
if [ "$1" = "0" ]; then
remove_service
# 0: uninstall
if [ $1 -eq 0 ]; then
echo "clean database"
clear_database
fi
%posttrans
flag=$(cat /var/lib/opengauss/recode_install_flag)
if [ $flag = "install" ]; then
echo "opengauss install successfully!"
echo "Please run: systemctl start opengauss.service"
else
echo "upgrade posttrans"
cp -rf /usr/local/opengauss_%{version}/* /usr/local/opengauss
chown -R opengauss:opengauss /usr/local/opengauss
chmod -R 755 /usr/local/opengauss
systemctl restart opengauss.service
echo "opengauss upgrade successfully"
fi
%files
%defattr (-,root,root)
%{apppath}
%{tmppath}
%doc
%{?_localstatedir}/lib/opengauss
%attr(700,opengauss,opengauss) %dir %{?_localstatedir}/lib/opengauss
%attr(700,opengauss,opengauss) %dir %{?_localstatedir}/lib/opengauss/data
%attr(755,opengauss,opengauss) %dir %{apppath}
%attr(755,opengauss,opengauss) %dir %{tmppath}
%attr(644,opengauss,opengauss) %config(noreplace) %{?_localstatedir}/lib/opengauss/.bash_profile
%changelog
* Fri May 24 2024 zhangzhihui <zhangzhihui42@huawei.com> - 5.0.1-12
* Wed Jun 12 2024 liuheng <liuheng76@huawei.com> - 5.0.1-14
- Fix bugs: #IA4KLQ #IA4PTU
* Fri May 24 2024 zhangzhihui <zhangzhihui42@huawei.com> - 5.0.1-13
- upgrade function
* Mon May 6 2024 liuheng <liuheng76@huawei.com> - 5.0.1-12

View File

@ -6,9 +6,9 @@ After=local-fs.target
Type=forking
User=opengauss
WorkingDirectory=/var/lib/opengauss
ExecStart=/bin/bash -c 'source ~/.bashrc; gs_ctl start -D /var/lib/opengauss/data'
ExecStop=/bin/bash -c 'source ~/.bashrc; gs_ctl stop -D /var/lib/opengauss/data'
ExecReload=/bin/bash -c 'source ~/.bashrc; gs_ctl reload -D /var/lib/opengauss/data'
ExecStart=/bin/bash -c 'source ~/.bash_profile; gs_ctl start -D /var/lib/opengauss/data'
ExecStop=/bin/bash -c 'source ~/.bash_profile; gs_ctl stop -D /var/lib/opengauss/data'
ExecReload=/bin/bash -c 'source ~/.bash_profile; gs_ctl reload -D /var/lib/opengauss/data'
Delegate=yes
RemainAfterExit=yes

1238
opengauss_upgrade_common.sh Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2010-2022. All rights reserved.
# date: 2021-12-22
# version: 1.0
# 数据库监听端口
GAUSS_LISTEN_PORT="7654"
# 数据库管理员用户名
GAUSS_ADMIN_USER="opengauss"
#数据库升级回退日志路径
GAUSS_LOG_PATH="/var/lib/opengauss/opengauss_upgrade"
#数据库升级根位置
GAUSS_UPGRADE_BASE_PATH="/var/lib/opengauss/opengauss_upgrade/pkg_5.0.1"
#数据库SQL包位置
GAUSS_SQL_TAR_PATH="/var/lib/opengauss/opengauss_upgrade/pkg_5.0.1"
#数据库低版本备份位置
GAUSS_BACKUP_BASE_PATH="/var/lib/opengauss/opengauss_upgrade/bak"
#数据库临时目录
GAUSS_TMP_PATH="/var/lib/opengauss/opengauss_upgrade/tmp"
#是否使用存在的bin解压包
GAUSS_UPGRADE_BIN_PATH=""
#需要同步的cluster config 列表
GAUSS_UPGRADE_SYNC_CONFIG_LIST=""

View File

@ -0,0 +1,18 @@
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2010-2022. All rights reserved.
# date: 2021-12-22
# version: 1.0
err_upgrade_pre=201
err_upgrade_bin=202
err_upgrade_post=203
err_rollback_pre=204
err_rollback_bin=205
err_rollback_post=206
err_check_init=207
err_parameter=208
err_upgrade_commit=209
err_version_same=210
err_no_need_commit=211
err_inner_sys=212
err_dn_role_null=213

View File

@ -0,0 +1,56 @@
#!/bin/bash
# Copyright (c) Huawei Technologies Co., Ltd. 2010-2022. All rights reserved.
# date: 2021-12-22
# version: 1.0
CURRENT_DIR=$(
cd $(dirname $0)
pwd
)
source ${CURRENT_DIR}/opengauss_upgrade_config.sh
source ${CURRENT_DIR}/opengauss_upgrade_common.sh
function main() {
check_and_init
parse_cmd_line $@
case "${action}" in
upgrade_pre)
upgrade_pre
exit 0
;;
upgrade_bin)
upgrade_bin
exit 0
;;
upgrade_post)
upgrade_post
exit 0
;;
rollback_pre)
rollback_pre
exit 0
;;
rollback_bin)
rollback_bin
exit 0
;;
rollback_post)
rollback_post
exit 0
;;
upgrade_commit)
upgrade_commit
exit 0
;;
switch_over)
switch_over
exit 0
;;
*)
log "please input right parameter, the following command may help you"
log "sh upgrade_GAUSSV5.sh --help or sh upgrade_GAUSSV5.sh -h"
die "Must input parameter -t action" ${err_parameter}
;;
esac
}
main $@

159
upgrade.patch Normal file
View File

@ -0,0 +1,159 @@
diff -crN '--exclude=.git' '--exclude=.gitee' '--exclude=.vscode' openGauss-server-5.0.1/liteom/upgrade_common.sh openGauss-server-5.0.1-edit/liteom/upgrade_common.sh
*** openGauss-server-5.0.1/liteom/upgrade_common.sh 2024-05-09 14:48:32.000000000 +0800
--- openGauss-server-5.0.1-edit/liteom/upgrade_common.sh 2024-06-07 17:31:52.228407016 +0800
***************
*** 273,284 ****
}
function check_version() {
- if [[ ! -f "${GAUSSHOME}/version.cfg" ]]; then
- die "Cannot find current version.cfg!" ${err_upgrade_pre}
- else
- old_version=$(tail -n 1 "$GAUSSHOME"/version.cfg)
- old_cfg=$(sed -n 2p "$GAUSSHOME"/version.cfg | sed 's/\.//g')
- fi
if [[ -f "$GAUSS_UPGRADE_BIN_PATH"/version.cfg ]]; then
new_version_cfg_path="${GAUSS_UPGRADE_BIN_PATH}/version.cfg"
elif [[ -f "$GAUSS_UPGRADE_BASE_PATH"/version.cfg ]]; then
--- 273,278 ----
***************
*** 290,333 ****
new_version=$(tail -n 1 "$new_version_cfg_path")
new_cfg=$(sed -n 2p "$new_version_cfg_path" | sed 's/\.//g')
- if [[ X"$old_version" == X || X"$old_cfg" == X || X"$new_version" == X || X"$new_cfg" == X ]]; then
- die "Maybe version.cfg is not normal" ${err_upgrade_pre}
- fi
- if ! echo "$old_cfg"|grep -Ewq "[0-9]{3,6}";then
- die "Maybe version.cfg is not normal" ${err_upgrade_pre}
- fi
if ! echo "$new_cfg"|grep -Ewq "[0-9]{3,6}";then
die "Maybe version.cfg is not normal" ${err_upgrade_pre}
fi
! if [[ "$old_version" == "$new_version" ]]; then
! die "New version is same as old, the commitId is $old_version!" ${err_version_same}
! fi
! if [[ ${new_cfg} -lt ${old_cfg} ]]; then
! die "Current version is newer!" ${err_upgrade_pre}
! fi
! big_cfg="False"
! if [[ ${new_cfg} -gt ${old_cfg} ]]; then
! log "Big upgrade is needed!"
! big_cfg="True"
! fi
local flag_file="$GAUSS_TMP_PATH"/version_flag
- if echo "old_version=$old_version" > "$flag_file" && chmod 600 "$flag_file"; then
- debug "Begin to generate $flag_file"
- else
- die "Write $flag_file failed" ${err_upgrade_pre}
- fi
if ! echo "new_version=$new_version" >> "$flag_file"; then
die "Write $flag_file failed" ${err_upgrade_pre}
fi
if ! echo "big_cfg=$big_cfg" >> "$flag_file"; then
die "Write $flag_file failed" ${err_upgrade_pre}
fi
- if ! echo "old_cfg=$old_cfg" >> "$flag_file"; then
- die "Write $flag_file failed" ${err_upgrade_pre}
- fi
- log "Old version commitId is $old_version, version info is $old_cfg"
log "New version commitId is $new_version, version info is $new_cfg"
##need version.cfg to check big upgrade,note user exec sql on primary dn
--- 284,302 ----
new_version=$(tail -n 1 "$new_version_cfg_path")
new_cfg=$(sed -n 2p "$new_version_cfg_path" | sed 's/\.//g')
if ! echo "$new_cfg"|grep -Ewq "[0-9]{3,6}";then
die "Maybe version.cfg is not normal" ${err_upgrade_pre}
fi
! big_cfg="True"
local flag_file="$GAUSS_TMP_PATH"/version_flag
if ! echo "new_version=$new_version" >> "$flag_file"; then
die "Write $flag_file failed" ${err_upgrade_pre}
fi
if ! echo "big_cfg=$big_cfg" >> "$flag_file"; then
die "Write $flag_file failed" ${err_upgrade_pre}
fi
log "New version commitId is $new_version, version info is $new_cfg"
##need version.cfg to check big upgrade,note user exec sql on primary dn
***************
*** 1239,1242 ****
fi
rm -f "$GAUSS_TMP_PATH"/version_flag
rm -f "$GAUSS_TMP_PATH"/record_step.txt
! }
\ No newline at end of file
--- 1208,1211 ----
fi
rm -f "$GAUSS_TMP_PATH"/version_flag
rm -f "$GAUSS_TMP_PATH"/record_step.txt
! }
diff -crN '--exclude=.git' '--exclude=.gitee' '--exclude=.vscode' openGauss-server-5.0.1/liteom/upgrade_config.sh openGauss-server-5.0.1-edit/liteom/upgrade_config.sh
*** openGauss-server-5.0.1/liteom/upgrade_config.sh 2024-05-09 14:48:32.000000000 +0800
--- openGauss-server-5.0.1-edit/liteom/upgrade_config.sh 2024-06-06 16:56:26.681705002 +0800
***************
*** 4,31 ****
# version: 1.0
# 数据库监听端口
! GAUSS_LISTEN_PORT=""
# 数据库管理员用户名
! GAUSS_ADMIN_USER=""
#数据库升级回退日志路径
! GAUSS_LOG_PATH=""
#数据库升级根位置
! GAUSS_UPGRADE_BASE_PATH=""
#数据库SQL包位置
! GAUSS_SQL_TAR_PATH=""
#数据库低版本备份位置
! GAUSS_BACKUP_BASE_PATH=""
#数据库临时目录
! GAUSS_TMP_PATH=""
#是否使用存在的bin解压包
GAUSS_UPGRADE_BIN_PATH=""
#需要同步的cluster config 列表
! GAUSS_UPGRADE_SYNC_CONFIG_LIST=""
\ No newline at end of file
--- 4,31 ----
# version: 1.0
# 数据库监听端口
! GAUSS_LISTEN_PORT="7654"
# 数据库管理员用户名
! GAUSS_ADMIN_USER="opengauss"
#数据库升级回退日志路径
! GAUSS_LOG_PATH="/usr/local/opengauss_upgrade"
#数据库升级根位置
! GAUSS_UPGRADE_BASE_PATH="/usr/local/opengauss_upgrade/pkg_5.0.1"
#数据库SQL包位置
! GAUSS_SQL_TAR_PATH="/usr/local/opengauss_upgrade/pkg_5.0.1"
#数据库低版本备份位置
! GAUSS_BACKUP_BASE_PATH="/usr/local/opengauss_upgrade/bak"
#数据库临时目录
! GAUSS_TMP_PATH="/usr/local/opengauss_upgrade/tmp"
#是否使用存在的bin解压包
GAUSS_UPGRADE_BIN_PATH=""
#需要同步的cluster config 列表
! GAUSS_UPGRADE_SYNC_CONFIG_LIST=""

3
version.cfg Normal file
View File

@ -0,0 +1,3 @@
openGauss-Lite-5.0.1
92.854
33b035fd