Skip to content

Commit cc18fb1

Browse files
LINxianshengob-robot
authored andcommitted
optimize systemd
1 parent 0c8e87b commit cc18fb1

21 files changed

+282
-171
lines changed

.gitignore

+10-8
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,16 @@ tools/deploy/single-with-proxy.yaml
289289
tools/deploy/single.yaml
290290
tools/docker/standalone/boot
291291
tools/docker/standalone/init_store_for_fast_start.py
292-
tools/rpm/systemd/profile/oceanbase-service.sh
293-
tools/rpm/systemd/profile/post_install.sh
294-
tools/rpm/systemd/profile/pre_uninstall.sh
295-
tools/rpm/systemd/profile/post_uninstall.sh
296-
tools/rpm/systemd/profile/telemetry.sh
297-
tools/rpm/systemd/profile/postinst
298-
tools/rpm/systemd/profile/prerm
299-
tools/rpm/systemd/profile/postrm
292+
tools/systemd/profile/oceanbase-service.sh
293+
tools/systemd/profile/pre_install.sh
294+
tools/systemd/profile/post_install.sh
295+
tools/systemd/profile/pre_uninstall.sh
296+
tools/systemd/profile/post_uninstall.sh
297+
tools/systemd/profile/telemetry.sh
298+
tools/systemd/profile/preinst
299+
tools/systemd/profile/postinst
300+
tools/systemd/profile/prerm
301+
tools/systemd/profile/postrm
300302

301303
############# unittest #############
302304
unittest/**/test_*

.secignore

+2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@
188188
http://helloworld.com/*
189189
http://1.1.1.1:8080/*
190190
https://mirrors.aliyun.com/*
191+
https://mirrors.oceanbase.com/*
192+
http://mirrors.oceanbase.com/*
191193
https://bixense.com/clicolors/
192194
193195

cmake/DEB.cmake

+16-12
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,34 @@ if (OB_BUILD_OPENSOURCE)
4545
set(CPACK_DEBIAN_SERVER_PACKAGE_DEPENDS "oceanbase-ce-libs (= ${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE})")
4646
set(CPACK_DEBIAN_SERVER_PACKAGE_DEPENDS "${CPACK_DEBIAN_SERVER_PACKAGE_DEPENDS}, jq, systemd")
4747

48-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh.template
49-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/postinst
48+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_install.sh.template
49+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/preinst
5050
@ONLY)
5151

52-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/pre_uninstall.sh.template
53-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/prerm
52+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_install.sh.template
53+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/postinst
5454
@ONLY)
5555

56-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_uninstall.sh.template
57-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/postrm
56+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_uninstall.sh.template
57+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/prerm
58+
@ONLY)
59+
60+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_uninstall.sh.template
61+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/postrm
5862
@ONLY)
5963

6064
set(CPACK_DEBIAN_SERVER_PACKAGE_CONTROL_EXTRA
61-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/postinst
62-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/prerm
63-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/postrm)
65+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/postinst
66+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/prerm
67+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/postrm)
6468
endif()
6569

6670
# add the deb post and pre script
6771
if (OB_BUILD_OPENSOURCE)
6872
install(FILES
69-
tools/rpm/systemd/profile/postinst
70-
tools/rpm/systemd/profile/prerm
71-
tools/rpm/systemd/profile/postrm
73+
tools/systemd/profile/postinst
74+
tools/systemd/profile/prerm
75+
tools/systemd/profile/postrm
7276
DESTINATION profile
7377
COMPONENT server)
7478
endif()

cmake/Pack.cmake

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ set(BITCODE_TO_ELF_LIST "")
2525

2626
# systemd define on package
2727
if (OB_BUILD_OPENSOURCE)
28-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/oceanbase-service.sh.template
29-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/oceanbase-service.sh
28+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/oceanbase-service.sh.template
29+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/oceanbase-service.sh
3030
@ONLY)
31-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/telemetry.sh.template
32-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/telemetry.sh
31+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/telemetry.sh.template
32+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/telemetry.sh
3333
@ONLY)
3434
endif()
3535

@@ -75,11 +75,11 @@ install(
7575

7676
if (OB_BUILD_OPENSOURCE)
7777
install(FILES
78-
tools/rpm/systemd/profile/oceanbase.cnf
79-
tools/rpm/systemd/profile/oceanbase-pre.json
80-
tools/rpm/systemd/profile/oceanbase.service
81-
tools/rpm/systemd/profile/oceanbase-service.sh
82-
tools/rpm/systemd/profile/telemetry.sh
78+
tools/systemd/profile/oceanbase.cnf
79+
tools/systemd/profile/oceanbase-pre.json
80+
tools/systemd/profile/oceanbase.service
81+
tools/systemd/profile/oceanbase-service.sh
82+
tools/systemd/profile/telemetry.sh
8383
DESTINATION profile
8484
COMPONENT server)
8585
endif()

cmake/RPM.cmake

+18-12
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,25 @@ set(CPACK_RPM_SPEC_MORE_DEFINE
6262
if (OB_BUILD_OPENSOURCE)
6363
set(CPACK_RPM_SERVER_PACKAGE_REQUIRES "oceanbase-ce-libs = ${CPACK_PACKAGE_VERSION}, jq, systemd")
6464

65-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh.template
66-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh
65+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_install.sh.template
66+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_install.sh
6767
@ONLY)
68-
set(CPACK_RPM_SERVER_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_install.sh)
68+
set(CPACK_RPM_SERVER_PRE_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_install.sh)
6969

70-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/pre_uninstall.sh.template
71-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/pre_uninstall.sh
70+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_install.sh.template
71+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_install.sh
7272
@ONLY)
73-
set(CPACK_RPM_SERVER_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/pre_uninstall.sh)
73+
set(CPACK_RPM_SERVER_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_install.sh)
7474

75-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_uninstall.sh.template
76-
${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_uninstall.sh
75+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_uninstall.sh.template
76+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_uninstall.sh
7777
@ONLY)
78-
set(CPACK_RPM_SERVER_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/rpm/systemd/profile/post_uninstall.sh)
78+
set(CPACK_RPM_SERVER_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/pre_uninstall.sh)
79+
80+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_uninstall.sh.template
81+
${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_uninstall.sh
82+
@ONLY)
83+
set(CPACK_RPM_SERVER_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/systemd/profile/post_uninstall.sh)
7984
endif()
8085

8186
## server
@@ -89,9 +94,10 @@ endif()
8994
# add the rpm post and pre script
9095
if (OB_BUILD_OPENSOURCE)
9196
install(FILES
92-
tools/rpm/systemd/profile/post_install.sh
93-
tools/rpm/systemd/profile/post_uninstall.sh
94-
tools/rpm/systemd/profile/pre_uninstall.sh
97+
tools/systemd/profile/pre_install.sh
98+
tools/systemd/profile/post_install.sh
99+
tools/systemd/profile/post_uninstall.sh
100+
tools/systemd/profile/pre_uninstall.sh
95101
DESTINATION profile
96102
COMPONENT server)
97103
endif()

deps/init/dep_create.sh

+11
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ function get_os_release() {
8282
fedora)
8383
version_ge "33" && compat_centos7 && return
8484
;;
85+
openEuler)
86+
version_ge "22" && compat_centos9 && return
87+
;;
8588
opensuse-leap)
8689
version_ge "15" && compat_centos7 && return
8790
;;
@@ -108,6 +111,11 @@ function get_os_release() {
108111
version_ge "8.0" && compat_centos8 && return
109112
version_ge "7.0" && compat_centos7 && return
110113
;;
114+
anolis)
115+
version_ge "23.0" && compat_centos9 && return
116+
version_ge "8.0" && compat_centos8 && return
117+
version_ge "7.0" && compat_centos7 && return
118+
;;
111119
centos)
112120
version_ge "8.0" && OS_RELEASE=8 && return
113121
version_ge "7.0" && OS_RELEASE=7 && return
@@ -116,6 +124,9 @@ function get_os_release() {
116124
version_ge "12" && compat_centos9 && return
117125
version_ge "9" && compat_centos7 && return
118126
;;
127+
openEuler)
128+
version_ge "22" && compat_centos9 && return
129+
;;
119130
ubuntu)
120131
version_ge "22.04" && compat_centos9 && return
121132
version_ge "16.04" && compat_centos7 && return

tools/rpm/systemd/README-CN.md

-27
This file was deleted.

tools/rpm/systemd/README.md

-27
This file was deleted.

tools/rpm/systemd/profile/post_install.sh.template

-14
This file was deleted.

tools/rpm/systemd/profile/post_uninstall.sh.template

-6
This file was deleted.

tools/systemd/README-CN.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# 通过软件源安装 OceanBase 数据库
2+
如果你想在Linux rpm或deb平台上部署OceanBase,可以使用yum或apt进行单节点安装,并通过systemd进行简单管理
3+
4+
**注意**
5+
6+
- 该方法仅能用做学习研究或测试使用;
7+
- 千万不要使用此方法用于带有重要数据的场景,比如生产环境。
8+
9+
## 通过 YUM 仓库安装 OceanBase
10+
配置yum源,安装OceanBase,会自动安装所需依赖
11+
```bash
12+
yum install -y yum-utils
13+
yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
14+
yum install -y oceanbase-ce
15+
```
16+
17+
## 通过 APT 仓库安装 OceanBase
18+
配置apt源,安装OceanBase,会自动安装所需依赖
19+
```bash
20+
apt update
21+
apt install -y lsb-release wget gnupg2 mysql-client curl
22+
wget http://mirrors.oceanbase.com/oceanbase/oceanbase_deb.pub && apt-key add oceanbase_deb.pub
23+
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
24+
apt update
25+
apt install -y oceanbase-ce
26+
```
27+
28+
## 依赖列表说明:
29+
| 组件 | 版本 |
30+
|-------|-------|
31+
| oceanbase-ce-libs | 与oceanbase-ce相同版本 |
32+
| jq | / |
33+
| oniguruma | / |
34+
| curl | / |
35+
36+
# 启动方法
37+
可以通过以下指令进行启动:
38+
```bash
39+
systemctl start oceanbase
40+
```
41+
42+
可以通过以下指令将oceanbase服务设置为开机自启动:
43+
```bash
44+
systemctl enable oceanbase
45+
```
46+
47+
## systemd介绍
48+
Systemd提供了自动化管理oceanbase的启动和停止,可以通过systemctl指令对oceanbase进行管理控制,例如:
49+
```bash
50+
systemctl {start|stop|restart|status} oceanbase
51+
```
52+
53+
## 通过systemd配置OceanBase
54+
systemd提供了配置文件`/etc/oceanbase.cnf`,可以在启动前修改配置进行带参启动

tools/systemd/README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Installing OceanBase Database via yum/apt
2+
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.
3+
4+
**WARNING**
5+
6+
- The installation method is just used for study or test;
7+
- You should not deploy it with important data as it is not used in production environment.
8+
9+
## Installing OceanBase via yum
10+
Config yum repo then install OceanBase, it will automatically install the required dependencies.
11+
```bash
12+
yum install -y yum-utils
13+
yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
14+
yum install -y oceanbase-ce
15+
```
16+
17+
## Installing OceanBase via apt
18+
Config apt repo then install OceanBase, it will automatically install the required dependencies.
19+
```bash
20+
apt update
21+
apt install -y lsb-release wget gnupg2 mysql-client curl
22+
wget http://mirrors.oceanbase.com/oceanbase/oceanbase_deb.pub && apt-key add oceanbase_deb.pub
23+
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
24+
apt update
25+
apt install -y oceanbase-ce
26+
```
27+
28+
## Dependencies list:
29+
| dependency | version |
30+
|-------|-------|
31+
| oceanbase-ce-libs | same version with oceanbase-ce |
32+
| jq | / |
33+
| oniguruma | / |
34+
| curl | / |
35+
36+
# Startup Method
37+
You can install and run OceanBase service using the following command:
38+
```bash
39+
systemctl start oceanbase
40+
```
41+
You can set the OceanBase service to start automatically on boot using the following command:
42+
```bash
43+
systemctl enable oceanbase
44+
```
45+
46+
## Overview of systemd
47+
Systemd provides automatic OceanBase startup and shutdown. It also enables manual server management using the systemctl command. For example:
48+
```bash
49+
systemctl {start|stop|restart|status} oceanbase
50+
```
51+
52+
## Oceanbase configuration by systemd
53+
Systemd provide `/etc/oceanbase.cnf` to config OceanBase before startup.

0 commit comments

Comments
 (0)