From e8ba276098b589344748f503191aea3d57511d53 Mon Sep 17 00:00:00 2001 From: dl239 Date: Mon, 13 Mar 2023 17:55:49 +0800 Subject: [PATCH 1/6] feat: add init_env script --- release/sbin/init_env.sh | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 release/sbin/init_env.sh diff --git a/release/sbin/init_env.sh b/release/sbin/init_env.sh new file mode 100755 index 00000000000..487e75d06fd --- /dev/null +++ b/release/sbin/init_env.sh @@ -0,0 +1,47 @@ +#! /usr/bin/env bash +# shellcheck disable=SC1091 + +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +user=`whoami` +if [[ ${user} != "root" ]]; then + echo "please switch to 'root' user to run this script" + exit +fi + +home="$(cd "$(dirname "$0")"/.. || exit 1; pwd)" +sbin="$(cd "$(dirname "$0")" || exit 1; pwd)" +. "$home"/conf/openmldb-env.sh +. "$sbin"/init.sh +cd "$home" || exit 1 + +old_IFS="$IFS" +IFS=$'\n' +for host in $(parse_host conf/hosts tablet | awk -F ' ' '{print $1}' | xargs -n 1 | sort | uniq) +do + limit_conf_file="/etc/security/limits.conf" + run_auto "$host" "echo '* soft core unlimited' >> ${limit_conf_file}" + run_auto "$host" "echo '* hard core unlimited' >> ${limit_conf_file}" + run_auto "$host" "echo '* soft nofile 655360' >> ${limit_conf_file}" + run_auto "$host" "echo '* hard nofile 655360' >> ${limit_conf_file}" + + # disable swap + run_auto "$host" "swapoff -a" + + # disable THP (Transparent Huge Pages) + run_auto "$host" "echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled" + run_auto "$host" "echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag" +done +IFS="$old_IFS" From b9045496b7f9a52eb0adca7a72248e4f9b861356 Mon Sep 17 00:00:00 2001 From: dl239 Date: Mon, 13 Mar 2023 19:20:37 +0800 Subject: [PATCH 2/6] docs: add docs --- docs/en/deploy/install_deploy.md | 11 +++++++++++ docs/zh/deploy/install_deploy.md | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/docs/en/deploy/install_deploy.md b/docs/en/deploy/install_deploy.md index a09d7abcf2e..58ccdd2b089 100644 --- a/docs/en/deploy/install_deploy.md +++ b/docs/en/deploy/install_deploy.md @@ -72,6 +72,8 @@ $ cat /sys/kernel/mm/transparent_hugepage/defrag always madvise [never] ``` +Note: You can also use script to modify the above configurations, refer [here](#configure-node-environment-optional) + ### Time and zone settings The OpenMLDB data expiration deletion mechanism relies on the system clock. If the system clock is incorrect, the expired data will not be deleted or the data that has not expired will be deleted. @@ -231,6 +233,15 @@ default values are used, which are defined in `conf/openmldb-env.sh`. If multiple TaskManager instances are deployed in different machines,the `offline.data.prefix` should be configured to be globally accessabile by these machines (e.g., hdfs path). ``` +### Configure Node Environment (Optional) +``` +bash sbin/init_env.sh +``` +Note: +- The script needs to be executed by the `root` user. +- The script will modify the `limit`, disable the `swap` and `THP`. + + ### Deployment ```bash sbin/deploy-all.sh diff --git a/docs/zh/deploy/install_deploy.md b/docs/zh/deploy/install_deploy.md index f8e778d1e43..5d44d696b35 100644 --- a/docs/zh/deploy/install_deploy.md +++ b/docs/zh/deploy/install_deploy.md @@ -114,6 +114,8 @@ $ cat /sys/kernel/mm/transparent_hugepage/defrag always madvise [never] ``` +注:以上三项也可以通过脚本一键修改,参考[修改机器环境配置](#修改机器环境配置-可选) + ### 时间和时区设置 OpenMLDB 数据过期删除机制依赖于系统时钟, 如果系统时钟不正确会导致过期数据没有删掉或者删掉了没有过期的数据。 @@ -221,6 +223,14 @@ node3:2181:2888:3888 /tmp/openmldb/zk-1 如果在不同机器上部署多个 TaskManager,其 `offline.data.prefix` 配置的路径,这些机器必须可以访问,建议配置hdfs路径。 ``` +### 修改机器环境配置 (可选) +``` +bash sbin/init_env.sh +``` +说明: +- 需要用root用户执行此脚本。执行其他脚本不需要root +- 此脚本只修改limit配置,关闭swap和关闭THP + ### 部署 ```bash From af3da61726918ed62eb6c9c3c0a866157c6c682c Mon Sep 17 00:00:00 2001 From: dl239 Date: Mon, 13 Mar 2023 19:24:44 +0800 Subject: [PATCH 3/6] docs: update --- docs/en/deploy/install_deploy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/deploy/install_deploy.md b/docs/en/deploy/install_deploy.md index 58ccdd2b089..d0add5338a8 100644 --- a/docs/en/deploy/install_deploy.md +++ b/docs/en/deploy/install_deploy.md @@ -72,7 +72,7 @@ $ cat /sys/kernel/mm/transparent_hugepage/defrag always madvise [never] ``` -Note: You can also use script to modify the above configurations, refer [here](#configure-node-environment-optional) +Note: You can also use the script to modify the above configurations, refer [here](#configure-node-environment-optional) ### Time and zone settings From 3686f209f595eb6e3fbab5e076a898703c3b20ba Mon Sep 17 00:00:00 2001 From: dl239 Date: Mon, 13 Mar 2023 19:26:47 +0800 Subject: [PATCH 4/6] fix: fix style --- release/sbin/init_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/sbin/init_env.sh b/release/sbin/init_env.sh index 487e75d06fd..cb28f6d27ef 100755 --- a/release/sbin/init_env.sh +++ b/release/sbin/init_env.sh @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -user=`whoami` +user=$(whoami) if [[ ${user} != "root" ]]; then echo "please switch to 'root' user to run this script" exit From 709b139b1f61a08c4fdb8d9af506fed6bc0d8697 Mon Sep 17 00:00:00 2001 From: dl239 Date: Tue, 14 Mar 2023 15:07:48 +0800 Subject: [PATCH 5/6] feat: add deploy test --- .github/workflows/openmldb-tool.yml | 56 ++++++++++++++++++ test/test-tool/openmldb-deploy/gen_conf.sh | 66 ++++++++++++++++++++++ test/test-tool/openmldb-deploy/install.sh | 33 +++++++++++ 3 files changed, 155 insertions(+) create mode 100644 .github/workflows/openmldb-tool.yml create mode 100644 test/test-tool/openmldb-deploy/gen_conf.sh create mode 100644 test/test-tool/openmldb-deploy/install.sh diff --git a/.github/workflows/openmldb-tool.yml b/.github/workflows/openmldb-tool.yml new file mode 100644 index 00000000000..52b7418145a --- /dev/null +++ b/.github/workflows/openmldb-tool.yml @@ -0,0 +1,56 @@ +# OpenMLDB tool jobs +name: openmldb-tool + +on: + push: + branches: + - main + paths-ignore: + - 'docs/**' + - 'demo/**' + - 'docker/**' + - 'image/**' + - 'release/**' + - 'tools/**' + - '*.md' + tags: + - v* + pull_request: + paths-ignore: + - 'docs/**' + - 'demo/**' + - 'docker/**' + - 'image/**' + - 'release/**' + - 'tools/**' + - '*.md' + workflow_dispatch: + +env: + GIT_SUBMODULE_STRATEGY: recursive + NPROC: 2 # default Parallel build number for GitHub's Linux runner + EXAMPLES_ENABLE: OFF # turn off hybridse's example code + HYBRIDSE_TESTING_ENABLE: OFF # turn off hybridse's test code + +jobs: + deploy: + runs-on: self-hosted + steps: + - uses: actions/checkout@v2 + + - name: prepare env + run: | + VERSION="snapshot" + if [[ ${{ github.ref }} == "refs/tags/v"* ]]; then + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + VERSION=${VERSION#v} + fi + echo "OPENMLDB_VETSION=$VERSION" >> $GITHUB_ENV + - name: generate config + run: | + BASE_DIR=${{ vars.DEPLOY_DIR }} bash test/test-tool/openmldb-deploy/gen_conf.sh ${{ vars.NODE_LIST }} > hosts + - name: install openmldb + env: + OPENMLDB_VETSION: ${{ env.OPENMLDB_VETSION }} + run: | + bash test/test-tool/openmldb-deploy/install.sh ${{ env.OPENMLDB_VETSION }} diff --git a/test/test-tool/openmldb-deploy/gen_conf.sh b/test/test-tool/openmldb-deploy/gen_conf.sh new file mode 100644 index 00000000000..04f26130e5c --- /dev/null +++ b/test/test-tool/openmldb-deploy/gen_conf.sh @@ -0,0 +1,66 @@ +#! /usr/bin/env bash +# shellcheck disable=SC1091 + +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [[ $BASE_DIR == "" ]]; then + echo "please set 'BASE_DIR' when run script" + exit -1 +fi + +if [[ $# -lt 1 ]]; then + echo "at lease one node is required" + exit -1 +fi +echo "[tablet]" +for host in "$@"; do + echo $host:30221 $BASE_DIR/tablet +done + +num=0 +echo -e "\n[nameserver]" +for host in "$@"; do + echo $host:30321 $BASE_DIR/nameserver + let num=num+1 + if [[ $num -eq 2 ]]; then + break + fi +done + +echo -e "\n[apiserver]" +for host in "$@"; do + echo $host:39080 $BASE_DIR/apiserver + break +done + +num=0 +echo -e "\n[taskmanager]" +for host in "$@"; do + echo $host:39902 $BASE_DIR/taskmanager + let num=num+1 + if [[ $num -eq 2 ]]; then + break + fi +done + +num=0 +echo -e "\n[zookeeper]" +for host in "$@"; do + echo $host:32181:32888:33888 $BASE_DIR/zookeeper + let num=num+1 + if [[ $num -eq 3 ]]; then + break + fi +done diff --git a/test/test-tool/openmldb-deploy/install.sh b/test/test-tool/openmldb-deploy/install.sh new file mode 100644 index 00000000000..485866650e1 --- /dev/null +++ b/test/test-tool/openmldb-deploy/install.sh @@ -0,0 +1,33 @@ +#! /usr/bin/env bash +# shellcheck disable=SC1091 + +# Copyright 2021 4Paradigm +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eE -x +VERSION="$1" +if [[ -z ${VERSION} ]]; then + VERSION=0.6.3 +fi +echo "version: ${VERSION}" +curl -SLo openmldb.tar.gz "https://github.com/4paradigm/OpenMLDB/releases/download/v${VERSION}/openmldb-${VERSION}-linux.tar.gz" +mkdir -p "openmldb" +tar xzf openmldb.tar.gz -C "openmldb" --strip-components 1 +pushd "openmldb" + +mv ../hosts conf/hosts +sed -i"" -e "s/OPENMLDB_VERSION=[0-9]\.[0-9]\.[0-9]/OPENMLDB_VERSION=${VERSION}/g" conf/openmldb-env.sh +sed -i"" -e "s/OPENMLDB_MODE:=standalone/OPENMLDB_MODE:=cluster/g" conf/openmldb-env.sh +sh sbin/deploy-all.sh +sh sbin/start-all.sh From d4ffe17278370d03ead57375a44ed85795643c7e Mon Sep 17 00:00:00 2001 From: dl239 Date: Tue, 14 Mar 2023 15:14:18 +0800 Subject: [PATCH 6/6] fix: revert yml --- .github/workflows/openmldb-tool.yml | 56 ------------------ test/test-tool/openmldb-deploy/gen_conf.sh | 66 ---------------------- test/test-tool/openmldb-deploy/install.sh | 33 ----------- 3 files changed, 155 deletions(-) delete mode 100644 .github/workflows/openmldb-tool.yml delete mode 100644 test/test-tool/openmldb-deploy/gen_conf.sh delete mode 100644 test/test-tool/openmldb-deploy/install.sh diff --git a/.github/workflows/openmldb-tool.yml b/.github/workflows/openmldb-tool.yml deleted file mode 100644 index 52b7418145a..00000000000 --- a/.github/workflows/openmldb-tool.yml +++ /dev/null @@ -1,56 +0,0 @@ -# OpenMLDB tool jobs -name: openmldb-tool - -on: - push: - branches: - - main - paths-ignore: - - 'docs/**' - - 'demo/**' - - 'docker/**' - - 'image/**' - - 'release/**' - - 'tools/**' - - '*.md' - tags: - - v* - pull_request: - paths-ignore: - - 'docs/**' - - 'demo/**' - - 'docker/**' - - 'image/**' - - 'release/**' - - 'tools/**' - - '*.md' - workflow_dispatch: - -env: - GIT_SUBMODULE_STRATEGY: recursive - NPROC: 2 # default Parallel build number for GitHub's Linux runner - EXAMPLES_ENABLE: OFF # turn off hybridse's example code - HYBRIDSE_TESTING_ENABLE: OFF # turn off hybridse's test code - -jobs: - deploy: - runs-on: self-hosted - steps: - - uses: actions/checkout@v2 - - - name: prepare env - run: | - VERSION="snapshot" - if [[ ${{ github.ref }} == "refs/tags/v"* ]]; then - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - VERSION=${VERSION#v} - fi - echo "OPENMLDB_VETSION=$VERSION" >> $GITHUB_ENV - - name: generate config - run: | - BASE_DIR=${{ vars.DEPLOY_DIR }} bash test/test-tool/openmldb-deploy/gen_conf.sh ${{ vars.NODE_LIST }} > hosts - - name: install openmldb - env: - OPENMLDB_VETSION: ${{ env.OPENMLDB_VETSION }} - run: | - bash test/test-tool/openmldb-deploy/install.sh ${{ env.OPENMLDB_VETSION }} diff --git a/test/test-tool/openmldb-deploy/gen_conf.sh b/test/test-tool/openmldb-deploy/gen_conf.sh deleted file mode 100644 index 04f26130e5c..00000000000 --- a/test/test-tool/openmldb-deploy/gen_conf.sh +++ /dev/null @@ -1,66 +0,0 @@ -#! /usr/bin/env bash -# shellcheck disable=SC1091 - -# Copyright 2021 4Paradigm -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if [[ $BASE_DIR == "" ]]; then - echo "please set 'BASE_DIR' when run script" - exit -1 -fi - -if [[ $# -lt 1 ]]; then - echo "at lease one node is required" - exit -1 -fi -echo "[tablet]" -for host in "$@"; do - echo $host:30221 $BASE_DIR/tablet -done - -num=0 -echo -e "\n[nameserver]" -for host in "$@"; do - echo $host:30321 $BASE_DIR/nameserver - let num=num+1 - if [[ $num -eq 2 ]]; then - break - fi -done - -echo -e "\n[apiserver]" -for host in "$@"; do - echo $host:39080 $BASE_DIR/apiserver - break -done - -num=0 -echo -e "\n[taskmanager]" -for host in "$@"; do - echo $host:39902 $BASE_DIR/taskmanager - let num=num+1 - if [[ $num -eq 2 ]]; then - break - fi -done - -num=0 -echo -e "\n[zookeeper]" -for host in "$@"; do - echo $host:32181:32888:33888 $BASE_DIR/zookeeper - let num=num+1 - if [[ $num -eq 3 ]]; then - break - fi -done diff --git a/test/test-tool/openmldb-deploy/install.sh b/test/test-tool/openmldb-deploy/install.sh deleted file mode 100644 index 485866650e1..00000000000 --- a/test/test-tool/openmldb-deploy/install.sh +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env bash -# shellcheck disable=SC1091 - -# Copyright 2021 4Paradigm -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eE -x -VERSION="$1" -if [[ -z ${VERSION} ]]; then - VERSION=0.6.3 -fi -echo "version: ${VERSION}" -curl -SLo openmldb.tar.gz "https://github.com/4paradigm/OpenMLDB/releases/download/v${VERSION}/openmldb-${VERSION}-linux.tar.gz" -mkdir -p "openmldb" -tar xzf openmldb.tar.gz -C "openmldb" --strip-components 1 -pushd "openmldb" - -mv ../hosts conf/hosts -sed -i"" -e "s/OPENMLDB_VERSION=[0-9]\.[0-9]\.[0-9]/OPENMLDB_VERSION=${VERSION}/g" conf/openmldb-env.sh -sed -i"" -e "s/OPENMLDB_MODE:=standalone/OPENMLDB_MODE:=cluster/g" conf/openmldb-env.sh -sh sbin/deploy-all.sh -sh sbin/start-all.sh