操作系统:CentOS7
Postgresql版本:10.10
端口:5432
备注:下文的安装步骤中,【】包围的部分需根据自己的环境来配置
1 源码方式安装
将安装包拷贝到服务器目录,并通过cd命令进入该目录,然后执行以下命令
tar -zxvf postgresql-10.10.tar.gz
cd postgresql-10.10
./configure
make
make install
2 创建用户、数据目录、日志归档目录并授权
adduser postgres
mkdir -p /home/pg/data
mkdir -p /var/log/pg
chown -R postgres /home/pg/
chown -R postgres /var/log/pg
mkdir /home/pg/data/archivedir
chown -R postgres /home/pg/data/archivedir
3 初始化数据库
su postgres
/usr/local/pgsql/bin/initdb -D /home/pg/data
4 启动
/usr/local/pgsql/bin/pg_ctl start -l logfile -D /home/pg/data
5 配置环境变量
打开配置文件
vi ~/.bash_profile
编辑
export PGHOME=/usr/local/pgsql
export PGUSER=postgres
export PGPORT=5432
export PGDATA=/home/pg/data
export PATH=$PGHOME/bin:$PATH:$HOME/bin
export LD_LIBRARY_PATH=$PGHOME/lib: