时间:2021-07-01 10:21:17 帮助过:6人阅读
Locate and edit your distributions .repo file, located:
To the section(s) identified above, you need to append a line (otherwise dependencies might resolve to the postgresql supplied by the base repository):
exclude=postgresql*
A PGDG file is available for each distribution/architecture/database version combination. Browse http://yum.postgresql.org and find your correct RPM. For example, to install PostgreSQL 9.4 on CentOS 6 64-bit:
yum localinstall http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
To list available packages:
yum list postgres*
For example, to install a basic PostgreSQL 9.4 server:
yum install postgresql94-server
Other packages can be installed according to your needs.
After installing the packages, a database needs to be initialized and configured.
In the commands below, the value of <name> will vary depending on the version of PostgreSQL used.
For PostgreSQL version 9.0 and above, the <name> includes the major.minor version of PostgreSQL, e.g., postgresql-9.4
For versions 8.x, the <name> is always postgresql (without the version signifier).
The PostgreSQL data directory contains all of the data files for the database. The variable PGDATA is used to reference this directory.
For PostgreSQL version 9.0 and above, the default data directory is:
/var/lib/pgsql/<name>/data
For example:
/var/lib/pgsql/9.4/data
For versions 7.x and 8.x, default data directory is:
/var/lib/pgsql/data/
The first command (only needed once) is to initialize the database in PGDATA.
service <name> initdb
E.g. for version 9.4:
service postgresql-9.4 initdb
If the previous command did not work, try directly calling the setup binary, located in a similar naming scheme:
/usr/pgsql-y.x/bin/postgresqlyx-setup initdb
E.g. for version 9.4:
/usr/pgsql-9.4/bin/postgresql94-setup initdb
If you want PostgreSQL to start automatically when the OS starts:
chkconfig <name> on
E.g. for version 9.4:
chkconfig postgresql-9.4 on
In RHEL 7+, try:
systemctl enable postgresql
To control the database service, use:
service <name> <command>
where <command> can be:
E.g. to start version 9.4:
service postgresql-9.4 start
With RHEL 7.1+ and CentOS 7.1+, Systemd is introduced. Use this instead:
systemctl enable postgresql-9.4.service
systemctl start postgresql-9.4.service
To remove everything:
yum erase postgresql94*
Or remove individual packages as desired.
YUM Installation PostgreSQL
标签: