fix 数据目录不为空,也安装成功了
This commit is contained in:
parent
9cbbc806b0
commit
acf0e8a9ff
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
Name: opengauss
|
Name: opengauss
|
||||||
Version: 6.0.0
|
Version: 6.0.0
|
||||||
Release: 18
|
Release: 19
|
||||||
Summary: openGauss is an open source relational database management system
|
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
|
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
|
URL: https://gitee.com/opengauss/openGauss-server
|
||||||
@ -275,37 +275,49 @@ install -m 644 %{SOURCE28} %{buildroot}%{tmppath}/upgrade.sh
|
|||||||
popd
|
popd
|
||||||
|
|
||||||
%pre
|
%pre
|
||||||
|
# add opengauss user
|
||||||
/usr/sbin/groupadd -r opengauss >/dev/null 2>&1 || :
|
/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 || :
|
/usr/sbin/useradd -M -N -g opengauss -r -d %{datapath} -s /bin/bash -c "openGauss Server" opengauss >/dev/null 2>&1 || :
|
||||||
|
|
||||||
# for install step
|
# for install step
|
||||||
# 1:install 2:upgrade
|
# 1:install 2:upgrade
|
||||||
if [ $1 -gt 1 ]; then
|
if [ $1 -eq 1 ]; then
|
||||||
echo "upgrade pre"
|
echo "Preparing for install"
|
||||||
else
|
|
||||||
portinfo=$(lsof -i:%{port})
|
portinfo=$(lsof -i:%{port})
|
||||||
if [ "${portinfo}" != "" ]; then
|
if [ "${portinfo}" != "" ]; then
|
||||||
echo "The port[%{port}] is occupied. Please use command 'lsof -i:%{port} to check it.'"
|
echo "The port[%{port}] is occupied. Please use command 'lsof -i:%{port} to check it.'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ -d /var/lib/opengauss/data ]; then
|
||||||
|
if [ "`ls -A /var/lib/opengauss/data`" != "" ]; then
|
||||||
|
echo "Datanode dir(/var/lib/opengauss/data) is not empty."
|
||||||
|
echo "Please delete dir and reinstall opengauss."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
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."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif [ $1 -eq 2 ]; then
|
||||||
|
echo "Preparing for upgrade"
|
||||||
|
old_version=$(rpm -qi opengauss | grep -i version | awk -F':' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||||
|
if [ "$(printf '%s\n' "%{version}" "$old_version" | sort -V | head -n1)" == "$old_version" ]; then
|
||||||
|
echo "Error: New version (${version}) must be greater than the old version ($old_version)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "${old_version}" == "2.1.0" && %{version} == "6.0.0" ]]; then
|
||||||
|
echo "The opengauss do not support upgrade from 2.1.0 to 6.0.0."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
%post
|
%post
|
||||||
start_opengauss(){
|
start_opengauss(){
|
||||||
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."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "`ls -A /var/lib/opengauss/data`" != "" ]; then
|
|
||||||
echo "Datanode dir(/var/lib/opengauss/data) is not empty."
|
|
||||||
echo "Please delete dir and reinstall opengauss."
|
|
||||||
exit 1
|
|
||||||
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 --nodename=single_node")
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Init openGauss database failed."
|
echo "Init openGauss database failed."
|
||||||
@ -426,12 +438,18 @@ else
|
|||||||
rm -rf /usr/local/opengauss
|
rm -rf /usr/local/opengauss
|
||||||
fi
|
fi
|
||||||
mkdir -p /usr/local/opengauss
|
mkdir -p /usr/local/opengauss
|
||||||
cp -rf /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/* /usr/local/opengauss
|
upgrade_result=$(cat /var/lib/opengauss/opengauss_upgrade/tmp/upgrade_result.txt)
|
||||||
|
if [ $upgrade_result == "success" ]; then
|
||||||
|
echo "opengauss upgrade successfully"
|
||||||
|
cp -rf /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/* /usr/local/opengauss
|
||||||
|
else:
|
||||||
|
echo "opengauss upgrade failed, rollback in progress"
|
||||||
|
cp -rf /var/lib/opengauss/opengauss_upgrade/bak/* /usr/local/opengauss
|
||||||
|
fi
|
||||||
chown -R opengauss:opengauss /usr/local/opengauss
|
chown -R opengauss:opengauss /usr/local/opengauss
|
||||||
chmod -R 755 /usr/local/opengauss
|
chmod -R 755 /usr/local/opengauss
|
||||||
chmod -R 700 /var/lib/opengauss/data
|
chmod -R 700 /var/lib/opengauss/data
|
||||||
systemctl restart opengauss.service
|
systemctl restart opengauss.service
|
||||||
echo "opengauss upgrade successfully"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -445,6 +463,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Dec 10 2024 liuheng <liuheng76@huawei.com> - 6.0.0-19
|
||||||
|
- Fix bugs: #IBAAVY
|
||||||
|
|
||||||
* Thu Dec 5 2024 xiaofan <xiaofan@iscas.ac.cn> - 6.0.0-18
|
* Thu Dec 5 2024 xiaofan <xiaofan@iscas.ac.cn> - 6.0.0-18
|
||||||
- Support riscv64
|
- Support riscv64
|
||||||
|
|
||||||
|
|||||||
34
upgrade.sh
34
upgrade.sh
@ -17,10 +17,11 @@ version=6.0.0
|
|||||||
GAUSS_BASE_PATH="/usr/local/opengauss"
|
GAUSS_BASE_PATH="/usr/local/opengauss"
|
||||||
GAUSS_UPGRADE_BASE_PATH="/var/lib/opengauss/opengauss_upgrade/pkg_${version}"
|
GAUSS_UPGRADE_BASE_PATH="/var/lib/opengauss/opengauss_upgrade/pkg_${version}"
|
||||||
GAUSS_BACKUP_BASE_PATH="/var/lib/opengauss/opengauss_upgrade/bak"
|
GAUSS_BACKUP_BASE_PATH="/var/lib/opengauss/opengauss_upgrade/bak"
|
||||||
GAUSS_TMP_PATH="${GAUSS_UPGRADE_BASE_PATH}/tmp"
|
GAUSS_TMP_PATH="/var/lib/opengauss/opengauss_upgrade/tmp"
|
||||||
GAUSS_LOG_FILE="${GAUSS_UPGRADE_BASE_PATH}/opengauss_upgrade.log"
|
GAUSS_LOG_FILE="/var/lib/opengauss/opengauss_upgrade/opengauss_upgrade.log"
|
||||||
new_opengauss_dir=/var/lib/opengauss/pkg_${version}
|
new_opengauss_dir=/var/lib/opengauss/pkg_${version}
|
||||||
GAUSS_LISTEN_PORT=7654
|
GAUSS_LISTEN_PORT=7654
|
||||||
|
GAUSS_UPGRADE_RESULT_FILE=${GAUSS_TMP_PATH}/upgrade_result.txt
|
||||||
|
|
||||||
function create_dir() {
|
function create_dir() {
|
||||||
rm -rf ${GAUSS_BACKUP_BASE_PATH}
|
rm -rf ${GAUSS_BACKUP_BASE_PATH}
|
||||||
@ -318,6 +319,7 @@ function prepare_sql_all() {
|
|||||||
function pre_exec_sql() {
|
function pre_exec_sql() {
|
||||||
if exec_sql "$GAUSS_TMP_PATH"/temp_sql/temp_upgrade_maindb.sql maindb && exec_sql "$GAUSS_TMP_PATH"/temp_sql/temp_upgrade_otherdb.sql otherdb; then
|
if exec_sql "$GAUSS_TMP_PATH"/temp_sql/temp_upgrade_maindb.sql maindb && exec_sql "$GAUSS_TMP_PATH"/temp_sql/temp_upgrade_otherdb.sql otherdb; then
|
||||||
debug "exec pre sql successfully"
|
debug "exec pre sql successfully"
|
||||||
|
return 0
|
||||||
else
|
else
|
||||||
log "exec pre sql failed"
|
log "exec pre sql failed"
|
||||||
return 1
|
return 1
|
||||||
@ -535,20 +537,21 @@ function delete_tmp_files() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function add_pg_proc_index() {
|
function add_pg_proc_index() {
|
||||||
add_index="start transaction; set isinplaceupgrade=on;
|
version=$(gaussdb -V)
|
||||||
|
if [[ ! $version =~ "V500R002C00" && ! $version =~ "2.1.0" ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
add_index_cmd="start transaction; set isinplaceupgrade=on;
|
||||||
ALTER INDEX pg_proc_proname_args_nsp_index unusable;
|
ALTER INDEX pg_proc_proname_args_nsp_index unusable;
|
||||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 9666;
|
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 9666;
|
||||||
CREATE INDEX pg_catalog.pg_proc_proname_all_args_nsp_index on pg_catalog.pg_proc USING BTREE(proname name_ops, pronamespace oid_ops, propackageid oid_ops);
|
CREATE INDEX pg_catalog.pg_proc_proname_all_args_nsp_index on pg_catalog.pg_proc USING BTREE(proname name_ops, pronamespace oid_ops, propackageid oid_ops);
|
||||||
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
SET LOCAL inplace_upgrade_next_system_object_oids = IUO_CATALOG, false, true, 0, 0, 0, 0;
|
||||||
commit;"
|
commit;"
|
||||||
version=$(gaussdb -V)
|
sqlbegin="gsql -p $GAUSS_LISTEN_PORT -X -t -A "
|
||||||
if [[ $version =~ "V500R002C00" || $version =~ "2.1.0" ]]; then
|
result=$(${sqlbegin} -d postgres -c "${add_index_cmd}")
|
||||||
sqlbegin="gsql -p $GAUSS_LISTEN_PORT -X -t -A "
|
if [ $? -ne 0 ]; then
|
||||||
result=$(${sqlbegin} -d postgres -c "${add_index}")
|
log "Exec sql to get databases failed."
|
||||||
if [ $? -ne 0 ]; then
|
return 1
|
||||||
log "Exec sql to get databases failed."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,6 +572,7 @@ function upgrade_pre() {
|
|||||||
pre_exec_sql
|
pre_exec_sql
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
rollback_pre_sql
|
rollback_pre_sql
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,7 +611,8 @@ function upgrade_post() {
|
|||||||
debug "upgrade post sql successfully"
|
debug "upgrade post sql successfully"
|
||||||
else
|
else
|
||||||
log "upgrade post sql failed"
|
log "upgrade post sql failed"
|
||||||
return 1
|
rollback_post
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,12 +622,12 @@ function upgrade_commit() {
|
|||||||
die "set upgrade_mode to 0 failed" ${err_upgrade_commit}
|
die "set upgrade_mode to 0 failed" ${err_upgrade_commit}
|
||||||
fi
|
fi
|
||||||
# 2.删除临时文件
|
# 2.删除临时文件
|
||||||
delete_tmp_files
|
# delete_tmp_files
|
||||||
}
|
}
|
||||||
|
|
||||||
function cp_bak() {
|
function cp_bak() {
|
||||||
cp -rf ${GAUSS_BASE_PATH}/* ${GAUSS_BACKUP_BASE_PATH}
|
cp -rf ${GAUSS_BASE_PATH}/* ${GAUSS_BACKUP_BASE_PATH}
|
||||||
rm -rf ${GAUSS_BASE_PATH}/*
|
# rm -rf ${GAUSS_BASE_PATH}/*
|
||||||
}
|
}
|
||||||
|
|
||||||
function cp_new() {
|
function cp_new() {
|
||||||
@ -635,6 +640,7 @@ function main() {
|
|||||||
upgrade_post
|
upgrade_post
|
||||||
upgrade_commit
|
upgrade_commit
|
||||||
stop_dbnode
|
stop_dbnode
|
||||||
|
echo "success" > $GAUSS_UPGRADE_RESULT_FILE
|
||||||
# cp_bak
|
# cp_bak
|
||||||
# cp_new
|
# cp_new
|
||||||
# remove_path ${GAUSS_UPGRADE_BASE_PATH}/bin
|
# remove_path ${GAUSS_UPGRADE_BASE_PATH}/bin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user