centos7下安装highgodb及集成到springboot项目中

一、centos7中安装highgodb

1、安装包下载地址:https://www.highgo.com/down_enterprise.html

2、在centos7中解压安装包

# rpm -ivh 1b73693f2c91fd7f38acbc7d3882cf6c.rpm

3、以上安装成功后,系统会自动完成以下操作

(1)自动创建 highgo 用户,该用户默认没有密码。安装文件的属主均为 highgo 。

(2)自动创建默认路径,并生成环境配置文件(包括默认服务端口号5866):

默认路径:/opt/HighGo6.0.4-cluster

环境配置文件:/opt/HighGo6.0.4-cluster/etc/highgodb.env,其内容如下:

export HG_BASE=/opt/HighGo6.0.4-cluster
export HGDB_HOME=/opt/HighGo6.0.4-cluster
export PGPORT=5866
export PGDATABASE=highgo
export PGDATA=$HGDB_HOME/data
export PATH=$HGDB_HOME/bin:$PATH

(3)生成service文件:/usr/lib/systemd/system/hgdb-enterprise-6.0.4.service

4、设置highgo用户密码

echo highgo|passwd --stdin highgo
id highgo

5、设置highgo用户环境变量

# su - highgo
$ cat /opt/HighGo6.0.4-cluster/etc/highgodb.env >> ~/.bash_profile
$ source ~/.bash_profile

6、检查环境变量是否生效

$ echo $PGDATA
/opt/HighGo6.0.4-cluster/data

7、 初始化数据库
使用 highgo 用户执行 initdb 操作。

$ which initdb
/opt/HighGo6.0.4-cluster/bin/initdb

$ initdb -D ${PGDATA} > ./initdb.log

Enter new superuser password:

Enter it again:

initdb: warning: enabling "md5" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

说明:在上面执行初始化数据库命令时,会要求设置数据库超级用户(管理员 highgo)的密码,提示输密码、二次确认密码。注意:瀚高DB用户密码设置时,不支持"."符号

检查以上初始化数据库命令执行是否成功:

$ cat initdb.log
The files belonging to this database system will be owned by user "highgo".

This user must also own the server process.

 

The database cluster will be initialized with locale "en_US.UTF-8".

The default database encoding has accordingly been set to "UTF8".

The default text search configuration will be set to "english".

 

Data page checksums are disabled.

Data encryption is disabled.

  

creating directory /opt/HighGo6.0.4-cluster/data ... ok

creating subdirectories ... ok

selecting dynamic shared memory implementation ... posix

selecting default max_connections ... 100

selecting default shared_buffers ... 128MB

selecting default time zone ... Asia/Shanghai

creating configuration files ... ok

running bootstrap script ... ok

performing post-bootstrap initialization ... ok

syncing data to disk ... ok

  

Success. You can now start the database server using:

     pg_ctl -D /opt/HighGo6.0.4-cluster/data -l logfile start

8、登录测试

(1)切换到 highgo 用户

su - highgo

(2)查看HighGoDB是否启动:

$ pg_ctl status
pg_ctl: no server running

(3)启动HighGoDB:

$ pg_ctl start
waiting for server to start....2022-07-09 22:25:54.583 CST [2754] LOG: starting HighGo Database 6 Release 6.0.4-64-bit Production
2022-07-09 22:25:54.584 CST [2754] LOG: listening on IPv6 address "::1", port 5866
2022-07-09 22:25:54.584 CST [2754] LOG: listening on IPv4 address "127.0.0.1", port 5866
2022-07-09 22:25:54.585 CST [2754] LOG: listening on Unix socket "/tmp/.s.PGSQL.5866"
2022-07-09 22:25:54.595 CST [2754] LOG: This is a trial edition, validate until 2023-07-09 22:14:37.
2022-07-09 22:25:54.603 CST [2755] LOG: database system was shut down at 2022-07-09 22:14:37 CST
2022-07-09 22:25:54.607 CST [2754] LOG: database system is ready to accept connections
done
server started
$ pg_ctl status
pg_ctl: server is running (PID: 2754)
/opt/HighGo6.0.4-cluster/bin/postgres

(4)查看相关服务进程:

$ ps -axf |grep postgres

(5)查看相关监听:

# netstat -anp |grep 5866

9、配置允许远程访问

(1)切换到highgo用户环境:

su - highgo

(2)设置允许远程访问策略:

$ vi ${PGDATA}/pg_hba.conf

在这里插入图片描述

(3)修改监听地址(默认仅监听服务器本地地址localhost)

$ vi ${PGDATA}/postgresql.conf
将此行改为:listen_addresses = '*'

(4)重启数据库服务生效:

$ pg_ctl restart

10、登录数据库

(1)通过系统自动带的psql客户端工具登录:

$ psql -U highgo -d highgo

(2)通过图形化客户端工具登录

在这里插入图片描述
参考文档:http://www.postgres.cn/docs/12/index.html
https://www.modb.pro/db/431519

二、highgodb集成到springboot中

1、引入依赖

<!--highgo jdbc-->
        <dependency>
            <groupId>com.highgo</groupId>
            <artifactId>HgdbJdbc</artifactId>
            <version>6.2.2</version>
        </dependency>

2、yml文件配置

spring:
  datasource:
    driver-class-name: com.highgo.jdbc.Driver
    url: jdbc:highgo://xx.xx.xx.xx:5866/highgo?currentSchema=schemaname
    username: highgo
    password: xxxxxx

注:currentSchema表示指定的模式下的表数据

3、最后使用mybatis常规写法即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值