shell脚本自动化安装pgsql10.5版本
看到有个大佬写了个很实用的脚本,于是这里做了转载
#!/bin/bash
#进入软件的制定安装目录
echo "进入目录/usr/local,下载pgsql文件"
cd /usr/local
#判断是否有postgre版本的安装包
if [ -d post* ]
then
rm -rf /usr/local/post*
echo "安装包删除成功"
fi
#开始下载pgsql版本10.5并解压
if [ ! -d /usr/local/src ]
then
mkdir /usr/local/src
fi
cd /usr/local/src
wget https://ftp.postgresql.org/pub/source/v10.5/postgresql-10.5.tar.gz
if [ $? == 0 ]
then
tar -zxf postgresql-10.5.tar.gz -C /usr/local/
fi
echo "pgsql文件解压成功"
#判断用户是否存在
id $postgres >& /dev/null
echo "用户postgres已存在"
if [ $? -ne 0 ]
then
echo "用户不存在,开始创建postgres用户"
groupadd postgres
useradd -g postgres postgres
fi
echo "重命名postgresql并且进入安装目录"
mv /usr/local/post* /usr/local/pgsql
cd /usr/local/pgsql
#-------------------------------安装pgsql------------------------------------
echo "安装一些库文件"
yum install -y zlib zlib-devel >& /del/null
echo "开始执行configure步骤"
./configure --prefix=/usr/local/pgsql --without-readline
if [ $? == 0 ]
then
echo "configure配置通过,开始进行make编译"
make
if [ $? == 0 ]
then
echo "make编译通过,开始进行make install安装步骤"
make install
if [ $? != 0 ];then
echo "make install安装失败"
fi
echo "安装成功"
else
echo "make编译失败,检查错误。"
fi
else
echo "configure检查配置失败,请查看错误进行安装库文件"
fi
echo "开始进行pgsql的配置"
echo "给pgsql创建data目录"
mkdir -p /usr/local/pgsql/data
echo "修改用户组"
chown -R postgres:postgres /usr/local/pgsql
echo "添加环境变量,进入postgres用户的家目录"
cd /home/postgres
if [ -f .bash_profile ] ;then
cp .bash_profile .bash_profile.bak
echo "export PGHOME=/usr/local/pgsql" >> .bash_profile
echo "export PGDATA=/usr/local/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/local/pgsql/logfile start'
alias ps_stop='pg_ctl -D $PGDATA -l /usr/local/pgsql/logfile stop'
echo "切换至postgres用户来初始化数据库"
su - postgres -c "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
echo "---------------------------------------------------------------------------------------"
echo "---------------------------------------------------------------------------------------"
echo "----------------------------SUCCESS INSTALLATION OF POSTGRESQL-------------------------"
转自:https://www.cnblogs.com/FengGeBlog/p/9884207.html
shell脚本自动化安装pgsql10.5版本的更多相关文章
- shell脚本自动化安装LAMP
#!/bin/bash#auto make install LAMP#by authors yehailun #arp和apr-util依赖APR_FILES=apr-1.6.2.tar.gz APR ...
- fdisk分区硬盘并shell脚本自动化
最近工作需要用到对硬盘进行shell脚本自动化分区和mount的操作,google了一些资料,下面做个总结. 如果硬盘没有进行分区(逻辑分区或者扩展分区,关于两者概念,自行google),我们将无法将 ...
- Centos 6.4上面用Shell脚本一键安装vsftpd
Centos 6.4上面用Shell脚本一键安装vsftpd install.sh #!/bin/bash if [ `uname -m` == "x86_64" ];then m ...
- Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
Centos 6.4上面用Shell脚本一键安装mysql 5.6.15 #!/bin/bash if [ `uname -m` == "x86_64" ];then machi ...
- shell脚本自动化部署服务
shell脚本自动化部署 !/bin/bash #export PATH=$PATH:/export/maven/bin run_flag_dir="/data0/shell/deploy_ ...
- 安装完Ubuntu后通过shell脚本一键安装软件
安装完Ubuntu后通过shell脚本一键安装软件 以下代码中#是单行注释 :<<! ! 是多行注释. 运行的时候需要把多行注释去掉. 比如把以下代码保存为install.sh, 那么在终 ...
- shell脚本自动化部署
由于公司技术部团队较小,没有专门的运维团队,所以运维工作技术部承包了. 一.纯人工部署是这样的: 1. 本地打包:一般 maven clean package 2. 借助xftp上传到服务器对应目录 ...
- linux下使用shell脚本自动化部署项目
在Java开发项目时经常要把正在开发的项目发布到测试服务器中去测试,一般的话是要把项目先打成war包,然后把war包发布到服务器中,关闭服务器, 最后重新启动服务器,虽然这过程不是很繁琐,但如果是多个 ...
- Shell脚本一键安装LNMP环境
https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...
随机推荐
- kafka的分区
分区会均匀的分配到不同的broke上,即不同的机器上.
- myssl.com SSL 检测
配置正确了,就正常了. 与证书关系不大.
- 小程序onShow
/** * 生命周期函数--监听页面加载 */ onLoad: function(options) { let that = this; const openid = app.globalData.o ...
- c++11多线程记录2:线程管理
线程没有调用join和detach thread对象必须调用join或者detach,否则程序会终止 例如: void func() { std::cout << "hello, ...
- 个人Wiki搭建(Gitbook + GitHub Pages)
工具选择:Gitbook + GitHub Pages 大概流程: 首先在本地编写md文件,然后生成对应的html文件,最后将这些html文件推送到github对应的gitbook仓库. 具体步骤: ...
- SpringBootServletInitializer报错
1. 现象 从Springboot 1.5.1.RELEASE 升级到Springboot 2.1.2.RELEASE 后SpringBootServletInitializer报错. 2.解决方法 ...
- npm全局模块卸载及默认安装目录修改方法
卸载全局安装模块 npm uninstall -g <package> 卸载后,你可以到 /node_modules/ 目录下查看包是否还存在,或者使用以下命令查看:npm ls npm ...
- 魅族手机使用应用沙盒一键修改imsi数据
较早前文章介绍了怎么在安卓手机上安装激活XPosed框架,XPosed框架的牛逼之处功能各位都介绍过,可以不修改apk的前提下,修改系统内核的参数,打比方在某些应用领域,各位需要修改手机的某个系统参数 ...
- C语言判断字符串是否是 hex string的代码
把写内容过程中经常用到的一些内容段备份一下,如下内容内容是关于C语言判断字符串是否是 hex string的内容. { static unsigned int hex2bin[256]={0}; me ...
- Solr字段类型
一.一般属性 1.name fieldType的名称.该值用于字段定义中的类型属性,强烈建议名称仅包含字母数字和下划线,不能以数字开头[非强制]. 2.class 用于存储和索引此类型数据的类名.可以 ...