(1) 创建数据库用户及 权限设置
mkdir /postgresql/log
mkdir /postgresql/app
mkdir /postgresql/soft
# mkdir /postgresql/archive
groupadd -g 80000 postgresql
useradd -u 80000 -g postgresql postgresql
echo "postgresql" |passwd --stdin postgresql
chown -R postgresql:postgresql /postgresql
chmod -R 775 /postgresql
(2) 编译安装
chmod -R 775 /postgresql
cd /postgresql/soft
tar -zxvf postgresql-15.3.tar.gz
cd postgresql-15.3
- # 编译
./configure --prefix=/postgresql/app/postgresql \
--with-icu \
--with-perl \
--with-python \
--with-tcl \
--with-tclconfig=/usr/lib64 \
--with-openssl \
--with-includes=/usr/include/openssl \
--with-readline \
--with-pam \
--with-gssapi \
--with-libraries=/usr/lib64 \
--enable-nls \
--enable-dtrace \
--with-uuid=e2fs \
--with-libxml \
--with-libxslt \
--with-ldap \
--with-selinux \
--with-systemd \
--with-system-tzdata=/usr/share/zoneinfo \
--with-lz4 \
--with-zstd
make -j 4 world
make install world
- # 检查
cd /postgresql/app/postgresql/bin/
ldd postgres
(4) 用户环境变量配置
su - postgresql
## vi ~/.bash_profile
cat >> ~/.bash_profile <<-OFFFFFFFFFFFFF
export TZ='Asia/Shanghai'
export LANG=en_US.UTF8
export PS1="[`whoami`@`hostname`:"'$PWD]$'
export PGPORT=5432
export PGDATA=/postgresql/data
export PGHOME=/postgresql/app/postgresql
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIB RARY_PATH
export PATH=$PGHOME/bin:$PATH:.
export DATE=`date +"%Y%m%d%H%M"`
export MANPATH=$PGHOME/share/man:$MANPATH
export PGHOST=$PGDATA
export PGUSER=postgres
export PGDATABASE=postgres
export PATH="$PGHOME/bin:$PATH";export PATH
OFFFFFFFFFFFFF
source ~/.bash_profile
(5) 初始化数据库
/postgresql/app/postgresql/bin/initdb -D /postgresql/data -E UTF8 --lc-collate=C --lc-ctype=en_US.utf8 -U postgres
(6) 编译遇到问题
1) error: Package requirements (liblz4) were not met
dnf -y install lz4-devel
2) error: could not find function 'gss_init_sec_context' required for GSSAPI
dnf -y install krb5-devel
3) error: library 'uuid' is required for E2FS UUID
dnf -y install libuuid
dnf -y install libuuid-devel