INSTALL 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567
  1. PostgreSQL Installation from Source Code
  2. ------------------------------------------------------------------------
  3. This document describes the installation of PostgreSQL using this source
  4. code distribution.
  5. If you are building PostgreSQL for Microsoft Windows, read this document
  6. if you intend to build with MinGW or Cygwin; but if you intend to build
  7. with Microsoft's Visual C++, see the main documentation instead.
  8. ------------------------------------------------------------------------
  9. Short Version
  10. ./configure
  11. make
  12. su
  13. make install
  14. adduser postgres
  15. mkdir /usr/local/pgsql/data
  16. chown postgres /usr/local/pgsql/data
  17. su - postgres
  18. /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
  19. /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
  20. /usr/local/pgsql/bin/createdb test
  21. /usr/local/pgsql/bin/psql test
  22. The long version is the rest of this document.
  23. ------------------------------------------------------------------------
  24. Requirements
  25. In general, a modern Unix-compatible platform should be able to run
  26. PostgreSQL. The platforms that had received specific testing at the time
  27. of release are described in the section called "Supported Platforms"
  28. below.
  29. The following software packages are required for building PostgreSQL:
  30. - GNU make version 3.80 or newer is required; other make programs or
  31. older GNU make versions will *not* work. (GNU make is sometimes
  32. installed under the name "gmake".) To test for GNU make enter:
  33. make --version
  34. - You need an ISO/ANSI C compiler (at least C99-compliant). Recent
  35. versions of GCC are recommended, but PostgreSQL is known to build
  36. using a wide variety of compilers from different vendors.
  37. - tar is required to unpack the source distribution, in addition to
  38. either gzip or bzip2.
  39. - The GNU Readline library is used by default. It allows psql (the
  40. PostgreSQL command line SQL interpreter) to remember each command
  41. you type, and allows you to use arrow keys to recall and edit
  42. previous commands. This is very helpful and is strongly recommended.
  43. If you don't want to use it then you must specify the
  44. "--without-readline" option to "configure". As an alternative, you
  45. can often use the BSD-licensed "libedit" library, originally
  46. developed on NetBSD. The "libedit" library is GNU
  47. Readline-compatible and is used if "libreadline" is not found, or if
  48. "--with-libedit-preferred" is used as an option to "configure". If
  49. you are using a package-based Linux distribution, be aware that you
  50. need both the readline and readline-devel packages, if those are
  51. separate in your distribution.
  52. - The zlib compression library is used by default. If you don't want
  53. to use it then you must specify the "--without-zlib" option to
  54. "configure". Using this option disables support for compressed
  55. archives in pg_dump and pg_restore.
  56. The following packages are optional. They are not required in the
  57. default configuration, but they are needed when certain build options
  58. are enabled, as explained below:
  59. - To build the server programming language PL/Perl you need a full
  60. Perl installation, including the "libperl" library and the header
  61. files. The minimum required version is Perl 5.8.3. Since PL/Perl
  62. will be a shared library, the "libperl" library must be a shared
  63. library also on most platforms. This appears to be the default in
  64. recent Perl versions, but it was not in earlier versions, and in any
  65. case it is the choice of whomever installed Perl at your site.
  66. "configure" will fail if building PL/Perl is selected but it cannot
  67. find a shared "libperl". In that case, you will have to rebuild and
  68. install Perl manually to be able to build PL/Perl. During the
  69. configuration process for Perl, request a shared library.
  70. If you intend to make more than incidental use of PL/Perl, you
  71. should ensure that the Perl installation was built with the
  72. usemultiplicity option enabled (perl -V will show whether this is
  73. the case).
  74. - To build the PL/Python server programming language, you need a
  75. Python installation with the header files and the sysconfig module.
  76. The minimum required version is Python 2.7. Python 3 is supported if
  77. it's version 3.2 or later; but see the PL/Python documentation when
  78. using Python 3.
  79. Since PL/Python will be a shared library, the "libpython" library
  80. must be a shared library also on most platforms. This is not the
  81. case in a default Python installation built from source, but a
  82. shared library is available in many operating system distributions.
  83. "configure" will fail if building PL/Python is selected but it
  84. cannot find a shared "libpython". That might mean that you either
  85. have to install additional packages or rebuild (part of) your Python
  86. installation to provide this shared library. When building from
  87. source, run Python's configure with the --enable-shared flag.
  88. - To build the PL/Tcl procedural language, you of course need a Tcl
  89. installation. The minimum required version is Tcl 8.4.
  90. - To enable Native Language Support (NLS), that is, the ability to
  91. display a program's messages in a language other than English, you
  92. need an implementation of the Gettext API. Some operating systems
  93. have this built-in (e.g., Linux, NetBSD, Solaris), for other systems
  94. you can download an add-on package from
  95. https://www.gnu.org/software/gettext/. If you are using the Gettext
  96. implementation in the GNU C library then you will additionally need
  97. the GNU Gettext package for some utility programs. For any of the
  98. other implementations you will not need it.
  99. - You need OpenSSL, if you want to support encrypted client
  100. connections. OpenSSL is also required for random number generation
  101. on platforms that do not have "/dev/urandom" (except Windows). The
  102. minimum version required is 1.0.1.
  103. - You need Kerberos, OpenLDAP, and/or PAM, if you want to support
  104. authentication using those services.
  105. - You need LZ4, if you want to support compression of data with this
  106. method; see the configuration parameter default_toast_compression.
  107. - To build the PostgreSQL documentation, there is a separate set of
  108. requirements; see the main documentation's appendix on
  109. documentation.
  110. If you are building from a Git tree instead of using a released source
  111. package, or if you want to do server development, you also need the
  112. following packages:
  113. - Flex and Bison are needed to build from a Git checkout, or if you
  114. changed the actual scanner and parser definition files. If you need
  115. them, be sure to get Flex 2.5.31 or later and Bison 1.875 or later.
  116. Other lex and yacc programs cannot be used.
  117. - Perl 5.8.3 or later is needed to build from a Git checkout, or if
  118. you changed the input files for any of the build steps that use Perl
  119. scripts. If building on Windows you will need Perl in any case. Perl
  120. is also required to run some test suites.
  121. If you need to get a GNU package, you can find it at your local GNU
  122. mirror site (see https://www.gnu.org/prep/ftp for a list) or at
  123. ftp://ftp.gnu.org/gnu/.
  124. Also check that you have sufficient disk space. You will need about 350
  125. MB for the source tree during compilation and about 60 MB for the
  126. installation directory. An empty database cluster takes about 40 MB;
  127. databases take about five times the amount of space that a flat text
  128. file with the same data would take. If you are going to run the
  129. regression tests you will temporarily need up to an extra 300 MB. Use
  130. the "df" command to check free disk space.
  131. ------------------------------------------------------------------------
  132. Installation Procedure
  133. 1. Configuration
  134. The first step of the installation procedure is to configure the
  135. source tree for your system and choose the options you would like.
  136. This is done by running the "configure" script. For a default
  137. installation simply enter:
  138. ./configure
  139. This script will run a number of tests to determine values for
  140. various system dependent variables and detect any quirks of your
  141. operating system, and finally will create several files in the build
  142. tree to record what it found.
  143. You can also run "configure" in a directory outside the source tree,
  144. and then build there, if you want to keep the build directory
  145. separate from the original source files. This procedure is called a
  146. VPATH build. Here's how:
  147. mkdir build_dir
  148. cd build_dir
  149. /path/to/source/tree/configure [options go here]
  150. make
  151. The default configuration will build the server and utilities, as
  152. well as all client applications and interfaces that require only a C
  153. compiler. All files will be installed under "/usr/local/pgsql" by
  154. default.
  155. You can customize the build and installation process by supplying
  156. one or more command line options to "configure". Typically you would
  157. customize the install location, or the set of optional features that
  158. are built. "configure" has a large number of options, which are
  159. described in the section called "configure Options".
  160. Also, "configure" responds to certain environment variables, as
  161. described in the section called "configure Environment Variables".
  162. These provide additional ways to customize the configuration.
  163. 2. Build
  164. To start the build, type either of:
  165. make
  166. make all
  167. (Remember to use GNU make.) The build will take a few minutes
  168. depending on your hardware.
  169. If you want to build everything that can be built, including the
  170. documentation (HTML and man pages), and the additional modules
  171. ("contrib"), type instead:
  172. make world
  173. If you want to build everything that can be built, including the
  174. additional modules ("contrib"), but without the documentation, type
  175. instead:
  176. make world-bin
  177. If you want to invoke the build from another makefile rather than
  178. manually, you must unset MAKELEVEL or set it to zero, for instance
  179. like this:
  180. build-postgresql:
  181. $(MAKE) -C postgresql MAKELEVEL=0 all
  182. Failure to do that can lead to strange error messages, typically
  183. about missing header files.
  184. 3. Regression Tests
  185. If you want to test the newly built server before you install it,
  186. you can run the regression tests at this point. The regression tests
  187. are a test suite to verify that PostgreSQL runs on your machine in
  188. the way the developers expected it to. Type:
  189. make check
  190. (This won't work as root; do it as an unprivileged user.) See the
  191. file "src/test/regress/README" and the documentation for detailed
  192. information about interpreting the test results. You can repeat this
  193. test at any later time by issuing the same command.
  194. 4. Installing the Files
  195. Note:
  196. If you are upgrading an existing system be sure to read the
  197. documentation, which has instructions about upgrading a cluster.
  198. To install PostgreSQL enter:
  199. make install
  200. This will install files into the directories that were specified in
  201. Step 1. Make sure that you have appropriate permissions to write
  202. into that area. Normally you need to do this step as root.
  203. Alternatively, you can create the target directories in advance and
  204. arrange for appropriate permissions to be granted.
  205. To install the documentation (HTML and man pages), enter:
  206. make install-docs
  207. If you built the world above, type instead:
  208. make install-world
  209. This also installs the documentation.
  210. If you built the world without the documentation above, type
  211. instead:
  212. make install-world-bin
  213. You can use make install-strip instead of make install to strip the
  214. executable files and libraries as they are installed. This will save
  215. some space. If you built with debugging support, stripping will
  216. effectively remove the debugging support, so it should only be done
  217. if debugging is no longer needed. install-strip tries to do a
  218. reasonable job saving space, but it does not have perfect knowledge
  219. of how to strip every unneeded byte from an executable file, so if
  220. you want to save all the disk space you possibly can, you will have
  221. to do manual work.
  222. The standard installation provides all the header files needed for
  223. client application development as well as for server-side program
  224. development, such as custom functions or data types written in C.
  225. Client-only installation: If you want to install only the client
  226. applications and interface libraries, then you can use these
  227. commands:
  228. make -C src/bin install
  229. make -C src/include install
  230. make -C src/interfaces install
  231. make -C doc install
  232. "src/bin" has a few binaries for server-only use, but they are
  233. small.
  234. Uninstallation: To undo the installation use the command "make
  235. uninstall". However, this will not remove any created directories.
  236. Cleaning: After the installation you can free disk space by removing
  237. the built files from the source tree with the command "make clean". This
  238. will preserve the files made by the "configure" program, so that you can
  239. rebuild everything with "make" later on. To reset the source tree to the
  240. state in which it was distributed, use "make distclean". If you are
  241. going to build for several platforms within the same source tree you
  242. must do this and re-configure for each platform. (Alternatively, use a
  243. separate build tree for each platform, so that the source tree remains
  244. unmodified.)
  245. If you perform a build and then discover that your "configure" options
  246. were wrong, or if you change anything that "configure" investigates (for
  247. example, software upgrades), then it's a good idea to do "make
  248. distclean" before reconfiguring and rebuilding. Without this, your
  249. changes in configuration choices might not propagate everywhere they
  250. need to.
  251. ------------------------------------------------------------------------
  252. configure Options
  253. "configure"'s command line options are explained below. This list is not
  254. exhaustive (use ./configure --help to get one that is). The options not
  255. covered here are meant for advanced use-cases such as cross-compilation,
  256. and are documented in the standard Autoconf documentation.
  257. ------------------------------------------------------------------------
  258. Installation Locations
  259. These options control where make install will put the files. The
  260. "--prefix" option is sufficient for most cases. If you have special
  261. needs, you can customize the installation subdirectories with the other
  262. options described in this section. Beware however that changing the
  263. relative locations of the different subdirectories may render the
  264. installation non-relocatable, meaning you won't be able to move it after
  265. installation. (The man and doc locations are not affected by this
  266. restriction.) For relocatable installs, you might want to use the
  267. --disable-rpath option described later.
  268. --prefix=PREFIX
  269. Install all files under the directory "PREFIX" instead of
  270. "/usr/local/pgsql". The actual files will be installed into various
  271. subdirectories; no files will ever be installed directly into the
  272. "PREFIX" directory.
  273. --exec-prefix=EXEC-PREFIX
  274. You can install architecture-dependent files under a different
  275. prefix, "EXEC-PREFIX", than what "PREFIX" was set to. This can be
  276. useful to share architecture-independent files between hosts. If you
  277. omit this, then "EXEC-PREFIX" is set equal to "PREFIX" and both
  278. architecture-dependent and independent files will be installed under
  279. the same tree, which is probably what you want.
  280. --bindir=DIRECTORY
  281. Specifies the directory for executable programs. The default is
  282. "EXEC-PREFIX/bin", which normally means "/usr/local/pgsql/bin".
  283. --sysconfdir=DIRECTORY
  284. Sets the directory for various configuration files, "PREFIX/etc" by
  285. default.
  286. --libdir=DIRECTORY
  287. Sets the location to install libraries and dynamically loadable
  288. modules. The default is "EXEC-PREFIX/lib".
  289. --includedir=DIRECTORY
  290. Sets the directory for installing C and C++ header files. The
  291. default is "PREFIX/include".
  292. --datarootdir=DIRECTORY
  293. Sets the root directory for various types of read-only data files.
  294. This only sets the default for some of the following options. The
  295. default is "PREFIX/share".
  296. --datadir=DIRECTORY
  297. Sets the directory for read-only data files used by the installed
  298. programs. The default is "DATAROOTDIR". Note that this has nothing
  299. to do with where your database files will be placed.
  300. --localedir=DIRECTORY
  301. Sets the directory for installing locale data, in particular message
  302. translation catalog files. The default is "DATAROOTDIR/locale".
  303. --mandir=DIRECTORY
  304. The man pages that come with PostgreSQL will be installed under this
  305. directory, in their respective "manx" subdirectories. The default is
  306. "DATAROOTDIR/man".
  307. --docdir=DIRECTORY
  308. Sets the root directory for installing documentation files, except
  309. "man" pages. This only sets the default for the following options.
  310. The default value for this option is "DATAROOTDIR/doc/postgresql".
  311. --htmldir=DIRECTORY
  312. The HTML-formatted documentation for PostgreSQL will be installed
  313. under this directory. The default is "DATAROOTDIR".
  314. Note:
  315. Care has been taken to make it possible to install PostgreSQL into
  316. shared installation locations (such as "/usr/local/include") without
  317. interfering with the namespace of the rest of the system. First, the
  318. string "/postgresql" is automatically appended to datadir, sysconfdir,
  319. and docdir, unless the fully expanded directory name already contains
  320. the string "postgres" or "pgsql". For example, if you choose
  321. "/usr/local" as prefix, the documentation will be installed in
  322. "/usr/local/doc/postgresql", but if the prefix is "/opt/postgres", then
  323. it will be in "/opt/postgres/doc". The public C header files of the
  324. client interfaces are installed into includedir and are namespace-clean.
  325. The internal header files and the server header files are installed into
  326. private directories under includedir. See the documentation of each
  327. interface for information about how to access its header files. Finally,
  328. a private subdirectory will also be created, if appropriate, under
  329. libdir for dynamically loadable modules.
  330. ------------------------------------------------------------------------
  331. PostgreSQL Features
  332. The options described in this section enable building of various
  333. PostgreSQL features that are not built by default. Most of these are
  334. non-default only because they require additional software, as described
  335. in the section called "Requirements".
  336. --enable-nls[=LANGUAGES]
  337. Enables Native Language Support (NLS), that is, the ability to
  338. display a program's messages in a language other than English.
  339. "LANGUAGES" is an optional space-separated list of codes of the
  340. languages that you want supported, for example --enable-nls='de fr'.
  341. (The intersection between your list and the set of actually provided
  342. translations will be computed automatically.) If you do not specify
  343. a list, then all available translations are installed.
  344. To use this option, you will need an implementation of the Gettext
  345. API.
  346. --with-perl
  347. Build the PL/Perl server-side language.
  348. --with-python
  349. Build the PL/Python server-side language.
  350. --with-tcl
  351. Build the PL/Tcl server-side language.
  352. --with-tclconfig=DIRECTORY
  353. Tcl installs the file "tclConfig.sh", which contains configuration
  354. information needed to build modules interfacing to Tcl. This file is
  355. normally found automatically at a well-known location, but if you
  356. want to use a different version of Tcl you can specify the directory
  357. in which to look for "tclConfig.sh".
  358. --with-icu
  359. Build with support for the ICU library, enabling use of ICU
  360. collation features. This requires the ICU4C package to be installed.
  361. The minimum required version of ICU4C is currently 4.2.
  362. By default, pkg-config will be used to find the required compilation
  363. options. This is supported for ICU4C version 4.6 and later. For
  364. older versions, or if pkg-config is not available, the variables
  365. ICU_CFLAGS and ICU_LIBS can be specified to "configure", like in
  366. this example:
  367. ./configure ... --with-icu ICU_CFLAGS='-I/some/where/include' ICU_LIBS='-L/some/where/lib -licui18n -licuuc -licudata'
  368. (If ICU4C is in the default search path for the compiler, then you
  369. still need to specify nonempty strings in order to avoid use of
  370. pkg-config, for example, ICU_CFLAGS=' '.)
  371. --with-llvm
  372. Build with support for LLVM based JIT compilation. This requires the
  373. LLVM library to be installed. The minimum required version of LLVM
  374. is currently 3.9.
  375. "llvm-config" will be used to find the required compilation options.
  376. "llvm-config", and then "llvm-config-$major-$minor" for all
  377. supported versions, will be searched for in your PATH. If that would
  378. not yield the desired program, use LLVM_CONFIG to specify a path to
  379. the correct "llvm-config". For example
  380. ./configure ... --with-llvm LLVM_CONFIG='/path/to/llvm/bin/llvm-config'
  381. LLVM support requires a compatible "clang" compiler (specified, if
  382. necessary, using the CLANG environment variable), and a working C++
  383. compiler (specified, if necessary, using the CXX environment
  384. variable).
  385. --with-lz4
  386. Build with LZ4 compression support. This allows the use of LZ4 for
  387. compression of table data.
  388. --with-ssl=LIBRARY
  389. Build with support for SSL (encrypted) connections. The only
  390. "LIBRARY" supported is "openssl". This requires the OpenSSL package
  391. to be installed. "configure" will check for the required header
  392. files and libraries to make sure that your OpenSSL installation is
  393. sufficient before proceeding.
  394. --with-openssl
  395. Obsolete equivalent of --with-ssl=openssl.
  396. --with-gssapi
  397. Build with support for GSSAPI authentication. On many systems, the
  398. GSSAPI system (usually a part of the Kerberos installation) is not
  399. installed in a location that is searched by default (e.g.,
  400. "/usr/include", "/usr/lib"), so you must use the options
  401. "--with-includes" and "--with-libraries" in addition to this option.
  402. "configure" will check for the required header files and libraries
  403. to make sure that your GSSAPI installation is sufficient before
  404. proceeding.
  405. --with-ldap
  406. Build with LDAP support for authentication and connection parameter
  407. lookup (see the documentation about client authentication and libpq
  408. for more information). On Unix, this requires the OpenLDAP package
  409. to be installed. On Windows, the default WinLDAP library is used.
  410. "configure" will check for the required header files and libraries
  411. to make sure that your OpenLDAP installation is sufficient before
  412. proceeding.
  413. --with-pam
  414. Build with PAM (Pluggable Authentication Modules) support.
  415. --with-bsd-auth
  416. Build with BSD Authentication support. (The BSD Authentication
  417. framework is currently only available on OpenBSD.)
  418. --with-systemd
  419. Build with support for systemd service notifications. This improves
  420. integration if the server is started under systemd but has no impact
  421. otherwise. libsystemd and the associated header files need to be
  422. installed to use this option.
  423. --with-bonjour
  424. Build with support for Bonjour automatic service discovery. This
  425. requires Bonjour support in your operating system. Recommended on
  426. macOS.
  427. --with-uuid=LIBRARY
  428. Build the uuid-ossp module (which provides functions to generate
  429. UUIDs), using the specified UUID library. "LIBRARY" must be one of:
  430. - "bsd" to use the UUID functions found in FreeBSD, NetBSD, and
  431. some other BSD-derived systems
  432. - "e2fs" to use the UUID library created by the e2fsprogs project;
  433. this library is present in most Linux systems and in macOS, and
  434. can be obtained for other platforms as well
  435. - "ossp" to use the OSSP UUID library
  436. --with-ossp-uuid
  437. Obsolete equivalent of --with-uuid=ossp.
  438. --with-libxml
  439. Build with libxml2, enabling SQL/XML support. Libxml2 version 2.6.23
  440. or later is required for this feature.
  441. To detect the required compiler and linker options, PostgreSQL will
  442. query "pkg-config", if that is installed and knows about libxml2.
  443. Otherwise the program "xml2-config", which is installed by libxml2,
  444. will be used if it is found. Use of "pkg-config" is preferred,
  445. because it can deal with multi-architecture installations better.
  446. To use a libxml2 installation that is in an unusual location, you
  447. can set "pkg-config"-related environment variables (see its
  448. documentation), or set the environment variable XML2_CONFIG to point
  449. to the "xml2-config" program belonging to the libxml2 installation,
  450. or set the variables XML2_CFLAGS and XML2_LIBS. (If "pkg-config" is
  451. installed, then to override its idea of where libxml2 is you must
  452. either set XML2_CONFIG or set both XML2_CFLAGS and XML2_LIBS to
  453. nonempty strings.)
  454. --with-libxslt
  455. Build with libxslt, enabling the xml2 module to perform XSL
  456. transformations of XML. "--with-libxml" must be specified as well.
  457. ------------------------------------------------------------------------
  458. Anti-Features
  459. The options described in this section allow disabling certain PostgreSQL
  460. features that are built by default, but which might need to be turned
  461. off if the required software or system features are not available. Using
  462. these options is not recommended unless really necessary.
  463. --without-readline
  464. Prevents use of the Readline library (and libedit as well). This
  465. option disables command-line editing and history in psql.
  466. --with-libedit-preferred
  467. Favors the use of the BSD-licensed libedit library rather than
  468. GPL-licensed Readline. This option is significant only if you have
  469. both libraries installed; the default in that case is to use
  470. Readline.
  471. --without-zlib
  472. Prevents use of the Zlib library. This disables support for
  473. compressed archives in pg_dump and pg_restore.
  474. --disable-spinlocks
  475. Allow the build to succeed even if PostgreSQL has no CPU spinlock
  476. support for the platform. The lack of spinlock support will result
  477. in very poor performance; therefore, this option should only be used
  478. if the build aborts and informs you that the platform lacks spinlock
  479. support. If this option is required to build PostgreSQL on your
  480. platform, please report the problem to the PostgreSQL developers.
  481. --disable-atomics
  482. Disable use of CPU atomic operations. This option does nothing on
  483. platforms that lack such operations. On platforms that do have them,
  484. this will result in poor performance. This option is only useful for
  485. debugging or making performance comparisons.
  486. --disable-thread-safety
  487. Disable the thread-safety of client libraries. This prevents
  488. concurrent threads in libpq and ECPG programs from safely
  489. controlling their private connection handles. Use this only on
  490. platforms with deficient threading support.
  491. ------------------------------------------------------------------------
  492. Build Process Details
  493. --with-includes=DIRECTORIES
  494. "DIRECTORIES" is a colon-separated list of directories that will be
  495. added to the list the compiler searches for header files. If you
  496. have optional packages (such as GNU Readline) installed in a
  497. non-standard location, you have to use this option and probably also
  498. the corresponding "--with-libraries" option.
  499. Example: --with-includes=/opt/gnu/include:/usr/sup/include.
  500. --with-libraries=DIRECTORIES
  501. "DIRECTORIES" is a colon-separated list of directories to search for
  502. libraries. You will probably have to use this option (and the
  503. corresponding "--with-includes" option) if you have packages
  504. installed in non-standard locations.
  505. Example: --with-libraries=/opt/gnu/lib:/usr/sup/lib.
  506. --with-system-tzdata=DIRECTORY
  507. PostgreSQL includes its own time zone database, which it requires
  508. for date and time operations. This time zone database is in fact
  509. compatible with the IANA time zone database provided by many
  510. operating systems such as FreeBSD, Linux, and Solaris, so it would
  511. be redundant to install it again. When this option is used, the
  512. system-supplied time zone database in "DIRECTORY" is used instead of
  513. the one included in the PostgreSQL source distribution. "DIRECTORY"
  514. must be specified as an absolute path. "/usr/share/zoneinfo" is a
  515. likely directory on some operating systems. Note that the
  516. installation routine will not detect mismatching or erroneous time
  517. zone data. If you use this option, you are advised to run the
  518. regression tests to verify that the time zone data you have pointed
  519. to works correctly with PostgreSQL.
  520. This option is mainly aimed at binary package distributors who know
  521. their target operating system well. The main advantage of using this
  522. option is that the PostgreSQL package won't need to be upgraded
  523. whenever any of the many local daylight-saving time rules change.
  524. Another advantage is that PostgreSQL can be cross-compiled more
  525. straightforwardly if the time zone database files do not need to be
  526. built during the installation.
  527. --with-extra-version=STRING
  528. Append "STRING" to the PostgreSQL version number. You can use this,
  529. for example, to mark binaries built from unreleased Git snapshots or
  530. containing custom patches with an extra version string, such as a
  531. "git describe" identifier or a distribution package release number.
  532. --disable-rpath
  533. Do not mark PostgreSQL's executables to indicate that they should
  534. search for shared libraries in the installation's library directory
  535. (see "--libdir"). On most platforms, this marking uses an absolute
  536. path to the library directory, so that it will be unhelpful if you
  537. relocate the installation later. However, you will then need to
  538. provide some other way for the executables to find the shared
  539. libraries. Typically this requires configuring the operating
  540. system's dynamic linker to search the library directory; see the
  541. section called "Shared Libraries" for more detail.
  542. ------------------------------------------------------------------------
  543. Miscellaneous
  544. It's fairly common, particularly for test builds, to adjust the default
  545. port number with "--with-pgport". The other options in this section are
  546. recommended only for advanced users.
  547. --with-pgport=NUMBER
  548. Set "NUMBER" as the default port number for server and clients. The
  549. default is 5432. The port can always be changed later on, but if you
  550. specify it here then both server and clients will have the same
  551. default compiled in, which can be very convenient. Usually the only
  552. good reason to select a non-default value is if you intend to run
  553. multiple PostgreSQL servers on the same machine.
  554. --with-krb-srvnam=NAME
  555. The default name of the Kerberos service principal used by GSSAPI.
  556. postgres is the default. There's usually no reason to change this
  557. unless you are building for a Windows environment, in which case it
  558. must be set to upper case POSTGRES.
  559. --with-segsize=SEGSIZE
  560. Set the segment size, in gigabytes. Large tables are divided into
  561. multiple operating-system files, each of size equal to the segment
  562. size. This avoids problems with file size limits that exist on many
  563. platforms. The default segment size, 1 gigabyte, is safe on all
  564. supported platforms. If your operating system has "largefile"
  565. support (which most do, nowadays), you can use a larger segment
  566. size. This can be helpful to reduce the number of file descriptors
  567. consumed when working with very large tables. But be careful not to
  568. select a value larger than is supported by your platform and the
  569. file systems you intend to use. Other tools you might wish to use,
  570. such as tar, could also set limits on the usable file size. It is
  571. recommended, though not absolutely required, that this value be a
  572. power of 2. Note that changing this value breaks on-disk database
  573. compatibility, meaning you cannot use "pg_upgrade" to upgrade to a
  574. build with a different segment size.
  575. --with-blocksize=BLOCKSIZE
  576. Set the block size, in kilobytes. This is the unit of storage and
  577. I/O within tables. The default, 8 kilobytes, is suitable for most
  578. situations; but other values may be useful in special cases. The
  579. value must be a power of 2 between 1 and 32 (kilobytes). Note that
  580. changing this value breaks on-disk database compatibility, meaning
  581. you cannot use "pg_upgrade" to upgrade to a build with a different
  582. block size.
  583. --with-wal-blocksize=BLOCKSIZE
  584. Set the WAL block size, in kilobytes. This is the unit of storage
  585. and I/O within the WAL log. The default, 8 kilobytes, is suitable
  586. for most situations; but other values may be useful in special
  587. cases. The value must be a power of 2 between 1 and 64 (kilobytes).
  588. Note that changing this value breaks on-disk database compatibility,
  589. meaning you cannot use "pg_upgrade" to upgrade to a build with a
  590. different WAL block size.
  591. ------------------------------------------------------------------------
  592. Developer Options
  593. Most of the options in this section are only of interest for developing
  594. or debugging PostgreSQL. They are not recommended for production builds,
  595. except for "--enable-debug", which can be useful to enable detailed bug
  596. reports in the unlucky event that you encounter a bug. On platforms
  597. supporting DTrace, "--enable-dtrace" may also be reasonable to use in
  598. production.
  599. When building an installation that will be used to develop code inside
  600. the server, it is recommended to use at least the options
  601. "--enable-debug" and "--enable-cassert".
  602. --enable-debug
  603. Compiles all programs and libraries with debugging symbols. This
  604. means that you can run the programs in a debugger to analyze
  605. problems. This enlarges the size of the installed executables
  606. considerably, and on non-GCC compilers it usually also disables
  607. compiler optimization, causing slowdowns. However, having the
  608. symbols available is extremely helpful for dealing with any problems
  609. that might arise. Currently, this option is recommended for
  610. production installations only if you use GCC. But you should always
  611. have it on if you are doing development work or running a beta
  612. version.
  613. --enable-cassert
  614. Enables assertion checks in the server, which test for many "cannot
  615. happen" conditions. This is invaluable for code development
  616. purposes, but the tests can slow down the server significantly.
  617. Also, having the tests turned on won't necessarily enhance the
  618. stability of your server! The assertion checks are not categorized
  619. for severity, and so what might be a relatively harmless bug will
  620. still lead to server restarts if it triggers an assertion failure.
  621. This option is not recommended for production use, but you should
  622. have it on for development work or when running a beta version.
  623. --enable-tap-tests
  624. Enable tests using the Perl TAP tools. This requires a Perl
  625. installation and the Perl module IPC::Run.
  626. --enable-depend
  627. Enables automatic dependency tracking. With this option, the
  628. makefiles are set up so that all affected object files will be
  629. rebuilt when any header file is changed. This is useful if you are
  630. doing development work, but is just wasted overhead if you intend
  631. only to compile once and install. At present, this option only works
  632. with GCC.
  633. --enable-coverage
  634. If using GCC, all programs and libraries are compiled with code
  635. coverage testing instrumentation. When run, they generate files in
  636. the build directory with code coverage metrics. This option is for
  637. use only with GCC and when doing development work.
  638. --enable-profiling
  639. If using GCC, all programs and libraries are compiled so they can be
  640. profiled. On backend exit, a subdirectory will be created that
  641. contains the "gmon.out" file containing profile data. This option is
  642. for use only with GCC and when doing development work.
  643. --enable-dtrace
  644. Compiles PostgreSQL with support for the dynamic tracing tool
  645. DTrace.
  646. To point to the "dtrace" program, the environment variable DTRACE
  647. can be set. This will often be necessary because "dtrace" is
  648. typically installed under "/usr/sbin", which might not be in your
  649. PATH.
  650. Extra command-line options for the "dtrace" program can be specified
  651. in the environment variable DTRACEFLAGS. On Solaris, to include
  652. DTrace support in a 64-bit binary, you must specify
  653. DTRACEFLAGS="-64". For example, using the GCC compiler:
  654. ./configure CC='gcc -m64' --enable-dtrace DTRACEFLAGS='-64' ...
  655. Using Sun's compiler:
  656. ./configure CC='/opt/SUNWspro/bin/cc -xtarget=native64' --enable-dtrace DTRACEFLAGS='-64' ...
  657. ------------------------------------------------------------------------
  658. configure Environment Variables
  659. In addition to the ordinary command-line options described above,
  660. "configure" responds to a number of environment variables. You can
  661. specify environment variables on the "configure" command line, for
  662. example:
  663. ./configure CC=/opt/bin/gcc CFLAGS='-O2 -pipe'
  664. In this usage an environment variable is little different from a
  665. command-line option. You can also set such variables beforehand:
  666. export CC=/opt/bin/gcc
  667. export CFLAGS='-O2 -pipe'
  668. ./configure
  669. This usage can be convenient because many programs' configuration
  670. scripts respond to these variables in similar ways.
  671. The most commonly used of these environment variables are CC and CFLAGS.
  672. If you prefer a C compiler different from the one "configure" picks, you
  673. can set the variable CC to the program of your choice. By default,
  674. "configure" will pick "gcc" if available, else the platform's default
  675. (usually "cc"). Similarly, you can override the default compiler flags
  676. if needed with the CFLAGS variable.
  677. Here is a list of the significant variables that can be set in this
  678. manner:
  679. BISON
  680. Bison program
  681. CC
  682. C compiler
  683. CFLAGS
  684. options to pass to the C compiler
  685. CLANG
  686. path to "clang" program used to process source code for inlining
  687. when compiling with --with-llvm
  688. CPP
  689. C preprocessor
  690. CPPFLAGS
  691. options to pass to the C preprocessor
  692. CXX
  693. C++ compiler
  694. CXXFLAGS
  695. options to pass to the C++ compiler
  696. DTRACE
  697. location of the "dtrace" program
  698. DTRACEFLAGS
  699. options to pass to the "dtrace" program
  700. FLEX
  701. Flex program
  702. LDFLAGS
  703. options to use when linking either executables or shared libraries
  704. LDFLAGS_EX
  705. additional options for linking executables only
  706. LDFLAGS_SL
  707. additional options for linking shared libraries only
  708. LLVM_CONFIG
  709. "llvm-config" program used to locate the LLVM installation
  710. MSGFMT
  711. "msgfmt" program for native language support
  712. PERL
  713. Perl interpreter program. This will be used to determine the
  714. dependencies for building PL/Perl. The default is "perl".
  715. PYTHON
  716. Python interpreter program. This will be used to determine the
  717. dependencies for building PL/Python. Also, whether Python 2 or 3 is
  718. specified here (or otherwise implicitly chosen) determines which
  719. variant of the PL/Python language becomes available. See the
  720. PL/Python documentation for more information. If this is not set,
  721. the following are probed in this order: python python3 python2.
  722. TCLSH
  723. Tcl interpreter program. This will be used to determine the
  724. dependencies for building PL/Tcl. If this is not set, the following
  725. are probed in this order:
  726. tclsh tcl tclsh8.6 tclsh86 tclsh8.5 tclsh85 tclsh8.4 tclsh84.
  727. XML2_CONFIG
  728. "xml2-config" program used to locate the libxml2 installation
  729. Sometimes it is useful to add compiler flags after-the-fact to the set
  730. that were chosen by "configure". An important example is that gcc's
  731. "-Werror" option cannot be included in the CFLAGS passed to "configure",
  732. because it will break many of "configure"'s built-in tests. To add such
  733. flags, include them in the COPT environment variable while running
  734. "make". The contents of COPT are added to both the CFLAGS and LDFLAGS
  735. options set up by "configure". For example, you could do
  736. make COPT='-Werror'
  737. or
  738. export COPT='-Werror'
  739. make
  740. Note:
  741. If using GCC, it is best to build with an optimization level of at least
  742. "-O1", because using no optimization ("-O0") disables some important
  743. compiler warnings (such as the use of uninitialized variables). However,
  744. non-zero optimization levels can complicate debugging because stepping
  745. through compiled code will usually not match up one-to-one with source
  746. code lines. If you get confused while trying to debug optimized code,
  747. recompile the specific files of interest with "-O0". An easy way to do
  748. this is by passing an option to make: "make PROFILE=-O0 file.o".
  749. The COPT and PROFILE environment variables are actually handled
  750. identically by the PostgreSQL makefiles. Which to use is a matter of
  751. preference, but a common habit among developers is to use PROFILE for
  752. one-time flag adjustments, while COPT might be kept set all the time.
  753. ------------------------------------------------------------------------
  754. Post-Installation Setup
  755. ------------------------------------------------------------------------
  756. Shared Libraries
  757. On some systems with shared libraries you need to tell the system how to
  758. find the newly installed shared libraries. The systems on which this is
  759. *not* necessary include FreeBSD, HP-UX, Linux, NetBSD, OpenBSD, and
  760. Solaris.
  761. The method to set the shared library search path varies between
  762. platforms, but the most widely-used method is to set the environment
  763. variable LD_LIBRARY_PATH like so: In Bourne shells ("sh", "ksh", "bash",
  764. "zsh"):
  765. LD_LIBRARY_PATH=/usr/local/pgsql/lib
  766. export LD_LIBRARY_PATH
  767. or in "csh" or "tcsh":
  768. setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
  769. Replace /usr/local/pgsql/lib with whatever you set "--libdir" to in Step
  770. 1. You should put these commands into a shell start-up file such as
  771. "/etc/profile" or "~/.bash_profile". Some good information about the
  772. caveats associated with this method can be found at
  773. http://xahlee.info/UnixResource_dir/_/ldpath.html.
  774. On some systems it might be preferable to set the environment variable
  775. LD_RUN_PATH *before* building.
  776. On Cygwin, put the library directory in the PATH or move the ".dll"
  777. files into the "bin" directory.
  778. If in doubt, refer to the manual pages of your system (perhaps "ld.so"
  779. or "rld"). If you later get a message like:
  780. psql: error in loading shared libraries
  781. libpq.so.2.1: cannot open shared object file: No such file or directory
  782. then this step was necessary. Simply take care of it then.
  783. If you are on Linux and you have root access, you can run:
  784. /sbin/ldconfig /usr/local/pgsql/lib
  785. (or equivalent directory) after installation to enable the run-time
  786. linker to find the shared libraries faster. Refer to the manual page of
  787. "ldconfig" for more information. On FreeBSD, NetBSD, and OpenBSD the
  788. command is:
  789. /sbin/ldconfig -m /usr/local/pgsql/lib
  790. instead. Other systems are not known to have an equivalent command.
  791. ------------------------------------------------------------------------
  792. Environment Variables
  793. If you installed into "/usr/local/pgsql" or some other location that is
  794. not searched for programs by default, you should add
  795. "/usr/local/pgsql/bin" (or whatever you set "--bindir" to in Step 1)
  796. into your PATH. Strictly speaking, this is not necessary, but it will
  797. make the use of PostgreSQL much more convenient.
  798. To do this, add the following to your shell start-up file, such as
  799. "~/.bash_profile" (or "/etc/profile", if you want it to affect all
  800. users):
  801. PATH=/usr/local/pgsql/bin:$PATH
  802. export PATH
  803. If you are using "csh" or "tcsh", then use this command:
  804. set path = ( /usr/local/pgsql/bin $path )
  805. To enable your system to find the man documentation, you need to add
  806. lines like the following to a shell start-up file unless you installed
  807. into a location that is searched by default:
  808. MANPATH=/usr/local/pgsql/share/man:$MANPATH
  809. export MANPATH
  810. The environment variables PGHOST and PGPORT specify to client
  811. applications the host and port of the database server, overriding the
  812. compiled-in defaults. If you are going to run client applications
  813. remotely then it is convenient if every user that plans to use the
  814. database sets PGHOST. This is not required, however; the settings can be
  815. communicated via command line options to most client programs.
  816. ------------------------------------------------------------------------
  817. Getting Started
  818. The following is a quick summary of how to get PostgreSQL up and running
  819. once installed. The main documentation contains more information.
  820. 1. Create a user account for the PostgreSQL server. This is the user
  821. the server will run as. For production use you should create a
  822. separate, unprivileged account ("postgres" is commonly used). If you
  823. do not have root access or just want to play around, your own user
  824. account is enough, but running the server as root is a security risk
  825. and will not work.
  826. adduser postgres
  827. 2. Create a database installation with the "initdb" command. To run
  828. "initdb" you must be logged in to your PostgreSQL server account. It
  829. will not work as root.
  830. root# mkdir /usr/local/pgsql/data
  831. root# chown postgres /usr/local/pgsql/data
  832. root# su - postgres
  833. postgres$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
  834. The "-D" option specifies the location where the data will be
  835. stored. You can use any path you want, it does not have to be under
  836. the installation directory. Just make sure that the server account
  837. can write to the directory (or create it, if it doesn't already
  838. exist) before starting "initdb", as illustrated here.
  839. 3. At this point, if you did not use the "initdb" -A option, you might
  840. want to modify "pg_hba.conf" to control local access to the server
  841. before you start it. The default is to trust all local users.
  842. 4. The previous "initdb" step should have told you how to start up the
  843. database server. Do so now. The command should look something like:
  844. /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start
  845. To stop a server running in the background you can type:
  846. /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data stop
  847. 5. Create a database:
  848. /usr/local/pgsql/bin/createdb testdb
  849. Then enter:
  850. /usr/local/pgsql/bin/psql testdb
  851. to connect to that database. At the prompt you can enter SQL
  852. commands and start experimenting.
  853. ------------------------------------------------------------------------
  854. What Now?
  855. - The PostgreSQL distribution contains a comprehensive documentation
  856. set, which you should read sometime. After installation, the
  857. documentation can be accessed by pointing your browser to
  858. "/usr/local/pgsql/doc/html/index.html", unless you changed the
  859. installation directories.
  860. The first few chapters of the main documentation are the Tutorial,
  861. which should be your first reading if you are completely new to SQL
  862. databases. If you are familiar with database concepts then you want
  863. to proceed with part on server administration, which contains
  864. information about how to set up the database server, database users,
  865. and authentication.
  866. - Usually, you will want to modify your computer so that it will
  867. automatically start the database server whenever it boots. Some
  868. suggestions for this are in the documentation.
  869. - Run the regression tests against the installed server (using "make
  870. installcheck"). If you didn't run the tests before installation, you
  871. should definitely do it now. This is also explained in the
  872. documentation.
  873. - By default, PostgreSQL is configured to run on minimal hardware.
  874. This allows it to start up with almost any hardware configuration.
  875. The default configuration is, however, not designed for optimum
  876. performance. To achieve optimum performance, several server
  877. parameters must be adjusted, the two most common being
  878. shared_buffers and work_mem. Other parameters mentioned in the
  879. documentation also affect performance.
  880. ------------------------------------------------------------------------
  881. Supported Platforms
  882. A platform (that is, a CPU architecture and operating system
  883. combination) is considered supported by the PostgreSQL development
  884. community if the code contains provisions to work on that platform and
  885. it has recently been verified to build and pass its regression tests on
  886. that platform. Currently, most testing of platform compatibility is done
  887. automatically by test machines in the PostgreSQL Build Farm. If you are
  888. interested in using PostgreSQL on a platform that is not represented in
  889. the build farm, but on which the code works or can be made to work, you
  890. are strongly encouraged to set up a build farm member machine so that
  891. continued compatibility can be assured.
  892. In general, PostgreSQL can be expected to work on these CPU
  893. architectures: x86, x86_64, IA64, PowerPC, PowerPC 64, S/390, S/390x,
  894. Sparc, Sparc 64, ARM, MIPS, MIPSEL, and PA-RISC. Code support exists for
  895. M68K, M32R, and VAX, but these architectures are not known to have been
  896. tested recently. It is often possible to build on an unsupported CPU
  897. type by configuring with "--disable-spinlocks", but performance will be
  898. poor.
  899. PostgreSQL can be expected to work on these operating systems: Linux
  900. (all recent distributions), Windows (XP and later), FreeBSD, OpenBSD,
  901. NetBSD, macOS, AIX, HP/UX, and Solaris. Other Unix-like systems may also
  902. work but are not currently being tested. In most cases, all CPU
  903. architectures supported by a given operating system will work. Look in
  904. the section called "Platform-Specific Notes" below to see if there is
  905. information specific to your operating system, particularly if using an
  906. older system.
  907. If you have installation problems on a platform that is known to be
  908. supported according to recent build farm results, please report it to
  909. <pgsql-bugs@lists.postgresql.org>. If you are interested in porting
  910. PostgreSQL to a new platform, <pgsql-hackers@lists.postgresql.org> is
  911. the appropriate place to discuss that.
  912. ------------------------------------------------------------------------
  913. Platform-Specific Notes
  914. This section documents additional platform-specific issues regarding the
  915. installation and setup of PostgreSQL. Be sure to read the installation
  916. instructions, and in particular the section called "Requirements" as
  917. well. Also, check the file "src/test/regress/README" and the
  918. documentation regarding the interpretation of regression test results.
  919. Platforms that are not covered here have no known platform-specific
  920. installation issues.
  921. ------------------------------------------------------------------------
  922. AIX
  923. PostgreSQL works on AIX, but AIX versions before about 6.1 have various
  924. issues and are not recommended. You can use GCC or the native IBM
  925. compiler "xlc".
  926. ------------------------------------------------------------------------
  927. Memory Management
  928. AIX can be somewhat peculiar with regards to the way it does memory
  929. management. You can have a server with many multiples of gigabytes of
  930. RAM free, but still get out of memory or address space errors when
  931. running applications. One example is loading of extensions failing with
  932. unusual errors. For example, running as the owner of the PostgreSQL
  933. installation:
  934. =# CREATE EXTENSION plperl;
  935. ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": A memory address is not in the address space for the process.
  936. Running as a non-owner in the group possessing the PostgreSQL
  937. installation:
  938. =# CREATE EXTENSION plperl;
  939. ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
  940. Another example is out of memory errors in the PostgreSQL server logs,
  941. with every memory allocation near or greater than 256 MB failing.
  942. The overall cause of all these problems is the default bittedness and
  943. memory model used by the server process. By default, all binaries built
  944. on AIX are 32-bit. This does not depend upon hardware type or kernel in
  945. use. These 32-bit processes are limited to 4 GB of memory laid out in
  946. 256 MB segments using one of a few models. The default allows for less
  947. than 256 MB in the heap as it shares a single segment with the stack.
  948. In the case of the plperl example, above, check your umask and the
  949. permissions of the binaries in your PostgreSQL installation. The
  950. binaries involved in that example were 32-bit and installed as mode 750
  951. instead of 755. Due to the permissions being set in this fashion, only
  952. the owner or a member of the possessing group can load the library.
  953. Since it isn't world-readable, the loader places the object into the
  954. process' heap instead of the shared library segments where it would
  955. otherwise be placed.
  956. The "ideal" solution for this is to use a 64-bit build of PostgreSQL,
  957. but that is not always practical, because systems with 32-bit processors
  958. can build, but not run, 64-bit binaries.
  959. If a 32-bit binary is desired, set LDR_CNTRL to MAXDATA=0xn0000000,
  960. where 1 <= n <= 8, before starting the PostgreSQL server, and try
  961. different values and "postgresql.conf" settings to find a configuration
  962. that works satisfactorily. This use of LDR_CNTRL tells AIX that you want
  963. the server to have MAXDATA bytes set aside for the heap, allocated in
  964. 256 MB segments. When you find a workable configuration, "ldedit" can be
  965. used to modify the binaries so that they default to using the desired
  966. heap size. PostgreSQL can also be rebuilt, passing
  967. configure LDFLAGS="-Wl,-bmaxdata:0xn0000000" to achieve the same
  968. effect.
  969. For a 64-bit build, set OBJECT_MODE to 64 and pass CC="gcc -maix64" and
  970. LDFLAGS="-Wl,-bbigtoc" to "configure". (Options for "xlc" might differ.)
  971. If you omit the export of OBJECT_MODE, your build may fail with linker
  972. errors. When OBJECT_MODE is set, it tells AIX's build utilities such as
  973. "ar", "as", and "ld" what type of objects to default to handling.
  974. By default, overcommit of paging space can happen. While we have not
  975. seen this occur, AIX will kill processes when it runs out of memory and
  976. the overcommit is accessed. The closest to this that we have seen is
  977. fork failing because the system decided that there was not enough memory
  978. for another process. Like many other parts of AIX, the paging space
  979. allocation method and out-of-memory kill is configurable on a system- or
  980. process-wide basis if this becomes a problem.
  981. ------------------------------------------------------------------------
  982. Cygwin
  983. PostgreSQL can be built using Cygwin, a Linux-like environment for
  984. Windows, but that method is inferior to the native Windows build and
  985. running a server under Cygwin is no longer recommended.
  986. When building from source, proceed according to the Unix-style
  987. installation procedure (i.e., ./configure; make; etc.), noting the
  988. following Cygwin-specific differences:
  989. - Set your path to use the Cygwin bin directory before the Windows
  990. utilities. This will help prevent problems with compilation.
  991. - The "adduser" command is not supported; use the appropriate user
  992. management application on Windows NT, 2000, or XP. Otherwise, skip
  993. this step.
  994. - The "su" command is not supported; use ssh to simulate su on Windows
  995. NT, 2000, or XP. Otherwise, skip this step.
  996. - OpenSSL is not supported.
  997. - Start "cygserver" for shared memory support. To do this, enter the
  998. command /usr/sbin/cygserver &. This program needs to be
  999. running anytime you start the PostgreSQL server or initialize a
  1000. database cluster ("initdb"). The default "cygserver" configuration
  1001. may need to be changed (e.g., increase SEMMNS) to prevent PostgreSQL
  1002. from failing due to a lack of system resources.
  1003. - Building might fail on some systems where a locale other than C is
  1004. in use. To fix this, set the locale to C by doing "export
  1005. LANG=C.utf8" before building, and then setting it back to the
  1006. previous setting after you have installed PostgreSQL.
  1007. - The parallel regression tests (make check) can generate spurious
  1008. regression test failures due to overflowing the listen() backlog
  1009. queue which causes connection refused errors or hangs. You can limit
  1010. the number of connections using the make variable MAX_CONNECTIONS
  1011. thus:
  1012. make MAX_CONNECTIONS=5 check
  1013. (On some systems you can have up to about 10 simultaneous
  1014. connections.)
  1015. It is possible to install "cygserver" and the PostgreSQL server as
  1016. Windows NT services. For information on how to do this, please refer to
  1017. the "README" document included with the PostgreSQL binary package on
  1018. Cygwin. It is installed in the directory "/usr/share/doc/Cygwin".
  1019. ------------------------------------------------------------------------
  1020. macOS
  1021. To build PostgreSQL from source on macOS, you will need to install
  1022. Apple's command line developer tools, which can be done by issuing
  1023. xcode-select --install
  1024. (note that this will pop up a GUI dialog window for confirmation). You
  1025. may or may not wish to also install Xcode.
  1026. On recent macOS releases, it's necessary to embed the "sysroot" path in
  1027. the include switches used to find some system header files. This results
  1028. in the outputs of the configure script varying depending on which SDK
  1029. version was used during configure. That shouldn't pose any problem in
  1030. simple scenarios, but if you are trying to do something like building an
  1031. extension on a different machine than the server code was built on, you
  1032. may need to force use of a different sysroot path. To do that, set
  1033. PG_SYSROOT, for example
  1034. make PG_SYSROOT=/desired/path all
  1035. To find out the appropriate path on your machine, run
  1036. xcrun --show-sdk-path
  1037. Note that building an extension using a different sysroot version than
  1038. was used to build the core server is not really recommended; in the
  1039. worst case it could result in hard-to-debug ABI inconsistencies.
  1040. You can also select a non-default sysroot path when configuring, by
  1041. specifying PG_SYSROOT to configure:
  1042. ./configure ... PG_SYSROOT=/desired/path
  1043. This would primarily be useful to cross-compile for some other macOS
  1044. version. There is no guarantee that the resulting executables will run
  1045. on the current host.
  1046. To suppress the "-isysroot" options altogether, use
  1047. ./configure ... PG_SYSROOT=none
  1048. (any nonexistent pathname will work). This might be useful if you wish
  1049. to build with a non-Apple compiler, but beware that that case is not
  1050. tested or supported by the PostgreSQL developers.
  1051. macOS's "System Integrity Protection" (SIP) feature breaks make check,
  1052. because it prevents passing the needed setting of DYLD_LIBRARY_PATH down
  1053. to the executables being tested. You can work around that by doing
  1054. make install before make check. Most PostgreSQL developers just turn
  1055. off SIP, though.
  1056. ------------------------------------------------------------------------
  1057. MinGW/Native Windows
  1058. PostgreSQL for Windows can be built using MinGW, a Unix-like build
  1059. environment for Microsoft operating systems, or using Microsoft's Visual
  1060. C++ compiler suite. The MinGW build procedure uses the normal build
  1061. system described in this chapter; the Visual C++ build works completely
  1062. differently and is described in the documentation.
  1063. The native Windows port requires a 32 or 64-bit version of Windows 2000
  1064. or later. Earlier operating systems do not have sufficient
  1065. infrastructure (but Cygwin may be used on those). MinGW, the Unix-like
  1066. build tools, and MSYS, a collection of Unix tools required to run shell
  1067. scripts like "configure", can be downloaded from http://www.mingw.org/.
  1068. Neither is required to run the resulting binaries; they are needed only
  1069. for creating the binaries.
  1070. To build 64 bit binaries using MinGW, install the 64 bit tool set from
  1071. https://mingw-w64.org/, put its bin directory in the PATH, and run
  1072. "configure" with the "--host=x86_64-w64-mingw32" option.
  1073. After you have everything installed, it is suggested that you run psql
  1074. under "CMD.EXE", as the MSYS console has buffering issues.
  1075. ------------------------------------------------------------------------
  1076. Collecting Crash Dumps on Windows
  1077. If PostgreSQL on Windows crashes, it has the ability to generate
  1078. minidumps that can be used to track down the cause for the crash,
  1079. similar to core dumps on Unix. These dumps can be read using the Windows
  1080. Debugger Tools or using Visual Studio. To enable the generation of dumps
  1081. on Windows, create a subdirectory named "crashdumps" inside the cluster
  1082. data directory. The dumps will then be written into this directory with
  1083. a unique name based on the identifier of the crashing process and the
  1084. current time of the crash.
  1085. ------------------------------------------------------------------------
  1086. Solaris
  1087. PostgreSQL is well-supported on Solaris. The more up to date your
  1088. operating system, the fewer issues you will experience.
  1089. ------------------------------------------------------------------------
  1090. Required Tools
  1091. You can build with either GCC or Sun's compiler suite. For better code
  1092. optimization, Sun's compiler is strongly recommended on the SPARC
  1093. architecture. If you are using Sun's compiler, be careful not to select
  1094. "/usr/ucb/cc"; use "/opt/SUNWspro/bin/cc".
  1095. You can download Sun Studio from
  1096. https://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/.
  1097. Many GNU tools are integrated into Solaris 10, or they are present on
  1098. the Solaris companion CD. If you need packages for older versions of
  1099. Solaris, you can find these tools at http://www.sunfreeware.com. If you
  1100. prefer sources, look at https://www.gnu.org/prep/ftp.
  1101. ------------------------------------------------------------------------
  1102. configure Complains About a Failed Test Program
  1103. If "configure" complains about a failed test program, this is probably a
  1104. case of the run-time linker being unable to find some library, probably
  1105. libz, libreadline or some other non-standard library such as libssl. To
  1106. point it to the right location, set the LDFLAGS environment variable on
  1107. the "configure" command line, e.g.,
  1108. configure ... LDFLAGS="-R /usr/sfw/lib:/opt/sfw/lib:/usr/local/lib"
  1109. See the ld man page for more information.
  1110. ------------------------------------------------------------------------
  1111. Compiling for Optimal Performance
  1112. On the SPARC architecture, Sun Studio is strongly recommended for
  1113. compilation. Try using the "-xO5" optimization flag to generate
  1114. significantly faster binaries. Do not use any flags that modify behavior
  1115. of floating-point operations and errno processing (e.g., "-fast").
  1116. If you do not have a reason to use 64-bit binaries on SPARC, prefer the
  1117. 32-bit version. The 64-bit operations are slower and 64-bit binaries are
  1118. slower than the 32-bit variants. On the other hand, 32-bit code on the
  1119. AMD64 CPU family is not native, so 32-bit code is significantly slower
  1120. on that CPU family.
  1121. ------------------------------------------------------------------------
  1122. Using DTrace for Tracing PostgreSQL
  1123. Yes, using DTrace is possible. See the documentation for further
  1124. information.
  1125. If you see the linking of the "postgres" executable abort with an error
  1126. message like:
  1127. Undefined first referenced
  1128. symbol in file
  1129. AbortTransaction utils/probes.o
  1130. CommitTransaction utils/probes.o
  1131. ld: fatal: Symbol referencing errors. No output written to postgres
  1132. collect2: ld returned 1 exit status
  1133. make: *** [postgres] Error 1
  1134. your DTrace installation is too old to handle probes in static
  1135. functions. You need Solaris 10u4 or newer to use DTrace.