alpine 编译安装postgresql16.4

解压缩postgresql16.4的源码压缩文件
创建 postgres用户及组
用addgroup 和adduser
addgroup -g 1001 postgres
adduser -G postgres postgres
拷贝至
mv postgresql-16.4/* /home/postgres/postgresql16.4/
变更目录所有
chown -R postgres:postgres   /home/postgres/postgresql16.4
默认编译至
/usr/local/pgsql 目录
创建此目录
mkdir -p /usr/local/pgsql
变换用户
chown -R postgres:postgres /usr/local/pgsql
切换用户
su - postgres
进入目录
./configure
提示
configure: error: ICU library not found
If you have ICU already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-icu to disable ICU support.
安装icu包
apk add icu-dev
再次配置
提示
configure: error: readline library not found
安装readline对应包
apk add readline-dev
提示
configure: error: zlib library not found
安装
apk add zlib-dev
再次
./configure
编译
make all 
安装
make install
安装完成。
编辑环境变量
编写
vim pg164.sh
填入一下内容,注意alpine需要path加入 /bin目录,否则会导致ls不能用。

export PGPORT=5432

export PGDATA=/home/postgres/data

export LANG=en_US.utf8

export PGHOME=/usr/local/pgsql

export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH

export PATH=$PGHOME/bin:/usr/bin:/usr/local/sbin:/bin:

export MANPATH=$PGHOME/share/man:/share/man:

应用环境更改
source pg164.sh
初始化数据库

initdb -D $PGDATA --encoding=UTF8 --locale=en_US.UTF8 -U postgres

 提示警告,没关系。

 no usable system locales were found

更改hba.conf  和postgresql.conf 配置连接即可。
pg_ctl start
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值