From 63a664dd8893a376626c19093ff81cd38e9738ba Mon Sep 17 00:00:00 2001 From: root Date: Fri, 24 Dec 2021 21:45:29 +0800 Subject: [PATCH 1/2] add opengauss.service --- autostart.sh | 9 ++++++++ og-edit.patch | 44 ++++++++++++++++++++++++++++++++++++++ opengauss-server.spec | 49 ++++++++++++++++++++++++++++++++++++++----- opengauss.service | 11 ++++++++++ 4 files changed, 108 insertions(+), 5 deletions(-) create mode 100755 autostart.sh create mode 100644 og-edit.patch mode change 100644 => 100755 opengauss-server.spec create mode 100755 opengauss.service diff --git a/autostart.sh b/autostart.sh new file mode 100755 index 0000000..1fc2afb --- /dev/null +++ b/autostart.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +result=`su - opengauss -c "source ~/.bash_profile; gs_ctl start -D /var/lib/opengauss/data"` +if [ $? -ne 0 ]; then + echo "Start openGauss database failed." + echo $result +else + echo "Start openGauss database success." +fi \ No newline at end of file diff --git a/og-edit.patch b/og-edit.patch new file mode 100644 index 0000000..d436a7b --- /dev/null +++ b/og-edit.patch @@ -0,0 +1,44 @@ +diff -crN openGauss-server-2.1.0/src/bin/psql/startup.cpp openGauss-server-2.1.0-edit/src/bin/psql/startup.cpp +*** openGauss-server-2.1.0/src/bin/psql/startup.cpp 2021-12-13 16:23:09.000000000 +0800 +--- openGauss-server-2.1.0-edit/src/bin/psql/startup.cpp 2022-01-22 22:08:39.420475340 +0800 +*************** +*** 257,262 **** +--- 257,266 ---- + pset.popt.topt.recordSep.separator_zero = false; + } + ++ if (options.port == NULL) { ++ options.port = GetEnvStr("PORT"); ++ } ++ + if (options.username == NULL) + password_prompt = pg_strdup(_("Password: ")); + else { +*************** +*** 1334,1337 **** + KEY_LEN); + exit(EXIT_FAILURE); + } +! } +\ No newline at end of file +--- 1338,1341 ---- + KEY_LEN); + exit(EXIT_FAILURE); + } +! } +diff -crN openGauss-server-2.1.0/src/gausskernel/dbmind/db4ai/executor/Makefile openGauss-server-2.1.0-edit/src/gausskernel/dbmind/db4ai/executor/Makefile +*** openGauss-server-2.1.0/src/gausskernel/dbmind/db4ai/executor/Makefile 2021-12-13 16:23:09.000000000 +0800 +--- openGauss-server-2.1.0-edit/src/gausskernel/dbmind/db4ai/executor/Makefile 2022-01-22 22:09:13.399068986 +0800 +*************** +*** 11,20 **** + + include $(top_builddir)/src/Makefile.global + +- PLATFORM_ARCH = $(shell uname -p) +- ifeq ($(PLATFORM_ARCH),x86_64) +- override CPPFLAGS += -mavx +- endif + + ifneq "$(MAKECMDGOALS)" "clean" + ifneq "$(MAKECMDGOALS)" "distclean" +--- 11,16 ---- diff --git a/opengauss-server.spec b/opengauss-server.spec old mode 100644 new mode 100755 index 7bf8e24..906e712 --- a/opengauss-server.spec +++ b/opengauss-server.spec @@ -12,7 +12,7 @@ Name: opengauss Version: 2.1.0 -Release: 2 +Release: 3 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,8 +21,11 @@ Source1: %{cjson_name}-%{cjson_version}.tar.gz Source2: %{zlib_name}-%{zlib_version}.tar.gz Source3: %{protobuf_name}-%{protobuf_version}.tar.gz Source4: %{orc_name}-%{orc_version}.tar.gz -Source5: opengauss-bashprofile +Source5: opengauss-bashprofile +Source6: opengauss.service +Source7: autostart.sh +Patch0: og-edit.patch Patch1: 0001-cJSON.patch Patch20: 0001-zlib.patch Patch21: 0002-zlib.patch @@ -32,7 +35,7 @@ Patch40: 0001-orc.patch BuildRequires: cmake gcc gcc-c++ openssl-devel python BuildRequires: cjson lz4-devel protobuf-devel snappy-devel zstd-devel boost-devel -BuildRequires: libcgroup-devel curl-devel unixODBC-devel jemalloc-devel +BuildRequires: libcgroup-devel libcurl-devel unixODBC-devel jemalloc-devel BuildRequires: java-1.8.0-openjdk-devel libedit-devel libaio-devel BuildRequires: bison flex DCF %ifnarch aarch64 %{arm} @@ -44,7 +47,7 @@ BuildRequires: numactl-devel %global __requires_exclude %{_privatelibs} Requires: lz4-devel protobuf-devel snappy-devel zstd-devel boost-devel -Requires: libcgroup-devel curl-devel unixODBC-devel jemalloc-devel +Requires: libcgroup-devel libcurl-devel unixODBC-devel jemalloc-devel Requires: java-1.8.0-openjdk-devel libedit-devel libaio-devel Requires: DCF %ifnarch aarch64 %{arm} @@ -63,6 +66,9 @@ 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} +%patch0 -p1 +popd pushd %{cjson_name}-%{cjson_version} %patch1 -p1 @@ -164,6 +170,7 @@ popd pushd openGauss-server-%{version} %make_install -s %{?_smp_mflags} mkdir -p %{buildroot}/var/lib/opengauss/data +mkdir -p %{buildroot}/%{apppath}/script cp build/script/opengauss_config_file_mini %{buildroot}/%{apppath}/share/postgresql/ popd @@ -172,6 +179,9 @@ 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 %pre /usr/sbin/groupadd -g 39 -o -r opengauss >/dev/null 2>&1 || : @@ -233,12 +243,39 @@ start_opengauss(){ fi } +add_service(){ + cp %{apppath}/script/opengauss.service /usr/lib/systemd/system/ + systemctl enable opengauss.service +} + # for install step if [ $1 = 1 ]; then set_mini_configparam + add_service start_opengauss fi +%postun +remove_service(){ + servicename=/usr/lib/systemd/system/opengauss.service + if [ -f $servicename ]; then + systemctl disable opengauss.service + rm $servicename + fi +} +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 [ "$1" = "0" ]; then + remove_service + clear_database +fi %files %defattr (-,root,root) @@ -251,9 +288,11 @@ fi %changelog +* Sat Jan 22 2022 zhangxubo - 2.1.0-3 +- Fix bugs: #I4RVNX + * Mon Dec 13 2021 zhangxubo - 2.1.0-2 - Fix bugs: Mask dependencies acquired during installation - * Wed Dec 1 2021 zhangxubo - 2.1.0-1 - Package init diff --git a/opengauss.service b/opengauss.service new file mode 100755 index 0000000..e9f1f42 --- /dev/null +++ b/opengauss.service @@ -0,0 +1,11 @@ +[Unit] +Description=Start openGauss server +After=local-fs.target + +[Service] +Type=idle +ExecStart=/usr/local/opengauss/script/autostart.sh +Delegate=yes + +[Install] +WantedBy=multi-user.target -- Gitee From 0eefe778103142b76e34b5c7b63aa46e2d3294fa Mon Sep 17 00:00:00 2001 From: zhang_xubo <2578876417@qq.com> Date: Thu, 27 Jan 2022 14:50:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?sysctmctl=E6=8B=89=E8=B5=B7=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=B8=80=E4=BC=9A=E8=BF=9B=E7=A8=8B=E5=B0=B1=E8=87=AA?= =?UTF-8?q?=E8=A1=8C=E5=85=B3=E9=97=AD=E3=80=82=E6=B7=BB=E5=8A=A0RemainAft?= =?UTF-8?q?erExit=3Dyes=E4=BF=9D=E6=8C=81=E8=BF=9B=E7=A8=8B=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opengauss.service | 1 + 1 file changed, 1 insertion(+) diff --git a/opengauss.service b/opengauss.service index e9f1f42..c2680b2 100755 --- a/opengauss.service +++ b/opengauss.service @@ -6,6 +6,7 @@ After=local-fs.target Type=idle ExecStart=/usr/local/opengauss/script/autostart.sh Delegate=yes +RemainAfterExit=yes [Install] WantedBy=multi-user.target -- Gitee