harbor配置外部postgresql数据库
以harborv2.3.0为例
一、安装postgersql13.3
下载地址: https://www.postgresql.org/ftp/source/
1、安装依赖
yum install -y readline-devel zlib-devel make openssl-devel gcc
2、源码安装
tar -xf postgresql-13.3.tar
cd postgresql-13.3
./configure --prefix=/usr/local/pgsql
make
make install
3、创建postgres用户
groupadd postgres
useradd -g postgres postgres
4、创建数据目录并授权
mkdir /usr/local/pgsql/data
chown postgres:postgres /usr/local/pgsql/data
5、切换到postgres用户
su - postgres
6、初始化
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
7、启动
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile start
二、配置postgres
1、进入数据库
su - postgres
/usr/local/pgsql/bin/psql
2、创建表结构
postgres=# create database registry;
postgres=# create database notaryserver;
postgres=# create database notarysigner;
3、开启远程访问
vim postgresql.conf #listen_addresses修改为*
listen_addresses = '*'
vim pg_hba.conf #在IPv4 local connections处添加如下一行
# IPv4 local connections:
host all all 0.0.0.0/0 trust
4、重启postgresql
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/logfile restart
三、修改harbor.yml
1、vim harbor.yml
external_database:
harbor:
host: 192.168.56.42
port: 5432
db_name: registry
username: postgres
password:
ssl_mode: disable
max_idle_conns: 50
max_open_conns: 100
notary_signer:
host: 192.168.56.42
port: 5432
db_name: notarysigner
username: postgres
password:
ssl_mode: disable
notary_server:
host: 192.168.56.42
port: 5432
db_name: notaryserver
username: postgres
password:
ssl_mode: disable
2、安装
./install.sh