Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Postgresql installation reference

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

os:centos 7.5

1.posgres Software Directory Description:

Software installation directory:/opt/pg10/

Archive log file directory:/pgdata/10/archive_wal

Backup directory: /pgdata/10/backup

Script directory: /pgdata/10/script

Data file directory:/pgdata/10/data

PID file directory:/pgdata/10/run

The requested URL/pgdata/10/was not found on this server.

Configuration file directory:/pgdata/10/etc

2. Create directories and permissions:

mkdir -p /pgdata/10/{archive_wal,backup,script,data,run,log,etc}

chown -R postgres:postgres /pgdata/10/

3. Install dependent software:

Install dependent software:

yum -y install vim make cmake gcc gcc-c++ glibc lrzsz sysstat e4fsprogs ntp readline-devel zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel python-devel tcl-devel gcc make flex bison perl-YAML perl-ExtUtils

4. Add User:

useradd postgres

echo postgres | passwd postgres --stdin

5. Setting environment variables:

su - postgres

vi .bash_profile

export PGLIB=/opt/pg10/lib

export PGDATA=/pgdata/10/data

export PATH=$PATH:/opt/pg10/bin

export PGHOST=/pgdata/10/run

6. Compile and install software:

tar xvzf postgresql-10.0.tar.gz

cd postgresql-10.0

./ configure --prefix=/opt/pg10/ --sysconfdir=/pgdata/10/etc --with-pgport=5432 --with-perl --with-tcl --with-python --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --with-blocksize=8 --enable-thread-safety --with-wal-segsize=128

make

make install

7. Install extensions:

a.pg_stat_statements

cd /root/postgresql-10.0/contrib/pg_stat_statements

make && sudo make install

psql

psql (10.0)

Type "help" for help.

postgres=# create extension pg_stat_statements;

CREATE EXTENSION

SELECT pg_stat_statements_reset(); Clear pg_stat_statements

b.pg_pathman

Root user executes:

export PGLIB=/opt/pg10/lib

export PGDATA=/pgdata/10/data

export PATH=$PATH:/opt/pg10/bin

export PGHOST=/pgdata/10/run

Compile and install:

cd /opt/pg10/share/postgresql/extension

git clone https://github.com/postgrespro/pg_pathman.git

cd pg_pathman

make USE_PGXS=1

make USE_PGXS=1 install

psql

psql (10.0)

Type "help" for help.

postgres=# create extension pg_pathman ;

CREATE EXTENSION

8. Set permissions:

chown -R postgres:postgres /pgdata/10/

9. initialize the database

su - postgres

cd /opt/pg10/bin

./ initdb -D /pgdata/10/data/ -E UTF-8 --locale=en_US.UTF-8 -k

10. Edit profile:

cp pg_hba.conf /pgdata/10/etc/

cp pg_ident.conf /pgdata/10/etc/

vi /pgdata/10/data/postgresql.conf

data_directory = '/pgdata/10/data'

hba_file = '/pgdata/10/etc/pg_hba.conf'

ident_file = '/pgdata/10/etc/pg_ident.conf'

external_pid_file = '/pgdata/10/run/'

listen_addresses = '*'

port = 5432

max_connections = 5000

unix_socket_directories = '/pgdata/10/run'

ssl = false

#ssl_cert_file = '/etc/pgsql/server.crt'

#ssl_key_file = '/etc/ssl/pgsql/server.key'

shared_buffers = 1GB

max_prepared_transactions = 3000

work_mem = 4MB

maintenance_work_mem = 512MB

shared_preload_libraries = 'pg_stat_statements'

pg_stat_statements.max = 10000

pg_stat_statements.track = all

wal_level = hot_standby

full_page_writes = on

wal_log_hints = off

archive_mode = on

archive_command = 'cp -i %p /pgdata/10/archive_wal/%f

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report