一、安装前准备工作
下载二进制包
wget https://get.enterprisedb.com/postgresql/postgresql-10.1-1-linux-x64-binaries.tar.gz
解压到部署目录
tar zxvf postgresql-10.1-1-linux-x64-binaries.tar.gz -C /usr/local/
groupadd postgres
useradd -g postgres postgres
mkdir -p /data/pgsql/{data,log}
chown -R postgres.postgres /data/pgsql
二、进行数据库初始化
切换用户 postgres,并执行初始化操作
su - postgres
cd /usr/local/pgsql/bin
./initdb -E utf8 -D /data/pgsql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /data/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
./pg_ctl -D /data/pgsql/data -l logfile start
初始化完成
三、安装后
配置环境变量,~/.bash_profile 添加如下内容
PATH=/usr/local/pgsql/bin:$PATH
export PATH
启动数据库
./pg_ctl -D /data/pgsql/data -l /data/pgsql/log/postgres.log start
或
./postgres -D /opt/pgsql/data/ > /opt/pgsql/log/postgres.log &
登陆数据库
psql