PostgreSql源码方式安装
一 、源码安装
1. Redhat7 修改主机名:
成都创新互联公司自2013年起,是专业互联网技术服务公司,拥有项目成都做网站、网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元海阳做网站,已为上家服务,为海阳各地企业和个人服务,联系电话:13518219792
[root@localhost ~]# hostnamectl set-hostname ygg
检查:
[root@localhost ~]# hostnamectl
Static hostname: ygg
Icon name: computer-vm
Chassis: vm
Machine ID: 19e8c6b6164b453b8816e1a002badeec
Boot ID: b9793f1a2e8c4dbcbf99f9f011563fe6
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@localhost ~]#
2. 安装依赖包:
yum install gcc* gcc-c++* zlib-devel* readline-devel* perl-ExtUtils-Embed* pam-devel* libxml2-devel* libxslt-devel* openldap-devel* python-devel* openssl-devel* cmake* readline* flex* bison* tcl* -y
3. Linux系统内核调整:
vi /etc/sysctl.conf
#add
kernel.shmmax = 68719476736 #最大共享内存段大小(默认)
kernel.shmall = 4294967296 #可以使用的共享内存的总量(默认)
kernel.shmmni = 4096 #整个系统共享内存段的最大数目
kernel.sem = 50100 64128000 50100 1280 #每个信号对象集的最大信号对象数;系统范围内
#最大信号对象数;每个信号对象支持的最大操作数;
#系统范围内最大信号对象集数
fs.file-max = 7672460 #文件句柄的最大数量,文件句柄设置表示在linux系统中可以打开的文件数量
net.ipv4.ip_local_port_range = 9000 65000 #应用程序可使用的IPv4端口范围
net.core.rmem_default = 1048576 #套接字接收缓冲区大小的缺省值
net.core.wmem_default = 262144 #套接字发送缓冲区大小的缺省值
net.core.wmem_max = 1048576 #套接字发送缓冲区大小的最大值
内核参数生效:
sysctl -p
4. 关闭防火墙及selinux。
5. 创建用户:
[root@ygg soft]# useradd postgresql
[root@ygg soft]# passwd postgresql
6. 解压并安装:
[root@ygg soft]# su - postgresql
[postgresql@ygg ~]$ cd /soft/
postgresql-10.3.tar.gz rlwrap-0.43rlwrap-0.43.tar.gz
[postgresql@ygg soft]$ gunzip postgresql-10.3.tar.gz
[postgresql@ygg soft]$ tar -xf postgresql-10.3.tar
[postgresql@ygg soft]$ cd postgresql-10.3/
[postgresql@ygg postgresql-10.3]$ ll
total 672
-rw-r--r--.1 postgresql postgresql 457 Feb 27 2018 aclocal.m4
drwxrwxr-x.2 postgresql postgresql 4096 Feb 27 2018 config 源码安装的配置脚本
-rwxr-xr-x.1 postgresql postgresql 498962 Feb 272018 configure
-rw-r--r--.1 postgresql postgresql 76915 Feb 27 2018 configure.in
drwxrwxr-x. 55 postgresql postgresql 4096 Feb 27 2018 contrib 已打包到PG源码中的第三方贡献的插件源码
-rw-r--r--.1 postgresql postgresql 1192 Feb 27 2018 COPYRIGHT
drwxrwxr-x.3 postgresql postgresql 101 Feb 27 2018 doc 文档
-rw-r--r--.1 postgresql postgresql 3638 Feb 27 2018 GNUmakefile.in
-rw-r--r--.1 postgresql postgresql 284 Feb 27 2018 HISTORY 版本变更的历史记录
-rw-r--r--.1 postgresql postgresql 71584 Feb 27 2018 INSTALL 安装说明
-rw-r--r--.1 postgresql postgresql 1682 Feb 27 2018 Makefile
-rw-r--r--.1 postgresql postgresql 1212 Feb 27 2018 README
drwxrwxr-x. 16 postgresql postgresql 4096 Feb 272018 src 源代码
[postgresql@ygg postgresql-10.3]$ ./configure --help
`configure' configures PostgreSQL 10.3 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/pgsql]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/pgsql/bin', `/usr/local/pgsql/lib' etc. You can specify
an installation prefix other than `/usr/local/pgsql' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/postgresql]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-integer-datetimes
obsolete option, no longer supported
--enable-nls[=LANGUAGES]
enable Native Language Support
--disable-rpath do not embed shared library search path in
executables
--disable-spinlocks do not use spinlocks
--disable-atomics do not use atomic operations
--disable-strong-random do not use a strong random number source
--enable-debug build with debugging symbols (-g)
--enable-profiling build with profiling enabled
--enable-coverage build with coverage testing instrumentation
--enable-dtrace build with DTrace support
--enable-tap-tests enable TAP tests (requires Perl and IPC::Run)
--enable-depend turn on automatic dependency tracking
--enable-cassert enable assertion checks (for debugging)
--disable-thread-safety disable thread-safety in client libraries
--disable-largefile omit support for large files
--disable-float4-byval disable float4 passed by value
--disable-float8-byval disable float8 passed by value
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-extra-version=STRING
append STRING to version
--with-template=NAME override operating system template
--with-includes=DIRS look for additional header files in DIRS
--with-libraries=DIRS look for additional libraries in DIRS
--with-libs=DIRS alternative spelling of --with-libraries
--with-pgport=PORTNUM set default port number [5432]
--with-blocksize=BLOCKSIZE
set table block size in kB [8]
--with-segsize=SEGSIZE set table segment size in GB [1]
--with-wal-blocksize=BLOCKSIZE
set WAL block size in kB [8]
--with-wal-segsize=SEGSIZE
set WAL segment size in MB [16]
--with-CC=CMD set compiler (deprecated)
--with-icu build with ICU support
--with-tcl build Tcl modules (PL/Tcl)
--with-tclconfig=DIR tclConfig.sh is in DIR
--with-perl build Perl modules (PL/Perl)
--with-python build Python modules (PL/Python)
--with-gssapi build with GSSAPI support
--with-krb-srvnam=NAME default service principal name in Kerberos (GSSAPI)
[postgres]
--with-pam build with PAM support
--with-bsd-auth build with BSD Authentication support
--with-ldap build with LDAP support
--with-bonjour build with Bonjour support
--with-openssl build with OpenSSL support
--with-selinux build with SELinux support
--with-systemd build with systemd support
--without-readline do not use GNU Readline nor BSD Libedit for editing
--with-libedit-preferred
prefer BSD Libedit over GNU Readline
--with-uuid=LIB build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)
--with-ossp-uuid obsolete spelling of --with-uuid=ossp
--with-libxml build with XML support
--with-libxslt use XSLT support when building contrib/xml2
--with-system-tzdata=DIR
use system time zone data in DIR
--without-zlib do not use Zlib
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
Some influential environment variables:
CCC compiler command
CFLAGSC compiler flags
LDFLAGSlinker flags, e.g. -Lif you have libraries in a
nonstandard directory
LIBSlibraries to pass to the linker, e.g. -l
CPPFLAGS(Objective) C/C++ preprocessor flags, e.g. -Iif
you have headers in a nonstandard directory
CPPC preprocessor
PKG_CONFIGpath to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
ICU_CFLAGSC compiler flags for ICU, overriding pkg-config
ICU_LIBSlinker flags for ICU, overriding pkg-config
LDFLAGS_EXextra linker flags for linking executables only
LDFLAGS_SLextra linker flags for linking shared libraries only
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to.
[postgresql @ ygg postgresql-10.3] $ ./configure --help
`configure'配置PostgreSQL 10.3以适应多种系统。
用法:./ configure [OPTION] ... [VAR = VALUE] ...
要分配环境变量(例如CC,CFLAGS ...),请将它们指定为
VAR = VALUE。有关某些有用变量的说明,请参见下文。
选项的默认值在方括号中指定。
组态:
-h,--help显示此帮助并退出
--help =简短显示此软件包的选项
--help = recursive显示所有包含的软件包的简短帮助
-V,--version显示版本信息并退出
-q,-quiet,-silent不打印“检查中...”消息
--cache-file = FILE缓存测试结果在FILE中[已禁用]
-C,“-cache-file = config.cache”的--config-cache别名
-n,--no-create不创建输出文件
--srcdir = DIR在DIR中找到源[configure dir或`..']
安装目录:
--prefix = PREFIX在PREFIX中安装与体系结构无关的文件
[/ usr / local / pgsql]
--exec-prefix = EPREFIX在EPREFIX中安装与体系结构相关的文件
[字首]
默认情况下,“ make install”将安装所有文件
/ usr / local / pgsql / bin,/ usr / local / pgsql / lib等。您可以指定
使用`--prefix'的`/ usr / local / pgsql'以外的安装前缀,
例如`--prefix = $ HOME'。
为了更好地控制,请使用以下选项。
微调安装目录:
--bindir = DIR 用户可执行文件[EPREFIX / bin]
--sbindir = DIR 系统管理员可执行文件[EPREFIX / sbin]
--libexecdir = DIR 程序可执行文件[EPREFIX / libexec]
--sysconfdir = DIR 只读单机数据[PREFIX / etc]
--sharedstatedir = DIR 可修改的体系结构独立数据[PREFIX / com]
--localstatedir = DIR 可修改的单机数据[PREFIX / var]
--libdir = DIR 目标代码库[EPREFIX / lib]
--includedir = DIR C头文件[PREFIX / include]
--oldincludedir =非gcc的DIR C头文件[/ usr / include]
--datarootdir = DIR 只读的独立于拱的数据根[PREFIX / share]
--datadir = DIR 与架构无关的只读数据[DATAROOTDIR]
--infodir = DIR 信息文档[DATAROOTDIR / info]
--localedir = DIR 依赖于语言环境的数据[DATAROOTDIR / locale]
--mandir = DIR 手册文件[DATAROOTDIR / man]
--docdir = DIR 文档根[DATAROOTDIR / doc / postgresql]
--htmldir = DIR html文档[DOCDIR]
--dvidir = DIR dvi文档[DOCDIR]
--pdfdir = DIR pdf文档[DOCDIR]
--psdir = DIR ps文档[DOCDIR]
系统类型:
--build = BUILD 配置为在BUILD上构建[猜测]
--host = HOST 交叉编译以构建要在HOST上运行的程序[BUILD]
可选功能:
--disable-option-checking 忽略无法识别的--enable /-with options
--disable-FEATURE 不包含FEATURE(与--enable-FEATURE = no相同)
--enable-FEATURE [= ARG] 包括功能[ARG = yes]
--disable-integer-datetimes 过时的选项,不再受支持
--enable-nls [= LANGUAGES] 启用母语支持
--disable-rpath 不将共享库搜索路径嵌入到可执行文件
--disable-spinlocks 不使用自旋锁
--disable-atomics 不使用原子操作
--disable-strong-random 不使用强随机数源
--enable-debug 带有调试符号的构建(-g)
--enable-profiling 构建并启用了性能分析使用覆盖率测试工具启用覆盖范围构建
--enable-dtrace 带有DTrace支持的构建
--enable-tap-tests 启用TAP测试(需要Perl和IPC :: Run)
--enable-depend 打开自动依赖性跟踪
--enable-cassert 启用断言检查(用于调试)
--disable-thread-safety 禁用客户端库中的线程安全
--disable-largefile 省略对大文件的支持
--disable-float4-byval 禁用按值传递的float4
--disable-float8-byval 禁用由值传递的float8
可选软件包:
--with-PACKAGE [= ARG] 使用包[ARG = yes]
--without-PACKAGE 不要使用PACKAGE(与--with-PACKAGE = no相同)
--with-extra-version = STRING 将STRING附加到版本
--with-template = NAME 覆盖操作系统模板
--with-includes = DIRS 在DIRS中查找其他头文件
--with-libraries = DIRS 在DIRS中寻找其他库
--with-libs = DIRS --with-libraries的替代拼写
--with-pgport = PORTNUM 设置默认端口号[5432]
--with-blocksize = blocksize 将表块大小设置为kB [8]
--with-segsize = SEGSIZE 以GB为单位设置表段的大小[1]
--with-wal-blocksize=blocksize 在kB中设置WAL块大小[8]
--with-wal-segsize = SEGSIZE 以MB为单位设置WAL段大小[16]
--with-CC = CMD 设置编译器(不建议使用)
--with-icu 在ICU支持下进行构建
--with-tcl 构建Tcl模块(PL / Tcl)
--with-tclconfig = DIR tclConfig.sh在DIR中
--with-perl 构建Perl模块(PL / Perl)
--with-python 构建Python模块(PL / Python)
--with-gssapi 构建具有GSSAPI支持
--with-krb-srvnam = NAME Kerberos(GSSAPI)中的默认服务主体名称[postgres]
--with-pam 建立并支持PAM
--with-bsd-auth 构建具有BSD身份验证支持
--with-ldap 建立LDAP支持
--with-bonjour 在Bonjour支持下进行构建
--with-openssl 建立具有OpenSSL支持
--with-selinux 构建带有SELinux支持
--with-systemd 构建并具有systemd支持
--without-readline 不要使用GNU Readline或BSD Libedit进行编辑
--with-libedit-preferred 比GNU Readline更喜欢BSD Libedit
--with-uuid = LIB 使用LIB(bsd,e2fs,ossp)构建contrib / uuid-ossp
--with-ossp-uuid --with-uuid = ossp的过时拼写
--with-libxml 建立XML支持
--with-libxslt 在构建contrib / xml2时使用XSLT支持
--with-system-tzdata = DIR 在DIR中使用系统时区数据
--without-zlib 不要使用Zlib
--with-gnu-ld 假定C编译器使用GNU ld [default = no]
一些有影响力的环境变量:
CC C编译器命令
CFLAGS C编译器标志
LDFLAGS 链接器标志,例如-L(如果您在非标准目录 LIBS库传递给链接器,例如-l
CPPFLAGS (客观)C / C ++预处理器标志,例如,如果-I您在非标准目录 中具有标题
CPP C预处理器
PKG_CONFIG 到pkg-config实用程序的路径
PKG_CONFIG_PATH 要添加到pkg-config的搜索路径的目录
PKG_CONFIG_LIBDIR 覆盖pkg-config的内置搜索路径的路径
ICU_CFLAGS ICU的C编译器标志,覆盖pkg-config
ICU的ICU_LIBS 链接器标志,覆盖pkg-config
LDFLAGS_EX 额外的链接器标志,仅用于链接可执行文件
LDFLAGS_SL 额外的链接器标志,仅用于链接共享库
使用这些变量来覆盖`configure'所做的选择或提供帮助
查找具有非标准名称/位置的库和程序。
向报告错误。
./configure --prefix=/home/postgresql/postgresql10/prefix --exec-prefix=/home/postgresql/postgresql10/execprefix --htmldir=/home/postgresql/postgresql10/html --with-pgport=1922 --with-openssl --with-perl --with-tcl --with-python --with-pam --without-ldap --with-libxml --with-libxslt --enable-thread-safety --with-wal-blocksize=16 --with-blocksize=8 --enable-dtrace --enable-debug
完成不报错如下:
如果报错缺少依赖包,根据提示yum相关包,重新配置
gmake world --包括第三方插件全部编译
结果如下:
gmake check-world --这个需要使用普通用户执行,可选,耗时较长
结果如下:
gmake install-world -- 包括第三方插件全部安装
7. 配置环境变量:
根据当前配置安装完成后,相关目录结构如下:
[postgresql@ygg ~]$ tree -d
.
`-- postgresql10
|-- data
|-- execprefix
| |-- bin
| `-- lib
| |-- pgxs
| | |-- config
| | `-- src
| | |-- makefiles
| | `-- test
| | `-- regress
| `-- pkgconfig
|-- html
| `-- html
`-- prefix
|-- include
| |-- informix
| | `-- esql
| |-- internal
| | `-- libpq
| |-- libpq
| `-- server
| |-- access
| |-- bootstrap
| |-- catalog
| |-- commands
| |-- common
| |-- datatype
| |-- executor
| |-- fe_utils
| |-- foreign
| |-- lib
| |-- libpq
| |-- mb
| |-- nodes
| |-- optimizer
| |-- parser
| |-- port
| | |-- atomics
| | |-- win32
| | | |-- arpa
| | | |-- netinet
| | | `-- sys
| | `-- win32_msvc
| | `-- sys
| |-- portability
| |-- postmaster
| |-- regex
| |-- replication
| |-- rewrite
| |-- snowball
| | `-- libstemmer
| |-- statistics
| |-- storage
| |-- tcop
| |-- tsearch
| | `-- dicts
| `-- utils
`-- share
|-- doc
| `-- extension
|-- extension
|-- man
| |-- man1
| |-- man3
| `-- man7
|-- timezone
| |-- Africa
| |-- America
| | |-- Argentina
| | |-- Indiana
| | |-- Kentucky
| | `-- North_Dakota
| |-- Antarctica
| |-- Arctic
| |-- Asia
| |-- Atlantic
| |-- Australia
| |-- Brazil
| |-- Canada
| |-- Chile
| |-- Etc
| |-- Europe
| |-- Indian
| |-- Mexico
| |-- Pacific
| `-- US
|-- timezonesets
`-- tsearch_data
二、卸载:
编译安装后如何卸载
•一般的,清除安装目录,再次安装可以尝试重新指定路径(安装时指定安装目录)•在安装的时候加 prefix ,不然的话虽然用find命令可以找出一些相关文件,但是对于修改了配置,比如加入启动项之类的操作就不好根除•通常只能用find去手动清除。所以软件通常都会提供uninstall的程序来执行卸载操作。
三、仅仅安装客户端
如果只想安装客户端应用程序和接口库,则可以使用以下命令:
make -C src/bin install
make -C src/include install
make -C src/interfaces install
make -C doc install
网页标题:PostgreSql源码方式安装
转载来于:http://myzitong.com/article/gpscdi.html