PostgreSQL学习笔记(一) ubuntu 16.4 源码安装 PostgreSQL 10


apt install gcc zlib1g-dev libreadline6-dev


wget -c


tar -xvf postgresql-10.0.tar.bz2


cd postgresql-10.0


root@buddy-yuan:/tmp/postgresql-10.0# ./configure --help
`configure' configures PostgreSQL 10.0 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.

-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
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX

root@buddy-yuan:/tmp/postgresql-10.0# mkdir /opt/PostgreSQL-10
root@buddy-yuan:/tmp/postgresql-10.0# ./configure --prefix=/opt/PostgreSQL-10/

configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/backend/port/dynloader/linux.h to src/include/dynloader.h
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port


make install

make[1]: Entering directory '/tmp/postgresql-10.0/config'
/bin/mkdir -p '/opt/PostgreSQL-10/lib/postgresql/pgxs/config'
/usr/bin/install -c -m 755 ./install-sh '/opt/PostgreSQL-10/lib/postgresql/pgxs/config/install-sh'
/usr/bin/install -c -m 755 ./missing '/opt/PostgreSQL-10/lib/postgresql/pgxs/config/missing'
make[1]: Leaving directory '/tmp/postgresql-10.0/config'
PostgreSQL installation complete.


root@buddy-yuan:/tmp/postgresql-10.0# useradd -d /home/postgres postgres
root@buddy-yuan:/tmp/postgresql-10.0# passwd postgres

root@buddy-yuan:/tmp/postgresql-10.0# mkdir /pgdata
root@buddy-yuan:/tmp/postgresql-10.0# mkdir -p /pgdata/data
root@buddy-yuan:/tmp/postgresql-10.0# chown -R postgres. /pgdata/data/

echo 'export PATH=$PATH:/opt/PostgreSQL-10/bin' > /etc/profile.d/


$ initdb -D /pgdata/data/ -U postgres -W
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "zh_CN.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple".

Data page checksums are disabled.

Enter new superuser password:
Enter it again:

fixing permissions on existing directory /pgdata/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

pg_ctl -D /pgdata/data/ -l logfile start


listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)

$ mkdir -p /pgdata/data/logs
$ pg_ctl -D /pgdata/data/ -l /pgdata/data/logs/start.log start
waiting for server to start.... done
server started


$ psql -p 5432
psql (10.0)
Type "help" for help.

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
postgres | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 |
template0 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
分享到: 更多

Post a Comment

Your email is never published nor shared. Required fields are marked *