linux postgresql 安装
程序员文章站
2022-05-27 16:18:41
...
对多个PG版本测试兼容性,匆忙写了脚本。
在root用户下执行
./***.sh 用户 群组 安装包tar包名字 安装目录
例如在当前目录下有 postgresql-13.2.tar.gz 安装包 将安装在/opt/pg13目录 使用pg13用户
./install.sh pg13 pg13 postgresql-13.2.tar.gz /opt/pg13
本地测试通过,有问题请不吝赐教。
依赖包
yum install bison \
flex \
readline-devel \
zlib-devel \
openssl-devel \
libxml2-devel \
libxslt-devel \
uuid-devel \
openldap-devel \
python-devel \
krb5-devel \
tcl-devel \
pam-devel \
gettext-devel \
gcc \
gcc-c++ \
gtk2-devel \
automake \
gettext\
perl-ExtUtils-Embed \
readline-devel
shell
#!/bin/bash
user_name=$1
user_group=$2
install_file_name=$3
install_path=$4
temp_path=$install_file_name
dir=${temp_path%.*}
result=${dir%.*}
echo "begin"
#del
userdel -r $user_name
groupdel $user_group
rm -rf $install_path
rm -rf /home/$user_name/$result
#create user
groupadd $user_group
useradd $user_name -g $user_group
echo "create "$user_name"done"
#create dir
mkdir $install_path
chown -R $user_name:$user_group $install_path
echo "create dir done"
#copy file
cp ./$install_file_name /home/$user_name
sleep 1
chown -R $user_name:$user_group /home/$user_name/$install_file_name
echo "copy file done"
temp_path=$install_file_name
dir=${temp_path%.*}
result=${dir%.*}
#gzip file
su - $user_name<<EOF
cd ~
tar -zxvf $install_file_name
echo "tar file done"
#config
cd $result
sed -i 's/\-O2//g' configure*
./configure --prefix=$install_path --enable-debug
echo "config done"
#install
make
slepp 5
make install
echo "done"
#source bashrc
echo "export PGHOME=$install_path" >> ~/.bashrc
echo "export PGDATA=$install_path/data" >> ~/.bashrc
echo "export PGLIB=$install_path/lib" >> ~/.bashrc
echo "export PATH=$install_path/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
echo "source done"
#initdb
initdb
echo "host all all 0.0.0.0/0 trust" >> $install_path/data/pg_hba.conf
echo "listen_addresses = '*' " >> $install_path/data/postgresql.conf
echo "port = 5432 " >> $install_path/data/postgresql.conf
echo "initdb done"
#test database
pg_ctl start -D $install_path/data -l logfile
createdb test_database
psql -dtest_database -h127.0.0.1 <<EXIT
\x
\d
\dx
select * from pg_class limit 5;
\q
EXIT
exit;
EOF
echo "done"
上一篇: php引用传值(转)
下一篇: 配置文件里的proxy
推荐阅读
-
QT语音怎么用?QT语音安装使用详细教程
-
Cimatron E14怎么安装?Cimatron E14安装破解详细图文教程
-
Win10周年累积更新KB3206632及12月全部补丁独立安装包下载
-
ae cs5.5破解版怎么安装?After Effects CS5.5中文破解版安装注册图文教程
-
迅捷录音软件如何使用?迅捷录音软件安装使用教程
-
迅捷苹果录屏精灵如何使用?迅捷苹果录屏精灵安装使用教程
-
linux释放内存命令(linux top命令的用法详细详解)
-
Steam怎么购买游戏 Steam游戏购买安装教程
-
Meshmixer怎么用?Meshmixer安装使用教程
-
Python提取Linux内核源代码的目录结构实现方法