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 can be installed in many ways

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

Share

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

PostgreSQL test environment

The test environment is a CentOS7.x x86slave 64-bit system.

Premise:

Installation minimized installation

Install the epel source

Get the source code

Go to the official website to get the source code:

Wget https://ftp.postgresql.org/pub/source/v9.4.6/postgresql-9.4.6.tar.bz2

Compile and install for performance-based software, we install it by compiling.

Installation depends on yum install-y systemtap-sdt-devel perl-ExtUtils-Embed\ pam-devel libxml2-devel libxslt-devel python-devel compilation. / configure-- prefix=/opt/pgsql-9.4.6\-- 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 # installed the included documentation All contribgmake check-world-- (need to be executed by ordinary users. Optional, time-consuming) after the installation of the gmake install-world startup service software, create a new ordinary 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.4.6export 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# initialization data # initdb-D $PGDATA-E UTF8-- locale=C-U postgres-W# will prompt you to enter a password twice before starting the database, you need to initialize the database, during the initialization process, you will create a configuration file, etc.

Modify the configuration file before starting, you need to modify the pg_hba.conf and postgresql.conf files

+ pg_hba.conf is used to configure sources that control access to the database

+ postgresql.conf is the main 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 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 launch database # pg_ctl start- D $PGDATA# or launch 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 REG 3 034606128 logfilepostgres 30772 postgres 2w REG 8 REG 3 034606128 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) allows public network access:

Echo "host all all 0.0.0.0 md5" > $PGDATA/pg_hba.conf stop pg_ctl stop-m fast | smart | immediate-D $PGDATACentOS binary package installation if you think that the PostgreSQL version that comes with CentOS or RedHat is too low and you want to use the new version, you can install it using the following method. Install the RPM package officially provided by PostgreSQL and add the new version information to the version library:

Rpm-ivh https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-3.noarch.rpm then use the yum install command to install:

Yum install-y postgresql94-server.x86_64 installs third-party contributions:

The data directory for the new version of PostgreSQL of yum install-y postgresql94-contrib.x86_64 is in the / var/lib/pgsql//data directory, and version represents the version of PostgreSQL, such as version 9.4, which is installed in the / var/lib/pgsql/9.4/data directory.

MacOS installation PostgreSQL can download and install Postgres.app, which is more convenient to learn.

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