optimize systemd

This commit is contained in:
LINxiansheng
2024-04-12 12:57:45 +00:00
committed by ob-robot
parent 0c8e87bff2
commit cc18fb1847
21 changed files with 282 additions and 171 deletions

18
.gitignore vendored
View File

@ -289,14 +289,16 @@ tools/deploy/single-with-proxy.yaml
tools/deploy/single.yaml
tools/docker/standalone/boot
tools/docker/standalone/init_store_for_fast_start.py
tools/rpm/systemd/profile/oceanbase-service.sh
tools/rpm/systemd/profile/post_install.sh
tools/rpm/systemd/profile/pre_uninstall.sh
tools/rpm/systemd/profile/post_uninstall.sh
tools/rpm/systemd/profile/telemetry.sh
tools/rpm/systemd/profile/postinst
tools/rpm/systemd/profile/prerm
tools/rpm/systemd/profile/postrm
tools/systemd/profile/oceanbase-service.sh
tools/systemd/profile/pre_install.sh
tools/systemd/profile/post_install.sh
tools/systemd/profile/pre_uninstall.sh
tools/systemd/profile/post_uninstall.sh
tools/systemd/profile/telemetry.sh
tools/systemd/profile/preinst
tools/systemd/profile/postinst
tools/systemd/profile/prerm
tools/systemd/profile/postrm
############# unittest #############
unittest/**/test_*

View File

@ -188,6 +188,8 @@
http://helloworld.com/*
http://1.1.1.1:8080/*
https://mirrors.aliyun.com/*
https://mirrors.oceanbase.com/*
http://mirrors.oceanbase.com/*
https://bixense.com/clicolors/
martin.gieseking@uos.de
jloup@gzip.org

View File

@ -45,30 +45,34 @@ if (OB_BUILD_OPENSOURCE)
set(CPACK_DEBIAN_SERVER_PACKAGE_DEPENDS "oceanbase-ce-libs (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE})")
set(CPACK_DEBIAN_SERVER_PACKAGE_DEPENDS "${CPACK_DEBIAN_SERVER_PACKAGE_DEPENDS}, jq, systemd")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/postinst
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_install.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/preinst
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/pre_uninstall.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/prerm
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_install.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/postinst
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_uninstall.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/postrm
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_uninstall.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/prerm
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_uninstall.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/postrm
@ONLY)
set(CPACK_DEBIAN_SERVER_PACKAGE_CONTROL_EXTRA
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/postinst
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/prerm
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/postrm)
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/postinst
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/prerm
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/postrm)
endif()
# add the deb post and pre script
if (OB_BUILD_OPENSOURCE)
install(FILES
tools/rpm/systemd/profile/postinst
tools/rpm/systemd/profile/prerm
tools/rpm/systemd/profile/postrm
tools/systemd/profile/postinst
tools/systemd/profile/prerm
tools/systemd/profile/postrm
DESTINATION profile
COMPONENT server)
endif()

View File

@ -25,11 +25,11 @@ set(BITCODE_TO_ELF_LIST "")
# systemd define on package
if (OB_BUILD_OPENSOURCE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/oceanbase-service.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/oceanbase-service.sh
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/oceanbase-service.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/oceanbase-service.sh
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/telemetry.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/telemetry.sh
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/telemetry.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/telemetry.sh
@ONLY)
endif()
@ -75,11 +75,11 @@ install(
if (OB_BUILD_OPENSOURCE)
install(FILES
tools/rpm/systemd/profile/oceanbase.cnf
tools/rpm/systemd/profile/oceanbase-pre.json
tools/rpm/systemd/profile/oceanbase.service
tools/rpm/systemd/profile/oceanbase-service.sh
tools/rpm/systemd/profile/telemetry.sh
tools/systemd/profile/oceanbase.cnf
tools/systemd/profile/oceanbase-pre.json
tools/systemd/profile/oceanbase.service
tools/systemd/profile/oceanbase-service.sh
tools/systemd/profile/telemetry.sh
DESTINATION profile
COMPONENT server)
endif()

View File

@ -62,20 +62,25 @@ set(CPACK_RPM_SPEC_MORE_DEFINE
if (OB_BUILD_OPENSOURCE)
set(CPACK_RPM_SERVER_PACKAGE_REQUIRES "oceanbase-ce-libs = ${CPACK_PACKAGE_VERSION}, jq, systemd")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_install.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_install.sh
@ONLY)
set(CPACK_RPM_SERVER_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh)
set(CPACK_RPM_SERVER_PRE_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_install.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/pre_uninstall.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/pre_uninstall.sh
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_install.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_install.sh
@ONLY)
set(CPACK_RPM_SERVER_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/pre_uninstall.sh)
set(CPACK_RPM_SERVER_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_install.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_uninstall.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_uninstall.sh
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_uninstall.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_uninstall.sh
@ONLY)
set(CPACK_RPM_SERVER_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_uninstall.sh)
set(CPACK_RPM_SERVER_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_uninstall.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_uninstall.sh.template
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_uninstall.sh
@ONLY)
set(CPACK_RPM_SERVER_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_uninstall.sh)
endif()
## server
@ -89,9 +94,10 @@ endif()
# add the rpm post and pre script
if (OB_BUILD_OPENSOURCE)
install(FILES
tools/rpm/systemd/profile/post_install.sh
tools/rpm/systemd/profile/post_uninstall.sh
tools/rpm/systemd/profile/pre_uninstall.sh
tools/systemd/profile/pre_install.sh
tools/systemd/profile/post_install.sh
tools/systemd/profile/post_uninstall.sh
tools/systemd/profile/pre_uninstall.sh
DESTINATION profile
COMPONENT server)
endif()

View File

@ -82,6 +82,9 @@ function get_os_release() {
fedora)
version_ge "33" && compat_centos7 && return
;;
openEuler)
version_ge "22" && compat_centos9 && return
;;
opensuse-leap)
version_ge "15" && compat_centos7 && return
;;
@ -108,6 +111,11 @@ function get_os_release() {
version_ge "8.0" && compat_centos8 && return
version_ge "7.0" && compat_centos7 && return
;;
anolis)
version_ge "23.0" && compat_centos9 && return
version_ge "8.0" && compat_centos8 && return
version_ge "7.0" && compat_centos7 && return
;;
centos)
version_ge "8.0" && OS_RELEASE=8 && return
version_ge "7.0" && OS_RELEASE=7 && return
@ -116,6 +124,9 @@ function get_os_release() {
version_ge "12" && compat_centos9 && return
version_ge "9" && compat_centos7 && return
;;
openEuler)
version_ge "22" && compat_centos9 && return
;;
ubuntu)
version_ge "22.04" && compat_centos9 && return
version_ge "16.04" && compat_centos7 && return

View File

@ -1,27 +0,0 @@
# 通过yum和systemd的方式安装OceanBase数据库
如果你想在linux rpm平台上部署oceanbase,可以使用yum进行单节点安装,并通过systemd进行简单管理
**注意**
- 该方法仅能用做学习研究或测试使用;
- 千万不要使用此方法用于带有重要数据的场景,比如生产环境。
## 安装方法
现在暂时只支持RPM平台系统,可以通过以下指令进行安装和启动:
```bash
yum install oceanbase-ce
systemctl start oceanbase
```
可以通过以下指令将oceanbase服务设置为开机自启动:
```bash
systemctl enable oceanbase
```
## systemd介绍
Systemd提供了自动化管理oceanbase的启动和停止,可以通过systemctl指令对oceanbase进行管理控制,例如:
```bash
systemctl {start|stop|restart|status} oceanbase
```
## 通过systemd配置oceanbase
systemd提供了配置文件`/etc/oceanbase.cnf`,可以在启动前修改配置进行带参启动

View File

@ -1,27 +0,0 @@
# Installing OceanBase Database via yum and systemd
If you want to deploy OceanBase on a Linux RPM platform, you can use yum for single-node installation and simple management with systemd.
**WARNING**
- The installation method is just used for study or test;
- You should not deploy it with important data as it is not used in production environment.
## Installation Method
Now systemd only support RPM platform and you can install and run oceanbase service using the following command:
```bash
yum install oceanbase-ce
systemctl start oceanbase
```
You can set the OceanBase service to start automatically on boot using the following command:
```bash
systemctl enable oceanbase
```
## Overview of systemd
Systemd provides automatic oceanbase startup and shutdown. It also enables manual server management using the systemctl command. For example:
```bash
systemctl {start|stop|restart|status} oceanbase
```
## Oceanbase configuration by systemd
Systemd provide `/etc/oceanbase.cnf` to config oceanbase before startup.

View File

@ -1,14 +0,0 @@
#!/bin/bash
echo "execute post install script"
prefix=@CPACK_PACKAGING_INSTALL_PREFIX@
# prepare the systemd service unit
cp -f $prefix/profile/oceanbase.service /etc/systemd/system/oceanbase.service
chmod 644 /etc/systemd/system/oceanbase.service
chmod +x $prefix/profile/oceanbase-service.sh
cp -f $prefix/profile/oceanbase.cnf /etc/oceanbase.cnf
systemctl daemon-reload
# telemetry
/bin/bash $prefix/profile/telemetry.sh $1 >/dev/null 2>&1

View File

@ -1,6 +0,0 @@
#!/bin/bash
echo "execute post uninstall script"
prefix=@CPACK_PACKAGING_INSTALL_PREFIX@
rm -rf $prefix/.meta $prefix/log_obshell

View File

@ -0,0 +1,54 @@
# 通过软件源安装 OceanBase 数据库
如果你想在Linux rpm或deb平台上部署OceanBase,可以使用yum或apt进行单节点安装,并通过systemd进行简单管理
**注意**
- 该方法仅能用做学习研究或测试使用;
- 千万不要使用此方法用于带有重要数据的场景,比如生产环境。
## 通过 YUM 仓库安装 OceanBase
配置yum源,安装OceanBase,会自动安装所需依赖
```bash
yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
yum install -y oceanbase-ce
```
## 通过 APT 仓库安装 OceanBase
配置apt源,安装OceanBase,会自动安装所需依赖
```bash
apt update
apt install -y lsb-release wget gnupg2 mysql-client curl
wget http://mirrors.oceanbase.com/oceanbase/oceanbase_deb.pub && apt-key add oceanbase_deb.pub
echo "deb http://mirrors.oceanbase.com/oceanbase/community/stable/$(lsb_release -is | awk '{print tolower($0)}')/$(lsb_release -cs)/$(dpkg --print-architecture)/ ./" | tee -a /etc/apt/sources.list.d/oceanbase.list
apt update
apt install -y oceanbase-ce
```
## 依赖列表说明:
| 组件 | 版本 |
|-------|-------|
| oceanbase-ce-libs | 与oceanbase-ce相同版本 |
| jq | / |
| oniguruma | / |
| curl | / |
# 启动方法
可以通过以下指令进行启动:
```bash
systemctl start oceanbase
```
可以通过以下指令将oceanbase服务设置为开机自启动:
```bash
systemctl enable oceanbase
```
## systemd介绍
Systemd提供了自动化管理oceanbase的启动和停止,可以通过systemctl指令对oceanbase进行管理控制,例如:
```bash
systemctl {start|stop|restart|status} oceanbase
```
## 通过systemd配置OceanBase
systemd提供了配置文件`/etc/oceanbase.cnf`,可以在启动前修改配置进行带参启动

53
tools/systemd/README.md Normal file
View File

@ -0,0 +1,53 @@
# Installing OceanBase Database via yum/apt
If you want to deploy OceanBase on a Linux RPM platform, you can use yum/apt for single-node installation and simple management with systemd.
**WARNING**
- The installation method is just used for study or test;
- You should not deploy it with important data as it is not used in production environment.
## Installing OceanBase via yum
Config yum repo then install OceanBase, it will automatically install the required dependencies.
```bash
yum install -y yum-utils
yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
yum install -y oceanbase-ce
```
## Installing OceanBase via apt
Config apt repo then install OceanBase, it will automatically install the required dependencies.
```bash
apt update
apt install -y lsb-release wget gnupg2 mysql-client curl
wget http://mirrors.oceanbase.com/oceanbase/oceanbase_deb.pub && apt-key add oceanbase_deb.pub
echo "deb http://mirrors.oceanbase.com/oceanbase/community/stable/$(lsb_release -is | awk '{print tolower($0)}')/$(lsb_release -cs)/$(dpkg --print-architecture)/ ./" | tee -a /etc/apt/sources.list.d/oceanbase.list
apt update
apt install -y oceanbase-ce
```
## Dependencies list:
| dependency | version |
|-------|-------|
| oceanbase-ce-libs | same version with oceanbase-ce |
| jq | / |
| oniguruma | / |
| curl | / |
# Startup Method
You can install and run OceanBase service using the following command:
```bash
systemctl start oceanbase
```
You can set the OceanBase service to start automatically on boot using the following command:
```bash
systemctl enable oceanbase
```
## Overview of systemd
Systemd provides automatic OceanBase startup and shutdown. It also enables manual server management using the systemctl command. For example:
```bash
systemctl {start|stop|restart|status} oceanbase
```
## Oceanbase configuration by systemd
Systemd provide `/etc/oceanbase.cnf` to config OceanBase before startup.

View File

@ -2,12 +2,14 @@
DATE=`date '+%Y-%m-%d %H:%M:%S'`
cnf_file='/etc/oceanbase.cnf'
ip=`hostname -i`
ip=`hostname -I | awk '/^[0-9]/ {print $1; exit}'`
port=2886
url="http://localhost"
prefix=@CPACK_PACKAGING_INSTALL_PREFIX@
unix_socket="$prefix/run/obshell.sock"
obshell="$prefix/bin/obshell"
etc_folder="$prefix/etc"
current_user=`whoami`
report=3
function prepare_config_json {
@ -44,6 +46,11 @@ function prepare_config_json {
sed -i "s|HOSTIP|${ip}|g" $json_file
}
function prepare_env {
echo "change etc owner to ${current_user}"
chown $current_user:$current_user "${etc_folder}"
}
function do_reload_observer {
echo "Not support reload now"
}
@ -73,8 +80,8 @@ function check_obagent_process {
echo "obshell process with PID $pid is not running."
$obshell admin start --ip $ip --port $port
if [ $? -ne 0 ]; then
echo "start ob_agent failed"
exit
echo "start ob_shell failed"
exit 1
fi
fi
else
@ -104,10 +111,10 @@ function check_trace {
state=$(echo "$response" | jq -r '.data.state')
echo "the response state is $state"
if [ "x$state" = "xSUCCEED" ]; then
echo "request successfully"
echo "$content request successfully"
break
elif [ "x$state" = "xFAILED" ]; then
echo "request failed"
echo "$content request failed"
exit 1
else
count=$((count + 1))
@ -124,8 +131,8 @@ function check_trace {
function start_obshell {
$obshell admin start --ip $ip --port $port > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "start ob_agent failed"
exit
echo "start ob_shell failed"
exit 1
fi
}
@ -170,19 +177,10 @@ function do_config_observer {
check_trace $trace "config observer" 3 3
}
function deploy_observer {
echo "oceanbase service deployed at ${DATE}"
prepare_config_json
start_obshell
do_config_observer
}
function start_observer {
systemd-notify --ready
function do_start_observer {
# check observer status
response=$(curl --silent -H "Content-Type: application/json" -X GET --unix-socket $unix_socket $url/api/v1/status)
identity=$(echo "$response" | jq -r '.data.agent.identity')
systemd-notify "STATUS=Service is running"
if [ "x$identity" = "xCLUSTER AGENT" ]; then
echo "The observer is already bootstrap, please start it immediately"
response=$(curl --silent -H "Content-Type: application/json" -X POST -d '{
@ -223,41 +221,40 @@ function start_observer {
echo "The observer has been installed before"
fi
systemd-notify --status="Service is ready"
if [ -f $prefix/run/observer.pid ]; then
pid=$(cat $prefix/run/observer.pid)
while true; do
if [ ! -d "/proc/$pid" ]; then
echo "Observer process with PID $pid has exited."
break
fi
if [ ! -d "/proc/$pid" ]; then
echo "Observer process with PID $pid has exited."
break
fi
echo "Observer process with PID $pid is still running."
# check observer state
response=$(curl --silent -H "Content-Type: application/json" -X GET -d '{
"scope":
{
"type":"global",
"target":[]
},
"force": true
}' --unix-socket $unix_socket $url/api/v1/status)
ob_state=$(echo "$response" | jq -r '.data.obState')
if [ "x$ob_state" = "x1" ]; then
echo "The agent dose not know the observer password"
echo "1. Please set environment: export OB_ROOT_PASSWORD={root_passowrd}"
echo "2. Kill all the obshell process"
echo "3. Restart the agent process: $prefix/bin/obshell admin start --ip $ip --port $port"
fi
sleep 30
done
# check observer state
response=$(curl --silent -H "Content-Type: application/json" -X GET --unix-socket $unix_socket $url/api/v1/status)
ob_state=$(echo "$response" | jq -r '.data.obState')
if [ "x$ob_state" = "x1" ]; then
echo "The agent dose not know the observer password"
echo "1. Please set environment: export OB_ROOT_PASSWORD={root_passowrd}"
echo "2. Kill all the obshell process"
echo "3. Restart the agent process: $prefix/bin/obshell admin start --ip $ip --port $port"
fi
else
echo "observer PID file not found."
exit 1
fi
}
function start_observer {
/bin/bash $prefix/profile/telemetry.sh $report "10" >/dev/null 2>&1
prepare_config_json
prepare_env
if check_daemon_process; then
echo "The agent service is exist"
else
start_obshell
fi
do_start_observer
}
function stop_observer {
check_obagent_process
response=$(curl --silent -H "Content-Type: application/json" -X POST -d '{
@ -275,7 +272,6 @@ function stop_observer {
fi
trace=$(echo "$response" | jq -r '.data.id')
check_trace $trace "stop observer" 20 6
systemd-notify --status='STOPPING=1'
}
function reload_observer {
@ -286,15 +282,7 @@ function reload_observer {
if [ "x$1" = "xstart" ]; then
echo "oceanbase service started at ${DATE}"
/bin/bash $prefix/profile/telemetry.sh $report "10" >/dev/null 2>&1
prepare_config_json
if check_daemon_process; then
echo "The agent service is exist"
else
start_obshell
fi
start_observer
elif [ "x$1" = "xstop" ]; then
echo "oceanbase service stopped at ${DATE}"
stop_observer
@ -307,7 +295,7 @@ elif [ "x$1" = "xdestroy" ]; then
$obshell admin stop > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "stop obshell failed"
exit
exit 1
fi
fi

View File

@ -3,11 +3,22 @@ Description=oceanbase
[Service]
User=root
Type=notify
Type=forking
KillMode=none
ExecStart=/bin/bash /home/admin/oceanbase/profile/oceanbase-service.sh start
ExecStop=/bin/bash /home/admin/oceanbase/profile/oceanbase-service.sh stop
ExecReload=/bin/bash /home/admin/oceanbase/profile/oceanbase-service.sh reload
PIDFile=/home/admin/oceanbase/run/observer.pid
TimeoutSec=2000
TimeoutStopSec=300
Restart=on-failure
RestartSec=10
SuccessExitStatus=SIGKILL
SendSIGKILL=no
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
LimitSTACK=infinity
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,20 @@
#!/bin/bash
echo "execute post install script"
prefix=@CPACK_PACKAGING_INSTALL_PREFIX@
# prepare the systemd service unit
cp -f $prefix/profile/oceanbase.service /etc/systemd/system/oceanbase.service
chmod 644 /etc/systemd/system/oceanbase.service
chmod +x $prefix/profile/oceanbase-service.sh
cp -f $prefix/profile/oceanbase.cnf /etc/oceanbase.cnf
systemctl daemon-reload
# telemetry
/bin/bash $prefix/profile/telemetry.sh $1 >/dev/null 2>&1
GREEN='\033[32m'
NC="\033[0m"
echo -e "${GREEN}To configure OceanBase${NC} : edit /etc/oceanbase.cnf"
echo -e "${GREEN}To start OceanBase${NC} : systemctl start oceanbase"
echo -e "${GREEN}To enable OceanBase auto reboot ${NC} : systemctl enable oceanbase"
echo -e "${GREEN}To get more infomation${NC} : https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000000640297"

View File

@ -0,0 +1,24 @@
#!/bin/bash
echo "execute post uninstall script"
prefix=@CPACK_PACKAGING_INSTALL_PREFIX@
json_file=$prefix/profile/oceanbase.json
GREEN='\033[32m'
NC="\033[0m"
if [ $1 -eq 0 ]; then
rm -rf $prefix/.meta $prefix/log_obshell
# prepare clean script
echo "find $prefix/ -mindepth 1 -maxdepth 1 ! -name lib -exec rm -rf {} +" > $prefix/oceanbase_clean.sh
if [ -f "$json_file" ] && [ -s "$json_file" ]; then
redo_dir=$(cat "$json_file" | jq -r '.oceanbase_ce.server.observerConfig.redo_dir')
echo "rm -rf $redo_dir" >> $prefix/oceanbase_clean.sh
data_dir=$(cat "$json_file" | jq -r '.oceanbase_ce.server.observerConfig.data_dir')
echo "rm -rf $data_dir" >> $prefix/oceanbase_clean.sh
echo "echo OK" >> $prefix/oceanbase_clean.sh
fi
echo "Clean oceanbase script can clean ob all configuration files and all data files."
echo -e "${GREEN}To clean OceanBase${NC} : bash $prefix/oceanbase_clean.sh"
fi

View File

@ -0,0 +1,11 @@
#!/bin/bash
echo "execute pre install script"
version=@OceanBase_CE_VERSION@
if [ "$1" -gt 1 ]; then
parent_name=$(cat /proc/$PPID/comm)
if [[ "$parent_name" != "ocp_mgragent" ]]; then
echo "The upgrade of the oceanbase $version is not allowed." >&2
exit 1
fi
fi

View File

@ -1,5 +1,4 @@
#!/bin/bash
echo "execute pre uninstall script"
prefix=@CPACK_PACKAGING_INSTALL_PREFIX@

View File

@ -4,7 +4,7 @@ url="https://openwebapi.oceanbase.com/api/web/oceanbase/report"
type=@CPACK_PACKAGE_NAME@
version=@CPACK_PACKAGE_VERSION@
release=@CPACK_RPM_PACKAGE_RELEASE@
ip=$(hostname -i)
ip=$(hostname -I | awk '/^[0-9]/ {print $1; exit}')
hostHash=$(echo -n "$ip" | sha1sum | awk '{print $1}')
osName=$(cat /etc/os-release | grep "^ID=" | cut -f2 -d=)
osRelease=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -f2 -d=)