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

Detailed steps for installing Postgresql12.1

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "the detailed steps of installing Postgresql12.1". In the daily operation, I believe many people have doubts about the detailed steps of installing Postgresql12.1. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "detailed steps of installing Postgresql12.1". Next, please follow the editor to study!

1. Upload the installation package

# cd / usr/src# rz# tar-zxvf postgresql-12.1.tar.gz# rm-rf postgresql-12.1.tar.gz

2. Add third-party plug-ins

Download address: https://www.postgresql.org/docs/12/contrib.html

# cd / usr/src/postgresql-12.1/contrib/# rz# unzip zhparser-master.zip# rm-rf zhparser-master.zip

3. Install the postgresql dependent library

# sudo apt-get install-y gcc libreadline-dev zlib1g zlib1g.dev make

4. Installation

# cd / usr/src/postgresql-12.1/#. / configure-prefix=/opt/pgsql12.1/-with-wal-blocksize=32-with-blocksize=32# make world# make install-world

5. Add user configuration environment variables

# useradd postgres-m # passwd postgres# su-postgres$ vi ~ / .profileexport PGPORT=8899export PGDATA=/home/postgres/pgsql12.1/pg_rootexport LANG=en_US.utf8export PGHOME=/opt/pgsql12.1/export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATHexport DATE= `date + "% Y%m%d%H%M" `export PATH=$PGHOME/bin:$PATH:.export MANPATH=$PGHOME/share/man:$MANPATHexport PGUSER=postgresexport PGHOST=$PGDATAalias Rm='rm-i'alias ll='ls-lh'export PGDATABASE=center$ exit# reboot or source ~ / .profile # usermod-s / bin/bash postgres# su-postgres$ mkdir-p / home/postgres/pgsql12.1/pg_root$ initdb-D $PGDATA-E UTF8-- locale=C-U postgres-W # here you need to enter the password twice

6. Modify kernel parameters

$su-root# vi / etc/sysctl.confkernel.shmmax = 68719476736kernel.shmall = 4294967296kernel.shmmni = 4096kernel.sem = 50100 64128000 50100 1280fs.file-max = 7672460net.ipv4.ip_local_port_range = 9000 65000net.core.rmem_default = 1048576net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 104857 sysctl-p # 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 5000000

7. Turn off the firewall

# sudo ufw status verboseStatus: activeLogging: on (low) Default: deny (incoming), allow (outgoing), disabled (routed) New profiles: skip# sudo ufw disableFirewall stopped and disabled on system startup# sudo ufw status verboseStatus: inactive

8. Configure pg_hba.conf

$cd $PGDATA$ vi pg_hba.conf add allowed access to the IP segment host all all 192.168.0.0 md5host all all 16 md5 10.10.0.0

9. Configure postgresql.conf

Listen_addresses = '0.0.0.0'port = 7788max_connections = 100superuser_reserved_connections = 13unix_socket_directories ='. Unix_socket_permissions = 0700tcp_keepalives_idle = 60 tcp_keepalives_interval = 10tcp_keepalives_count = 10shared_buffers = 128MBvacuum_cost_delay = 10bgwriter_delay = 10mswal_writer_delay = 10mslog_destination = 'csvlog' logging_collector = on log_directory =' pg_log'log_filename = 'postgresql-%Y-%m-%d_%H%M % S.log'log_file_mode = 0600log_truncate_on_rotation = onlog_rotation_age = 1dlog_rotation_size = 10MBlog_checkpoints = onlog_connections = onlog_disconnections = onlog_error_verbosity = verboselog_timezone = 'Asia/Shanghai'

10. Start the database

$pg_ctl start [- d $PGDATA]

11. Enter the database

$psql-h 127.0.0.1-p 7788-U postgres postgres

12. Stop the database

$pg_ctl stop [- m fast | smart | immediate] [- d $PGDATA]

13. Install Pgadmin

# sudo apt update-y & & sudo apt upgrade-y # sudo apt-get install-y pgadmin4 pgadmin4-apache2

Access: http://ip: port / pgadmin4/

At this point, the study on "detailed steps to install Postgresql12.1" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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