I. preface PostgreSQL, also referred to as Postgres, is a relational database management system applicable to various Linux operating systems, Windows, Solaris, BSD, and MacOSX. PostgreSQL follows the PostgreSQL License and is an open source software. PostgreSQL is developed by the PostgreSQL Global Development Group and is composed and supervised by a small number of companies.
I. Preface
PostgreSQL, also known as Postgres, is a relational database management system applicable to various Linux operating systems, Windows, Solaris, BSD, and Mac OS X. PostgreSQL follows the PostgreSQL License and is an open source software. PostgreSQL is developed by the PostgreSQL Global Development Group and consists of a small number of companies that volunteer to supervise and manage these companies, including RedHat and EnterpriseDB.
PostgreSQL is becoming more and more popular, so it is taken for granted that it is so reliable and efficient. Compared with traditional enterprise-level relational databases, PostgreSQL is fully community-driven and has rich tools and documents to form a complete ecosystem.
Currently, the installation of most of the searched CentOS commands for Centos 6.x has changed a lot. This article mainly records the process of installing PostgreSQL in CentOS 7.1.
II. install the PostgreSQL source
CentOS 6.x 32bit
rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-i386/pgdg-centos94-9.4-1.noarch.rpm
CentOS 6.x 64bit
rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
CentOS 7 64bit
rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
There are not many differences in the process of adding a source, mainly because the source address has some changes.
3. execute the Installation Command
yum updateyum install postgresql94-server postgresql94-contrib
4. verify whether the installation is successful
rpm -aq| grep postgres
The execution result is as follows:
postgresql94-libs-9.4.1-1PGDG.rhel7.x86_64postgresql94-server-9.4.1-1PGDG.rhel7.x86_64postgresql94-9.4.1-1PGDG.rhel7.x86_64postgresql94-contrib-9.4.1-1PGDG.rhel7.x86_64
V. initialize the database
CentOS 6.x system
service postgresql-9.4 initdb
CentOS 7System
/usr/pgsql-9.4/bin/postgresql94-setup initdb
If I execute service postgresql-9.4 initdb under CentOS 7, the following problem will be reported:
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
6. start the service and set it to start upon startup
CentOS 6.x system
service postgresql-9.4 startchkconfig postgresql-9.4 on
CentOS 7System
systemctl enable postgresql-9.4systemctl start postgresql-9.4
7. open firewall ports
CentOS 6.x system
vi /etc/sysconfig/iptables
Press I to enter the input mode and add the following statement to the file.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Press ESC to exit the editing mode. enter wq to exit the VI editing page.
Restart the firewall service
service iptables restart
CentOS 7System
firewall-cmd --permanent --add-port=5432/tcpfirewall-cmd --permanent --add-port=80/tcpfirewall-cmd --reload
8. access PostgreSQL
su - postgres
The output result is as follows:
Last logon: October 11, May 18 15:17:29 CST 2015pts/0-bash-4.2 $
Enter the command psql to view the PostgrSQL version.
Psql (9.4.1) input "help" to obtain help information.
9. set the postgres user password
postgres=# \password postgres
The above operations basically complete the installation of the entire PostgreSQL.