前言
研究datakit安装方法是学校老师给的任务 ,本文是本人亲自安装成功 之后的记录。参考了诸多博客。安装成功于2024年2月21日。
花了一个假期研究,装了不下十遍(是我太菜了)。研究好了之后也没有后续任务了(是我太菜了)。故把这篇安装方法文档发到网上,有需要的话尽管拿去。
文章目录
-
- 环境说明
- 操作步骤
-
- 挂载共享文件夹
- 安装JDK11并且将java版本从8转为11
- 下载Datakit的jar包
- 创建工作目录,并把Datakit解压
- 对openGauss进行一些设置
- 修改配置文件application-temp.yml
- 编辑安装脚本和启动脚本
-
- [★ 特别注意:Shell 脚本参数传递时有 \r 换行符问题](#★ 特别注意:Shell 脚本参数传递时有 \r 换行符问题)
- 使用install.sh来安装
- 把解压得到的插件放到正确的目录中
- 使用server.sh来启动
- 检查是否成功
- 卸载
DataKit是基于Web的openGauss的可视化的一体化工具,提供了一个可视化操作的运维界面。
环境说明
X86+openEuler 22.03+JDK11
操作步骤
挂载共享文件夹
(在安装opengauss时,你可能已经设置了共享文件夹。)
在windows系统中找一个目录当作共享文件夹,例如E:\shareOpenEuler
。
在Oracle VM VirtualBox中,菜单栏设置------共享文件夹------添加共享文件夹
。
还是在Oracle VM VirtualBox中,菜单栏设置------存储------添加虚拟光盘
。添加VBoxGuestAdditions.iso
启动虚拟机,安装一些依赖
yum install gcc-c++ libstdc++-devel
创建VBoxGuestAdditions.iso的挂载文件目录
mkdir /mnt/cdrom
如下图,建立共享文件夹目录挂载点、挂载增强功能包到指定路径、运行VBoxLinuxAdditions.run进行安装。
安装好增强功能包后,就可以使用vboxsf命令进行挂载共享文件夹了。
mount -t vboxsf shareOpenEuler /mnt/shareOpenEuler
小结
我的windows的共享文件夹路径:E:\shareOpenEuler
Linux挂载点:/mnt/shareOpenEuler
如果之前已经有的共享文件夹路径不同,后续步骤中的命令做相应替换即可。
安装JDK11并且将java版本从8转为11
yum install -y java-11-openjdk
java -version
alternatives --config java
java -version
下载Datakit的jar包
jar包下载地址:https://www.opengauss.org/zh/download/,选择x86-64,Linux
下载好放到共享文件夹里。
创建工作目录,并把Datakit解压
创建工作目录:
bash
mkdir -p /ops/server/openGauss-visualtool/logs /ops/server/openGauss-visualtool/config /ops/ssl /ops/files
将刚刚下载的Datakit 5.0.0 jar包放到共享文件夹(E:\shareOpenEuler)内并传至/ops/server/openGauss-visualtool/下:
cd /mnt/shareOpenEuler
cp Datakit-5.0.0.tar.gz /ops/server/openGauss-visualtool/
解压Datakit-5.0.0.tar.gz
tar -xzvf Datakit-5.0.0.tar.gz
对openGauss进行一些设置
查看openGauss的启动状态
首先切换用户,从root用户切换到opengauss用户(我的openGauss数据库的用户叫opengauss
)。gs_ctl status
是openGauss服务管理常用命令,代表查看状态。
su - opengauss
gs_ctl status
如下图,启动状态为:sever is running 代表正常
设置访问数据库的白名单,这里设置为:允许任何IP地址的客户端通过TCP/IP访问到openGauss数据库
cd $PGDATA
echo 'host all all 0.0.0.0/0 md5' >> pg_hba.conf
修改数据库参数
sed -i "s/^listen_addresses = .*/listen_addresses = '*'/" postgresql.conf
sed -i "s/^#password_encryption_type = .*/password_encryption_type = 0/" postgresql.conf
sed -i "s/^max_connections = .*/max_connections = 1000/" postgresql.conf
grep -E 'listen_addresses|password_encryption_type|max_connections' postgresql.conf
重启openGauss服务并查看启动状态
gs_ctl restart > /dev/null 2>&1
gs_ctl status
创建用户
# 登录数据库
gsql -d postgres -p 7654 -r
# 创建用户haha并授权,这里的'opengauss1!'是安装openGauss时我设的的密码
openGauss=# CREATE USER haha IDENTIFIED BY 'opengauss1!';
openGauss=# ALTER USER haha SYSADMIN;
# 创建数据库hahadb
openGauss=# create database hahadb;
修改配置文件application-temp.yml
将以下配置文件application-temp.yml传至/ops/server/openGauss-visualtool/config/下。配置文件内容如下:
yml
system:
# File storage path
defaultStoragePath: /ops/files
# Whitelist control switch
whitelist:
enabled: false
server:
port: 9494
ssl:
key-store: /ops/ssl/keystore.p12
key-store-password: password
key-store-type: PKCS12
enabled: true
servlet:
context-path: /
logging:
file:
path: /ops/server/openGauss-visualtool/logs/
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.opengauss.Driver
url: jdbc:opengauss://此处是ip:此处是port/此处是database?currentSchema=public
username: 此处是dbuser
password: 此处是dbpassword
druid:
test-while-idle: false
test-on-borrow: true
validation-query: "select 1"
validation-query-timeout: 30000
需要根据实际情况修改上面这些内容中的的ip、port、database、dbuser、dbpassword。
我的信息是:
ip:192.168.56.110
port:7654
database:hahadb
dbuser:haha
dbpassword:opengauss1!
key-store-password设置为123456
所以新建一个记事本,在里面写入如下内容,文件名为application-temp.yml,放入共享文件夹。通过共享文件夹,存放到服务器的/ops/server/openGauss-visualtool/config/。
yml
system:
# File storage path
defaultStoragePath: /ops/files
# Whitelist control switch
whitelist:
enabled: false
server:
port: 9494
ssl:
key-store: /ops/ssl/keystore.p12
key-store-password: 123456
key-store-type: PKCS12
enabled: true
servlet:
context-path: /
logging:
file:
path: /ops/server/openGauss-visualtool/logs/
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: org.opengauss.Driver
url: jdbc:opengauss://192.168.56.110:7654/hahadb?currentSchema=public
username: haha
password: opengauss1!
druid:
test-while-idle: false
test-on-borrow: true
validation-query: "select 1"
validation-query-timeout: 30000
编辑安装脚本和启动脚本
安装脚本如下,文件名为install.sh:
注意其中的storepass
要和刚刚application-temp.yml中的key-store-password
相同,我刚刚设的是123456,所以这里我写-storepass 123456
#!/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
chown -R ops:ops /ops
echo "end install"
启动脚本如下,文件名为server.sh:
#!/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
}
还是通过共享文件夹,传到/ops/server/openGauss-visualtool/
★ 特别注意:Shell 脚本参数传递时有 \r 换行符问题
运行insert.sh和serve.sh时会因为 \r 报错,解决方法是:
cd /ops/server/openGauss-visualtool/
dos2unix install.sh
sed -i "s/\r//" install.sh
dos2unix server.sh
sed -i "s/\r//" server.sh
使用install.sh来安装
输入命令:
cd /ops/server/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:
输入你的ip,我的是192.168.56.110
Please enter the port of openGauss.:
输入端口号,我的是7654
Please enter the database of openGauss.:
输入数据库名,我是hahadb
Please enter the username of openGauss.:
输入用户,我是haha
Please enter the password of openGauss.:
输入密码,我是opengauss1!,显示安装完成
host: 192.168.56.110, port: 7654 username: haha database: hahadb
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
end install
把解压得到的插件放到正确的目录中
除了visualtool-main.jar 放在/ops/server/openGauss-visualtool目录中,其余几个打包好的插件需要放在/ops/server/openGauss-visualtool/visualtool-plugin/ 目录中。所以输入以下命令:
cd /ops/server/openGauss-visualtool/
mkdir -p /ops/server/openGauss-visualtool/visualtool-plugin
mv base-ops-5.0.0-repackage.jar ./visualtool-plugin/
mv data-migration-5.0.0-repackage.jar ./visualtool-plugin/
mv observability-instance-5.0.0-repackage.jar ./visualtool-plugin/
mv observability-log-search-5.0.0-repackage.jar ./visualtool-plugin/
mv observability-sql-diagnosis-5.0.0-repackage.jar ./visualtool-plugin/
mv webds-plugin-5.0.0-repackage.jar ./visualtool-plugin/
使用server.sh来启动
cd /ops/server/openGauss-visualtool/
./server.sh start
检查是否成功
关闭防火墙
关闭防火墙,以便在web中访问。
systemctl stop firewalld.service
systemctl disable firewalld.service
查看日志
启动后,输入以下命令,会显示实时日志。
tail -20f /ops/server/openGauss-visualtool/logs/visualtool-main.out
web访问
链接:https://192.168.56.110:9494/,在浏览器中输入即可。注意要等待启动成功后才可看到,所以要等几分钟。
第一次登录,用户名admin,密码admin123,登录后强制修改密码,完成后进入首页。
就算卸载重装,默认密码也不管用了,要用自己设的密码登录。
卸载
DataKit工具是Jar包启动的,删除对应的Jar包即可卸载该工具。