CentOS7.9 部署PostgreSQL
前言
本文主要介绍一下, CentOS部署 PostgreSQL
1.1 安装包下载
通过官网下载源码安装包
本文选择 postgresql-14.11.tar.gz 进行测试
1.2 安装依赖
新系统是最小化安装,所有存了安装一些必要的依赖,同时安装了一些小工具。
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost ~]# rm -rf *
[root@localhost ~]# curl http://mirrors.aliyun.com/repo/Centos-7.repo > /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]# yum install -y cmake make gcc zlib gcc-c++ perl readline readline-devel
[root@localhost ~]# yum install -y zlib libicu
[root@localhost ~]# yum install -y zlib-devel perl python36 tcl openssl ncurses-devel openldap pam openssl-devel
[root@localhost ~]# yum -y install lrzsz
[root@localhost ~]# yum -y install vim ntp net-tools
1.3 同步时间
[root@localhost ~]# ntpdate ntp.aliyun.com
1.4 创建用户
创建用户
groupadd -g 60000 postgres
useradd -u 60000 -g postgres postgres
echo "postgres" | passwd --stdin postgres
1.5 创建用户组
mkdir -p /dbs/pg14/data
mkdir -p /pg14/soft
chown -R postgres:postgres /dbs
chown -R postgres:postgres /pg14
chmod -R 775 /pg14
chmod -R 775 /dbs
1.6 编译安装
su - postgres
cp /tmp/postgresql-14.11.tar.gz /pg14/soft
cd /pg14/soft
tar -zxvf postgresql-14.11.tar.gz
cd postgresql-14.11
./configure --prefix=/pg14/soft --with-openssl
make && make install
1.7 添加环境变量
cat >> ~/.bash_profile <<"EOF"
export PGPORT=5666
export PGDATA=/dbs/pg14/data
export PGHOME=/pg14/soft
export PATH=$PGHOME/bin:$PATH:.
EOF
source ~/.bash_profile
总结
目前PostgreSQL 已完成初步安装。
后续使用,需要先初始化,并启动psql服务。
并按需配置。