源码编译安装PostgresSQL(11.5)
原文链接:https://www.modb.pro/db/22220?cyn (阅读原文,支持作者)
摘要:源码编译安装pg11.5(Centos7.4+PG11.5)。
一、环境准备
1、安装依赖包
yum -y install gcc*
yum -y install python python-devel
yum -y install perl-ExtUtils-Embed
yum -y install zlib-devel
yum -y install readline*
2、创建用户组、目录
groupadd -g 1001 postgres #新增用户组
useradd -g 1001 -u 1001 postgres #新增用户
[root@pg11 ~]# id postgres
uid=1001(postgres) gid=1001(postgres) groups=1001(postgres)
passwd postgres #为用户设置密码
3、创建目录
mkdir -p /usr/local/pgsql11.5
chown -R postgres:postgres /usr/local/pgsql11.5/
mkdir -p /home/osdata/pgdata
chown -R postgres:postgres /home/osdata/
chmod 0700 /home/osdata/pgdata
4、修改环境变量(postgres用户)
export PATH=/usr/local/pgsql11.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/pgsql11.5/lib
export PGDATA=/home/osdata/pgdata
5、上传软件包,并且解压缩(root)
[root@pg11 pgsql11.5]# ll
total 19312
-rw-r–r--. 1 root root 19773087 Oct 30 20:05 postgresql-11.5.tar.bz2
[root@pg11 pgsql11.5]#chown -R postgres:postgres /usr/local/pgsql11.5/
[root@pg11 pgsql11.5]# ll
total 19312
-rw-r–r--. 1 postgres postgres 19773087 Oct 30 20:05 postgresql-11.5.tar.bz2
tar -xvf postgresql-11.5.tar.bz2
6、生成链接
ln -sf /usr/local/pgsql11.5 /usr/local/pgsql
二、安装postgresql
1、编译
cd postgresql-11.5/
./configure --prefix=/usr/local/pgsql11.5 --with-perl --with-python
2、安装
一次性把文档及附加模块全部进行编译和安装
gmake world
出现“PostgreSQL, contrib, and documentation successfully made. Ready to install.”说明编译成功
gmake install-world
出现“PostgreSQL, contrib, and documentation installation complete.”说明安装成功
查看版本
[postgres@pg11 postgresql-11.5]$ postgres --version
postgres (PostgreSQL) 11.5
3、初始化数据库
initdb -D /home/osdata/pgdata/ -W
4、启动数据库
pg_ctl -D $PGDATA -l logfile start
5、查看实例进程
[postgres@pg ~]$ ps -ef|grep postgres
postgres 56625 1 0 Mar04 ? 00:00:03 /usr/local/pgsql11.5/bin/postgres -D /home/osdata/pgdata
postgres 56627 56625 0 Mar04 ? 00:00:00 postgres: checkpointer
postgres 56628 56625 0 Mar04 ? 00:00:01 postgres: background writer
postgres 56629 56625 0 Mar04 ? 00:00:01 postgres: walwriter
postgres 56630 56625 0 Mar04 ? 00:00:05 postgres: autovacuum launcher
postgres 56631 56625 0 Mar04 ? 00:00:10 postgres: stats collector
postgres 56632 56625 0 Mar04 ? 00:00:00 postgres: logical replication launcher
root 76758 76699 0 11:01 pts/0 00:00:00 su - postgres
postgres 76759 76758 0 11:01 pts/0 00:00:00 -bash
postgres 76797 76759 0 11:01 pts/0 00:00:00 psql
postgres 76801 56625 0 11:01 ? 00:00:00 postgres: postgres test [local] idle
root 77192 77145 0 11:21 pts/1 00:00:00 su - postgres
postgres 77193 77192 0 11:21 pts/1 00:00:00 -bash
postgres 79582 77193 0 13:45 pts/1 00:00:00 ps -ef
postgres 79583 77193 0 13:45 pts/1 00:00:00 grep --color=auto postgres
查看数据库状态
[postgres@pg11 ~]$ pg_ctl -D /home/osdata/pgdata/ status
pg_ctl: server is running (PID: 23588)
/usr/local/pgsql11.5/bin/postgres “-D” “/home/osdata/pgdata”
6、设置开机自启动
1、配置脚本服务
在源码包的contrib目录中有linux、freebsd、macos适用的服务脚本
[root@pg11 ~]# cd /usr/local/pgsql/postgresql-11.5/contrib/start-scripts
[root@pg11 start-scripts]# ll
total 8
-rw-r–r--. 1 postgres postgres 1467 Aug 6 2019 freebsd
-rw-r–r--. 1 postgres postgres 3552 Aug 6 2019 linux
drwxrwxr-x. 2 postgres postgres 84 Aug 6 2019 macos
把名为linux的脚本拷贝到/etc/init.d目录,并且重命名为postgresql11
[root@pg11 ~]# cp /usr/local/pgsql/postgresql-11.5/contrib/start-scripts/linux /etc/init.d/postgresql11
[root@pg11 init.d]# chmod +x postgresql-11
[root@pg11 init.d]# chkconfig postgresql-11 on
[root@pg11 init.d]# chkconfig --list |grep postgresql-11
postgresql-11 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7、登录数据库
[postgres@pg ~]$ psql
psql (11.5)
Type “help” for help.
postgres=#
更多PG相关入门分享、进阶练习:https://www.modb.pro/tag/postgresql?cyn
源码编译安装PostgresSQL(11.5)相关推荐
- CentOS 7 源码编译安装 PostgreSQL 11.2
环境 系统版本 Centos7.6 工具:xshell6 PostgreSql: postgresql-11.2.tar.gz 安装部署 安装前准备 官网下载PostgreSQL 11.2源码地址:h ...
- mono和monodevelop源码编译安装
之所以用源码编译的方式安装mono和monodevelop,是因为通过yum安装的mono不是最新版本,而且monodevelop不能建 asp.net MVC3的工程. 而且通过源码安装,可以进一步 ...
- 源码编译安装percona-xtrabackup-2.3.2
一.系统包需求 rpm -q libaio-devel libgpg-error-devel libgcrypt-devel autoconf automake libidn-devel libcur ...
- mysql5.7 cmake源码编译安装
mysql5.7 cmake源码编译安装, -----该文章的知识点是一个大牛总结的,我这里只是加工了一下,非原创文章. 搜狐开源镜像站:http://mirrors.sohu.com/ 网易开源镜像 ...
- CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境
什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/Perl/Python组合成的动态Web应用程序和服务器,它是一组Web应用程序的基础 ...
- mysql+PHP源码编译安装
mysql源码编译安装 环境redhat6.5 安装依赖包: yum install cmake-2.8.12.2-4.el6.x86_64.rpm gcc-c++ ncurses-devel gcc ...
- LNMP架构环境搭建之PHP、Nginx源码编译安装及其简单配置应用
LNMP架构中的Mysql见上一篇博文"LNMP架构环境搭建之mysql源码编译安装" 一.PHP简介 PHP(外文名:PHP: Hypertext Preprocessor,中文 ...
- LNMP架构环境搭建之mysql源码编译安装
Mysql MySQL是一个开源的数据库,在互联网行业应用的很广泛,下面来记录一下从源码编译安装的步骤,当然,MySQL也有其他安装方式,比如,使用yum下载安装rpm包,或者二进制方式安装,如果机器 ...
- mysql5.1编译安装centos7_CentOS7下 Nginx1.13.5 + PHP7.1.10 + MySQL5.7.19 源码编译安装
在CentOS7下 Nginx1.13.5 + PHP7.1.10 + MySQL5.7.19 源码编译安装过程记录. 一.安装Nginx 1.安装依赖扩展 # yum -y install wget ...
最新文章
- Linux中的Screen命令使用技巧详解
- JVM是如何分配和回收内存?有实例!
- oracle 数据库问题:“ORA-01922: 必须指定 CASCADE 以删除...“,原因及解决办法
- 【杂文】Do A Slash
- 如何使用Java和XML Config在Spring Security中启用HTTP基本身份验证
- vscode 文件高亮插件_vscode中的vue文件不高亮,但是已经安装了vetur插件了,到底为什么???...
- getElementById和ByTagName的区别
- android不是16位,16位图像和Android处理
- C中处理Python的Numpy数组的代码范例
- The engine “node“ is incompatible with this module
- 如何写好周报并建立周报模板
- Java实现学生成绩分析系统
- 电脑插上耳机后声音依然外放,简单解决两步走!
- web前端工程师的分工安排
- php之Twitter第三方登录
- Matplotlib输出中文显示问题
- mac book 华为C8815不能debug
- java视频点播系统_jsp教学视频点播系统
- fegin设置header
- 留言赠书|AI圣经,这本书YYDS
热门文章
- 智慧气象 开源_来自开源的半条命11条智慧
- opensource项目_Opensource.com下一次迭代的重点
- vr设备应用程序_在15分钟内构建一个VR Web应用程序
- daisy_DAISY:视障人士的Linux兼容文本格式
- 运放组成的吉他放大电路_如何通过5个步骤构建开放式硬件吉他放大器
- 在组织中为IT部门构建小型冠军的最快方法
- 高性能滚动scroll(防抖和节流)
- CSS 匿名文本和匿名框
- IQ不平衡补偿 Lowdin算法
- c# 多线程单例模式_单例模式,多线程单例,双重锁定单例,工场单例创建上下文...