CentOS 6.9 (64bit)
1. Firewall 5432 port をopen
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
/etc/init.d/iptables restart
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
/etc/init.d/iptables restart
2.
yum -y install gcc
yum -y install readline
yum -y install readline-devel
yum -y install zlib
yum -y install zlib-devel
yum -y install readline
yum -y install readline-devel
yum -y install zlib
yum -y install zlib-devel
3.
useradd postgres
passwd postgres
passwd postgres
4.
chown -R postgres:postgres /home/postgres
chmod -R 700 /home/postgres
ls -ld /home/postgres
chmod -R 700 /home/postgres
ls -ld /home/postgres
5.
cd /usr/local/src
wget https://ftp.postgresql.org/pub/source/v10beta1/postgresql-10beta1.tar.gz
wget https://ftp.postgresql.org/pub/source/v10beta1/postgresql-10beta1.tar.gz
6.
ls
tar zxvf postgresql-10beta1.tar.gz
ls -d postgresql-10beta1
tar zxvf postgresql-10beta1.tar.gz
ls -d postgresql-10beta1
7.
mkdir /opt/postgresql10b1
8.
cd /usr/local/src/postgresql-10beta1
./configure --prefix=/opt/postgresql10b1
./configure --prefix=/opt/postgresql10b1
9.
make10.
make install
11.
ls -l /opt/postgresql10b1
12.
chown -R postgres:postgres /opt/postgresql10b1
ls -l /opt/postgresql10b1
ls -l /opt/postgresql10b1
13.
vi /home/postgres/.bash_profile
15.
# .bash_profile# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
-------------------------------------------------------------------------------追記
POSTGRES_HOME=/opt/postgresql10b1PGBIN=$POSTGRES_HOME/bin
PGLIB=$POSTGRES_HOME/lib
PGDATA==$POSTGRES_HOME/data
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PGLIB
PGPATH=$PATH:$HOME/bin:$PGBIN
export PATH
export PGDATA
export LD_LIBRARY_PATH
export POSTGRES_HOME=/opt/postgresql10b1
export PGBIN=$POSTGRES_HOME/bin
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PGLIB
export PATH=$PGBIN:.:$PATHH
export PGBIN=$POSTGRES_HOME/bin
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PGLIB
export PATH=$PGBIN:.:$PATHH
-------------------------------------------------------------------------------追記END
起動スクリプト
展開したPostgreSQLソース内にcontribディレクトリがあります。
contribディレクトリ内のstart-scriptsにlinuxというファイルが起動スクリプトの雛型になります。
このファイルをrootユーザで/etc/rc.d/init.d/にpostgresとファイル名を変更してコピーします。
contribディレクトリ内のstart-scriptsにlinuxというファイルが起動スクリプトの雛型になります。
このファイルをrootユーザで/etc/rc.d/init.d/にpostgresとファイル名を変更してコピーします。
インストール先は/opt/postgresql10b1なのでprefixに/opt/postgresql10b1を指定します。
chmod 755 /etc/init.d/postgres
chkconfig --add postgres
chkconfig --list | grep postgres
chkconfig postgres on
su - postgres
env | grep PGDATA
initdb --encoding=UTF8 --no-locale
initdb --encoding=UTF8 --locale=C
service postgres start
[root@localhost ~]# su - postgres
[postgres@localhost ~]$ psql