PostGresql安装实测过程(Linux)
一、数据库介质下载:并上传,解压到linux服务器上。
二、具体安装步骤(具体安装步骤可以查看安全介质中的INSTALL文件):
1)创建安装目录:
[root@PostGres /]#mkdir -p /pg94
2)执行脚本安装(在root用户下执行)。
[root@PostGres /]# cd /root/postgresql-9.4.0
[root@PostGres postgresql-9.4.0]# ./configure --prefix=/pg94-----安装过程中可能会缺少动态库,可以用yum search 、yum install 来安装。
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc supports -Wdeclaration-after-statement... yes
checking whether gcc supports -Wendif-labels... yes
checking for perl... /usr/bin/perl
configure: using perl 5.10.1
... ...
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/backend/port/unix_latch.c to src/backend/port/pg_latch.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
[root@PostGres postgresql-9.4.0]# make
... ...
make -C config all
make[1]: Entering directory `/root/postgresql-9.4.0/config'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/postgresql-9.4.0/config'
All of PostgreSQL successfully made. Ready to install.
[root@PostGres postgresql-9.4.0]# su[root@PostGres postgresql-9.4.0]# make install ... ...
make -C config install
make[1]: Entering directory `/root/postgresql-9.4.0/config'
/bin/mkdir -p '/pg9/lib/postgresql/pgxs/config'
/usr/bin/install -c -m 755 ./install-sh '/pg9/lib/postgresql/pgxs/config/install-sh'
make[1]: Leaving directory `/root/postgresql-9.4.0/config'
PostgreSQL installation complete.
3)创建用户以及数据库目录
[root@PostGres ~]# useradd pg
[root@PostGres ~]# mkdir -p /pg9/data
[root@PostGres ~]# chown -R pg.postgres /pg9/data4)配置环境变量
[root@PostGres ~]# su - pg
[pg@PostGres ~]$ vi .bash_profile
export PATH
PGLIB=/pg9/lib
PGDATA=/pg9/data
PATH=$PATH:/pg9/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
export PGLIB PGDATA PATH MANPATH[pg@PostGres ~]$ source .bash_profile
5)初始化数据库
[pg@PostGres ~]$ initdb
The files belonging to this database system will be owned by user "pg".
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.
fixing permissions on existing directory /pg9/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
creating template1 database in /pg9/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... 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:
postgres -D /pg9/data
or
pg_ctl -D /pg9/data -l logfile start
6)启动数据库
[pg@PostGres ~]$ pg_ctl start
server starting
LOG: database system was shut down at 2015-01-19 20:04:01 CST
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
[pg@PostGres ~]$ ps -ef|grep postgres:|grep -v grep
pg 8182 8180 0 20:04 ? 00:00:00 postgres: checkpointer process
pg 8183 8180 0 20:04 ? 00:00:00 postgres: writer process
pg 8184 8180 0 20:04 ? 00:00:00 postgres: wal writer process
pg 8185 8180 0 20:04 ? 00:00:00 postgres: autovacuum launcher process
pg 8186 8180 0 20:04 ? 00:00:00 postgres: stats collector process
好了,至此数据库安装完成。