Just copy the below lines and create a file. Your linux system will be ready with custom PostgreSQL installation. You can modify the script based on your need. You can consider the below lines as a framework. Cheers !!
Environment - Amazon Linux
#!/bin/bash
Environment - Amazon Linux
#!/bin/bash
set -x
sudo su - <<EOF
/usr/bin/yum -y install gcc
/usr/bin/yum -y install readline-devel
/usr/bin/yum -y install zlib-devel
echo "Adding User for Postgres server"
/usr/sbin/useradd -d /home/postgres -m postgres
read -s -p "Enter password for postgres: "
password
echo $password |passwd --stdin postgres
chage postgres -M -1
#/usr/sbin/useradd -d /home/postgres -m postgres
#passwd postgres
#read -p "New password:" postgres
#read -p "Retype new password " postgres
/bin/tar -xzf postgresql-10.1.tar.gz
cd postgresql-10.1
/root/postgresql-10.1/configure
--prefix=/usr/local/pgsql10/
make
make install
/bin/mkdir /usr/local/pgsql10/data
/bin/chown postgres:postgres -R /usr/local/pgsql10
EOF
sudo su - postgres <<EOF
cd /usr/local/pgsql10/bin
/usr/local/pgsql10/bin/initdb -D
/usr/local/pgsql10/data
/usr/local/pgsql10/bin/pg_ctl -D
/usr/local/pgsql10/data start
EOF
sudo su - <<EOF
/bin/ln -s /usr/local/pgsql10/bin/psql /usr/bin
EOF
sudo su - postgres <<EOF
/usr/bin/perl -i -p -e "s/\#listen_addresses =
'localhost'/listen_addresses = '*'/;"
/usr/local/pgsql10/data/postgresql.conf
/usr/bin/perl -i -p -e "s/shared_buffers
= 128MB/shared_buffers = 2GB/;"
/usr/local/pgsql10/data/postgresql.conf
/usr/bin/perl -i -p -e "s/\#port = 5432/port = 5433/;"
/usr/local/pgsql10/data/postgresql.conf
/usr/local/pgsql10/bin/pg_ctl -D
/usr/local/pgsql10/data restart
EOF
No comments:
Post a Comment