centos7 安装原始PG10.12

操蛋,要安装知道版本10.12.没找到。找个打包安装

https://ftp.postgresql.org/pub/source/v10.12/

1. First install required prerequisites such as gccreadline-devel and zlib-devel using package manager as shown.

# yum install gcc zlib-devel readline-devel     [On RHEL/CentOS]
# apt install gcc zlib1g-dev libreadline6-dev   [On Debian/Ubuntu]

2. Download the source code tar file from the official postgres website using the following wget command directly on system.

# wget https://ftp.postgresql.org/pub/source/v10.0/postgresql-10.0.tar.bz2

3. Use tar command to extract the downloaded tarball file. New directory named postgresql-10.0 will be created.

# tar -xvf postgresql-10.0.tar.bz2
# ll

Sample Output

total 19236
-rw-------. 1 root root      933 Mar 18  2015 anaconda-ks.cfg
-rw-r--r--. 1 root root     8823 Mar 18  2015 install.log
-rw-r--r--. 1 root root     3384 Mar 18  2015 install.log.syslog
drwxrwxrwx  6 1107 1107     4096 Oct  3  2017 postgresql-10.0
-rw-r--r--  1 root root 19639147 Oct  3  2017 postgresql-10.0.tar.bz2

4. Next step for installation procedure is to configure the downloaded source code by choosing the options according to your needs.

# cd postgresql-10.0

use ./configure --help to get help about various options.

Sample Output

# ./configure --help

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]

5. Now create a directory where you want to install postgres files and use prefix option with configure.

# mkdir /opt/PostgreSQL-10/
# ./configure --prefix=/opt/PostgreSQL-10

Sample Output

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
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 whether gcc supports -Wmissing-format-attribute... yes
checking whether gcc supports -Wformat-security... yes
checking whether gcc supports -fno-strict-aliasing... yes
checking whether gcc supports -fwrapv... yes
checking whether gcc supports -fexcess-precision=standard... no
....

6. After configuring, next we will start to build postgreSQL using following make command.

# make

After build process finishes, now install postgresql using following command.

# make install

Postgresql 10 has been installed in /opt/PostgreSQL-10 directory.

7. Now create a postgres user and directory to be used as data directory for initializing database cluster. Owner of this data directory should be postgres user and permissions should be 700 and also set path for postgresql binaries for our ease.

# useradd postgres
# passwd postgres
# mkdir /pgdatabase/data
# mkdir /opt/pglog/db_logs/start.log 创建个用来记录日志
# chown -R postgres /pgdatabase/data
# chown -R postgres /opt/pglog/db_logs/start.log  创建的时候。mkdir 不能退一次创建。我一层层创建的。又空去看下。哪里设置
# echo 'export PATH=$PATH:/opt/PostgreSQL-10/bin' > /etc/profile.d/postgres.sh

8. Now initialize database using the following command as postgres user before using any postgres commands.

# su postgres
$ initdb -D /pgdatabase/data/ -U postgres -W

 这个data目录下有文件的所有设置

/opt/pgdatabase/data这个目录下postgresql.conf  address 设置'*', pg_hba.conf 加下。host    all             all             0.0.0.0/0               trust
保存

Where -D is location for this database cluster or we can say it is data directory where we want to initialize database cluster, -U for database superuser name and -W for password prompt for db superuser.

For more info and options we can refer initdb –help.

9. After initializing database, start the database cluster or if you need to change port or listen address for server, edit the postgresql.conf file in data directory of database server.

Configure PostgreSQL Port

Configure PostgreSQL Port

$ pg_ctl -D /opt/pgdatabase/data/ -l /opt/pglog/db_logs/start.log restart/start....

10. After starting database, verify the status of postgres server process by using following commands.

$ ps -ef |grep -i postgres
$ netstat -apn |grep -i 51751

Verify PostgreSQL Database

Verify PostgreSQL Database

We can see that database cluster is running fine, and startup logs can be found at location specified with -l option while starting database cluster.

11. Now connect to database cluster and create database by using following commands.

$ psql -p 51751
postgres=# create database test;
postgres=# \l to list all databases in cluster
postgres=# \q to quit form postgres console

Connect PostgreSQL Database

Connect PostgreSQL Database

That’s It! in our upcoming articles, I will cover configuration, replication setup and installation of pgAdmin tool, till then stay tuned to Tecmint.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值