sudo groupadd postgres
sudo useradd -g postgres postgres
sudo passwd ygsoftpower
tar zxvf postgresql-9.6.3.tar.gz
cd postgresql-9.6.3
./configure --prefix=/usr/local/postgresql --without-readline
(根据文件安装文件路径 ./configure --prefix=/home/ec2-user/postgresql-9.6.3 --without-readline)
configure: error: no acceptable C compiler found in $PATH
yum -y install gcc
configure: error: zlib library not found
sudo yum -y install zlib-devel
make &&make install
cd contrib
make &&make install
先修改profile
vim /etc/profile
export PG_HOME = /usr/local/postgresql
export PATH = $PG_HOME/bin:$PATH
source /etc/profile
如果source无法执行,修改base_profile
export PATH=/usr/local/postgresql/bin:$PATH
mkdir -p /var/postgresql/data
chown ec2-user:ec2-user /var/postgresql/*
chown ec2-user:ec2-user /usr/local/postgresql/*
chmod -R 775 /var/postgresql/*
su ec2-user
initdb -D /var/postgresql/data
pg_ctl -D /var/postgresql/data -l /var/postgresql/logfile start
pg_ctl: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
sudo ln -s /home/ec2-user/postgresql-9.6.3/lib/libpq.so.5 /usr/lib/libpq.so.5
sudo ln -s /home/ec2-user/postgresql-9.6.3/lib/libpq.so.5 /usr/lib64/libpq.so.5
CREATE USER postgres SUPERUSER;
vi /var/postgresql/data/postgresql.conf
vi /var/postgresql/data/pg_hba.conf
host all all 0.0.0.0/0 trust
vi /var/postgresql/data/postgresql.conf
listen_addresses = ‘*'
supostgres
pg_ctl -D /var/postgresql/data -l /var/postgresql/logfile restart
pg_ctl -D /var/postgresql/data -l /var/postgresql/logfile stop
pg_ctl start
pg_ctl status -D /var/postgresql/data