PostgreSQL Compilation Installation

Source: Internet
Author: User
Tags postgresql

Get Source code

Slightly

Compiling the installation

For performance-based software, we install it in a compiled manner.

Installation dependencies
yum install -y systemtap-sdt-devel perl-ExtUtils-Embed pam-devel libxml2-devel libxslt-devel python-devel
Compile
./configure --prefix=/opt/pgsql-9.3.2 --with-perl --with-python --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --enable-thread-safety --with-wal-blocksize=16 --with-blocksize=16 --enable-dtrace --enable-debuggmake world # 安装了包含文档,所有的contribgmake check-world -- (需要普通用户执行。可选,耗时较长)gmake install-world
Start the service

After the software is installed, create a new normal user in the operating system to initialize the database, open and close the database.

useradd postgressu - postgresvi ~/.bash_profile# addexport PGDATA=/pgdata/pg_rootexport LANG=en_US.utf8export PGHOME=/opt/pgsql-9.3.2export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATHexport PATH=$PGHOME/bin:$PATHexport MANPATH=$PGHOME/share/man:$MANPATHexport PGUSER=postgres

Create the appropriate directory and modify the permissions:

mkdir -pv /pgdata/pg_rootchown -R postgres:postgres /pgdata/pg_rootsu - postgres# 初始化数据# initdb -D $PGDATA -E UTF8 --locale=C -U postgres -W# 会提示输入两次密码

Before starting the database, the database needs to be initialized, and during the initialization process, the configuration file is created.

Modifying a configuration file

Before you start, you need to modify the following pg_hba.conf and postgresql.conf files,

    • Pg_hba.conf used to configure the source of control access to the database
    • Postgresql.conf is the primary configuration file for the database

It is best to adjust the kernel parameters:

vi /etc/sysctl.confkernel.shmmni = 4096kernel.sem = 50100 64128000 50100 1280fs.file-max = 7672460net.ipv4.ip_local_port_range = 9000 65000net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576 sysctl -p

To modify the limits.conf configuration file:

vi /etc/security/limits.conf* soft nofile 131072* hard nofile 131072* soft nproc 131072* hard nproc 131072* soft core unlimited* hard core unlimited* soft memlock 50000000* hard memlock 50000000

Start the database

# pg_ctl start -D $PGDATA# 或者使用如下的方式启动pg_ctl -D /var/lib/pgsql/data -l logfile start-bash-4.2$ lsof logfileCOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEpostgres 30772 postgres 1w REG 8,3 0 34606128 logfilepostgres 30772 postgres 2w REG 8,3 0 34606128 logfile-bash-4.2$ lsof -i:5432COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEpostgres 30771 postgres 3u IPv6 37671946 0t0 TCP localhost:postgres (LISTEN)postgres 30771 postgres 4u IPv4 37671947 0t0 TCP localhost:postgres (LISTEN)

Allow extranet access:

echo "host all all 0.0.0.0/0 md5" >> $PGDATA/pg_hba.conf
Stop it
pg_ctl stop -m fast|smart|immediate -D $PGDATA
CentOS Binary Package Installation

If you think CentOS or Redhat comes with a version of PostgreSQL that is too low to use the new version, you can install it using the following method. Install PostgreSQL's official RPM package to add new version information to the repository:

rpm -ivh https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-3.noarch.rpm

Then install using the Yum Install command:

yum install -y postgresql94-server.x86_64

To install a third-party contribution package:

yum install -y postgresql94-contrib.x86_64

The data directory for the new version of PostgreSQL is in the/var/lib/pgsql/ <version> /data directory, and version represents the versions of PostgreSQL, such as version 9.4, which is installed in the/var/lib/pgsql/9.4/data directory.

MacOS Installation PostgreSQL

Can be downloaded to install Postgres.app, so it is more convenient to learn.

PostgreSQL Compilation Installation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.