openGauss Datakit安裝部署

我愛睡蓮發表於2023-04-12

一、問題描述:目前找不到任何關於opengauuss Datakit安裝部署的文件,自己來嘗試踩坑。

DataKit是一個以資源(物理機,資料庫)為底座的開發運維工具,將上層的開發運維工具外掛化,各外掛之間相互獨立,方便使用者按需引入。各外掛圍繞DataKit的資源中心進行擴充套件開,完成資料庫的運維,監控,遷移,開發,建模等複雜的操作。

Datakit安裝部署在伺服器上,是一個自動化運維的平臺。可以部署不同型別的外掛來實現不同的功能,是跟隨opengauss5.0釋出的新軟體,也可以用來監控小於5.0的opengauss版本

 

二、環境準備:

Datakit官方文件:https://docs.opengauss.org/zh/docs/5.0.0/docs/ToolandCommandReference/DataKit.html

DataKit使用文件和開發文件:https://gitee.com/opengauss/openGauss-workbench/tree/master/openGauss-visualtool/doc

openGauss-workbench下載連結:https://gitee.com/opengauss/openGauss-workbench.git

Datakit下載連結:https://opengauss.org/zh/download/

JDK下載連結:https://www.oracle.com/in/java/technologies/javase/jdk11-archive-downloads.html#license-lightbox

 

linux作業系統的jdk版本要與datakit打的jar包jdk版本保持一致,要不然透過不了

 

 

 

 

三、安裝部署

部署環境:redhat7,opengauss3.0.3,Datakit5.0

1.上傳壓縮包

# 此時如果沒有/ops/server/openGauss-visualtool目錄,可以臨時手動建立,也可以把這一步在初始化環境中進行解壓
[root@test01 tmp]# tar -xvf Datakit-5.0.0.tar.gz -C /ops/server/openGauss-visualtool

jdk手動安裝
workbench-master有啟動和初始化的指令碼可以拿來用
datakit除了visualtool-main.jar 放在/ops/server/openGauss-visualtool目錄中,其餘幾個打包好的外掛需要放在/ops/server/openGauss-visualtool/visualtool-plugin/ 目錄中

 

2.更新jdk版本,如果需要

# 檢查
rpm -qa | grep java rpm -qa | grep jdk
# 解除安裝 rpm
-qa | grep java | xargs rpm -e --nodeps rpm -qa | grep jdk | xargs rpm -e --nodeps
# 安裝
rpm -ivh jdk-11.0.17_linux-x64_bin.rpm
# 驗證
[root@test01 tmp]# java -version
java version "11.0.17" 2022-10-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.17+10-LTS-269)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.17+10-LTS-269, mixed mode)

 

3.建立遠端使用者

# 建立使用者
openGauss=# CREATE USER jack WITH MONADMIN password "xxxxxxxx"; openGauss=# alter user jack sysadmin;
# 寫入pg_hba.conf檔案
[omm@test01 ~]$ gs_guc set -N all -I all -h "host all jack 192.168.1.0/24 sha256"

 

4.編輯安裝和啟動指令碼

安裝指令碼在\openGauss-workbench-master\openGauss-workbench-master\openGauss-visualtool中

 

 

 使用安裝指令碼初始化環境,或者使用https://docs.opengauss.org/zh/docs/5.0.0/docs/ToolandCommandReference/DataKit.html文件中初始化環境,安裝指令碼需要修改一下。如果指令碼執行不順暢,也可以手動跑指令碼中的內容,保障目錄正常,以及加密檔案生成

# 建立ops使用者
useradd -m ops
vim install.sh
#!/usr/bin/env bash echo "begin install..." #sh ./uninstall.sh read -p "Do you want to automatically install dependencies (JDK, maven, node) ? (Press y|Y for Yes, any other key for No). " install_depency if [ "$install_depency" = "Y" -o "$install_depency" = "y" ]; then #sh ./install-depency.sh else echo "Please install the dependencies required by the system by yourself, including openjdk (11), maven (3), and node (16.15.1)." exit 1 fi read -p "Please enter the host of openGauss, Please ensure that the current host IP is in the whitelist of openGauss: " host if [ ! -n "$host" ]; then echo "Host cannot be empty." exit 1 fi read -p "Please enter the port of openGauss.: " port if [ ! -n "$port" ]; then echo "Port cannot be empty." exit 1 fi read -p "Please enter the database of openGauss.: " database if [ ! -n "$database" ]; then echo "Database cannot be empty." exit 1 fi read -p "Please enter the username of openGauss.: " username if [ ! -n "$username" ]; then echo "Username cannot be empty." exit 1 fi stty -echo read -p "Please enter the password of openGauss.: " password if [ ! -n "$password" ]; then echo "Password cannot be empty." exit 1 fi stty echo echo "host: $host, port: $port username: $username database: $database" cp config/application-temp.yml config/application-cus.yml sed -i "23s/ip:port/$host:$port/" config/application-cus.yml sed -i "23s/database/$database/" config/application-cus.yml sed -i "24s/dbuser/$username/" config/application-cus.yml sed -i "25s/dbpassword/$password/" config/application-cus.yml #mvn clean install -P prod -Dmaven.test.skip=true mkdir -p /ops/server/openGauss-visualtool/ mkdir -p /ops/files/ mkdir -p /ops/server/openGauss-visualtool/logs/ mkdir -p /ops/server/openGauss-visualtool/config/ mkdir -p /ops/ssl/ if [ ! -f "/ops/ssl/keystore.p12" ];then keytool -genkey -noprompt \ -dname "CN=opengauss, OU=opengauss, O=opengauss, L=Beijing, S=Beijing, C=CN"\ -alias opengauss\ -storetype PKCS12 \ -keyalg RSA \ -keysize 2048 \ -keystore /ops/ssl/keystore.p12 \ -validity 3650 \ -storepass 123456 fi echo "SSL is enabled, you can replace the keystore file at /ops/ssl/ folder and config the ssl options at file /ops/server/openGauss-visualtool/config/application-cus.yml" touch /ops/server/openGauss-visualtool/logs/visualtool-main.out cp visualtool-api/target/visualtool-main.jar /ops/server/openGauss-visualtool/ mv config/application-cus.yml /ops/server/openGauss-visualtool/config/ chown -R ops:ops /ops echo "end install"

 

編輯啟動指令碼

#!/usr/bin/env bash

SERVER_HOME=/ops/server/openGauss-visualtool
cd $SERVER_HOME
API_NAME=visualtool-main
JAR_NAME=$SERVER_HOME/$API_NAME\.jar
LOG=$SERVER_HOME/logs/$API_NAME\.out
PID=$SERVER_HOME/$API_NAME\.pid

usage() {
    echo "Usage: sh server.sh [start|stop|restart|status]"
    exit 1
}

is_exist(){
  pid=`ps -ef|grep $JAR_NAME|grep -v grep|awk '{print $2}' `
  if [ -z "${pid}" ]; then
   return 1
  else
    return 0
  fi
}

start(){
  is_exist
  if [ $? -eq "0" ]; then
    echo ">>> ${JAR_NAME} is already running PID=${pid} <<<"
  else
    echo '' > $LOG
    nohup java -Xms2048m -Xmx4096m -jar $JAR_NAME --spring.profiles.active=cus >$LOG 2>&1 &
    echo $! > $PID
    echo ">>> start $JAR_NAME successed PID=$! <<<"
   fi
  }

stop(){
  pidf=$(cat $PID)
  echo ">>> ${API_NAME} PID = $pidf begin kill $pidf <<<"
  kill $pidf
  rm -rf $PID
  sleep 2
  is_exist
  if [ $? -eq "0" ]; then
    echo ">>> ${API_NAME} 2 PID = $pid begin kill -9 $pid  <<<"
    kill -9  $pid
    sleep 2
    echo ">>> $JAR_NAME process stopped <<<"
  else
    echo ">>> ${JAR_NAME} is not running <<<"
  fi
}

status(){
  is_exist
  if [ $? -eq "0" ]; then
    echo ">>> ${JAR_NAME} is running PID is ${pid} <<<"
  else
    echo ">>> ${JAR_NAME} is not running <<<"
  fi
}

restart(){
  stop
  start
}

case "$1" in
  "start")
    start
    ;;
  "stop")
    stop
    ;;
  "status")
    status
    ;;
  "restart")
    restart
    ;;
  *)
    usage
    ;;
esac
exit 0
}

5.初始化環境

[root@test01 openGauss-visualtool]# mv application-temp.yml ./config/
[root@test01 openGauss-visualtool]# ./install.sh
begin install...
sh: ./uninstall.sh: No such file or directory
Do you want to automatically install dependencies (JDK, maven, node) ? (Press y|Y for Yes, any other key for No). Y
sh: ./install-depency.sh: No such file or directory
Please enter the host of openGauss, Please ensure that the current host IP is in the whitelist of openGauss: 10.83.239.211
Please enter the port of openGauss.: 26000
Please enter the database of openGauss.: postgres
Please enter the username of openGauss.: jack
Please enter the password of openGauss.: host: 192.168.163.21, port: 26000  username: jack database: postgres
SSL is enabled, you can replace the keystore file at /ops/ssl/ folder and config the ssl options at file /ops/server/openGauss-visualtool/config/application-cus.yml
cp: cannot stat ‘visualtool-api/target/visualtool-main.jar’: No such file or directory
mv: ‘config/application-cus.yml’ and ‘/ops/server/openGauss-visualtool/config/application-cus.yml’ are the same file
end install

 

[root@hktestmysqldb01 openGauss-visualtool]# ll config/
total 8
-rw------- 1 ops ops 873 Apr 11 16:42 application-cus.yml
-rw-r--r-- 1 ops ops 865 Mar 28 20:47 application-temp.yml
[root@hktestmysqldb01 openGauss-visualtool]# pwd
/ops/server/openGauss-visualtool

 

6. 啟動服務

# 把模板移動到外掛目錄下。也可以後期啟動好平臺後手動補入外掛
[ops@test01 openGauss-visualtool]$ mkdir -p /ops/server/openGauss-visualtool/visualtool-plugin
[ops@test01 openGauss-visualtool]$ mv base-ops-5.0.0-repackage.jar ./visualtool-plugin/
[ops@test01 openGauss-visualtool]$ mv data-migration-5.0.0-repackage.jar ./visualtool-plugin/
[ops@test01 openGauss-visualtool]$ mv observability-instance-5.0.0-repackage.jar ./visualtool-plugin/
[ops@test01 openGauss-visualtool]$ mv observability-log-search-5.0.0-repackage.jar ./visualtool-plugin/
[ops@test01 openGauss-visualtool]$ mv observability-sql-diagnosis-5.0.0-repackage.jar ./visualtool-plugin/
[ops@test01 openGauss-visualtool]$ mv webds-plugin-5.0.0-repackage.jar ./visualtool-plugin/

# ./server.sh start/stop/restart
[ops@test01 openGauss-visualtool]$ ./server.sh restart
>>> visualtool-main PID = 45148 begin kill 45148 <<<

>>> /ops/server/openGauss-visualtool/visualtool-main.jar is not running <<<
>>> start /ops/server/openGauss-visualtool/visualtool-main.jar successed PID=46530 <<<

 

7.檢查是否啟動成功

/ops/server/openGauss-visualtool/logs/visualtool-main.out 會記錄實時日誌

[root@test01 ~]# netstat -ntpl | grep 9494
tcp        0      0 0.0.0.0:9494            0.0.0.0:*               LISTEN      46530/java

前臺訪問連結:https://192.168.163.21:9494/

外掛管理,如果沒有做第6部在伺服器上移動外掛,也可以在前臺手動匯入一次

 

相關文章