Commit 675fc3c0 authored by root's avatar root

modify postgresql install

parent a2a2753e
#!/bin/bash
mv ./postgresql-10.5.tar.gz /usr/gisdeploy
cd /usr/gisdeploy
tar zxvf postgresql-10.5.tar.gz
echo "pgsql tar sucess"
#is postgres exist
id $postgres >& /dev/null
if [ $? == 0 ]
then
echo "create postgres"
groupadd postgres
useradd -g postgres postgres
fi
echo "enter postgresql dir"
rm /usr/gisdeploy/postgresql-10.5.tar.gz -rf
mv /usr/gisdeploy/postgresql-10.5 /usr/gisdeploy/pgsql/
cd /usr/gisdeploy/pgsql/
#-------------------------------pgsql------------------------------------
echo "install lib"
yum install -y zlib zlib-devel >& /dev/null
echo "configure"
./configure --prefix=/usr/gisdeploy/pgsql --without-readline
if [ $? == 0 ]
then
echo "configure finish make"
make
if [ $? == 0 ]
then
echo "start make"
make install
if [ $? != 0 ];then
echo "make install fail"
fi
echo "make install sucess"
else
echo "make fail"
fi
else
echo "configure check error"
fi
echo "configure pgsql"
echo "create pgsql data dir"
mkdir -p /usr/gisdeploy/pgsql/data
echo "modify group"
chown -R postgres:postgres /usr/gisdeploy/pgsql
echo "add env"
cd /home/postgres
if [ -f .bash_profile ] ;then
cp .bash_profile .bash_profile.bak
echo "export PGHOME=/usr/gisdeploy/pgsql" >> .bash_profile
echo "export PGDATA=/usr/gisdeploy/pgsql/data" >> .bash_profile
echo "PATH=$PGHOME/bin:$PATH" >> .bash_profile
echo "MANPATH=$PGHOME/share/man:$MANPATH" >> .bash_profile
echo "LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH" >> .bash_profile
fi
alias pg_start='pg_ctl -D $PGDATA -l /usr/gisdeploy/pgsql/logfile start'
alias ps_stop='pg_ctl -D $PGDATA -l /usr/gisdeploy/pgsql/logfile stop'
echo "postgres init"
yum install -y epel-release
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql110-server
sudo yum install -y postgis25_10.x86_64
sudo yum install -y pgrouting_10.x86_64
sudo firewall-cmd --zone=public --add-port=5432/tcp --permanent
su - postgres -c "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data --locale=zh_CN.UTF-8 -E UTF-8"
su - postgres -c "/usr/gisdeploy/pgsql/bin/pg_ctl -D /usr/gisdeploy/pgsql/data -l logfile start"
echo "---------------------------------------------------------------------------------------"
echo "---------------------------------------------------------------------------------------"
echo "----------------------------finish-------------------------"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment