Install PostgreSQL 9.4 on CentOS 7
时间:2016-05-17 14:14 来源:linux.it.net.cn 作者:IT
PostgreSQL is a database server. It is an object-relational database management system and it’s main purpose is to store data. PostgreSQL calls itself “The world’s most advanced open-source database”. It is a fact thatMySQL and PostgreSQL are two most popular open-source relation database management systems (RDMS). It is up to you to choose the one you like the most.
I have already written a post on how to “Install PostgreSQL 9.3 on CentOS 6″ but installing PostgreSQL on CentOS 7 is not quite the same so i decided to write a new post “Install PostgreSQL 9.4 on CentOS 7″.
Install PostgreSQL 9.4 on CentOS 7
Let’s Install PostgreSQL 9.4 on CentOS 7!
1. Install PostgreSQL 9.4 Repository
Install the latest stable version of PostgreSQL 9.4 for CentOS 7 64bit. All available repositories can be found HERE .
[root@node-1 ~]# rpm -ivh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
2. Install PostgreSQL 9.4 Server and Dependencies
Install PostgreSQL 9.4 server from YUM repository installed in previous step. YUM will automatically resolve and install dependencies also.
[root@node-1 ~]# yum install postgresql94-server -y
3. Initialize PostgreSQL 9.4 Database
You need to initialize the PostgreSQL 9.4 database before you can successfully start it. This step differs from initializing the PostgreSQL database on CentOS version 6. You can’t run “service postgresql94 initdb” anymore, instead you must call the PostgreSQL 9.4 setup binary as follows:
[root@node-1 ~]# /usr/pgsql-9.4/bin/postgresql94-setup initdb
Initializing database ... OK
4. Start PostgreSQL 9.4 and Make it Start at Boot
You can find the PostgreSQL 9.4 service with the following command and also see that it is not enabled to start at boot:
[root@node-1 ~]# systemctl list-unit-files |grep postgres
postgresql-9.4.service disabled
Enable the PostgreSQL 9.4 service to start at boot:
[root@node-1 ~]# systemctl enable postgresql-9.4.service
ln -s '/usr/lib/systemd/system/postgresql-9.4.service' '/etc/systemd/system/multi-user.target.wants/postgresql-9.4.service'
..and start the PostgreSQL 9.4 service as follows:
[root@node-1 ~]# systemctl start postgresql-9.4.service
5. Confirm the Database is Running
You can confirm the database is running by viewing the process list:
[root@node-1 ~]# ps auxf |grep postgres
root 3091 0.0 0.1 112640 980 pts/0 S+ 11:41 0:00 \_ grep --color=auto postgres
postgres 3042 0.0 1.9 337452 15200 ? S 11:40 0:00 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data
postgres 3043 0.0 0.1 192600 1368 ? Ss 11:40 0:00 \_ postgres: logger process
postgres 3045 0.0 0.2 337452 1680 ? Ss 11:40 0:00 \_ postgres: checkpointer process
postgres 3046 0.0 0.3 337452 2480 ? Ss 11:40 0:00 \_ postgres: writer process
postgres 3047 0.0 0.2 337452 1688 ? Ss 11:40 0:00 \_ postgres: wal writer process
postgres 3048 0.0 0.3 337864 2608 ? Ss 11:40 0:00 \_ postgres: autovacuum launcher process
postgres 3049 0.0 0.2 192728 1744 ? Ss 11:40 0:00 \_ postgres: stats collector process
.. and also by successfully connecting to the database as follows:
[root@node-1 ~]# su - postgres
Last login: Fri Jul 31 11:41:11 CEST 2015 on pts/0
-bash-4.2$ psql
psql (9.4.4)
Type "help" for help.
postgres=#
6. Edit Basic Configuration
Step 6 is still the same as with PostgreSQL 9.3 on CentOS 6 . You can read the postHERE and jump to Step 6.
(责任编辑:IT)
PostgreSQL is a database server. It is an object-relational database management system and it’s main purpose is to store data. PostgreSQL calls itself “The world’s most advanced open-source database”. It is a fact thatMySQL and PostgreSQL are two most popular open-source relation database management systems (RDMS). It is up to you to choose the one you like the most. I have already written a post on how to “Install PostgreSQL 9.3 on CentOS 6″ but installing PostgreSQL on CentOS 7 is not quite the same so i decided to write a new post “Install PostgreSQL 9.4 on CentOS 7″. Install PostgreSQL 9.4 on CentOS 7 Let’s Install PostgreSQL 9.4 on CentOS 7!1. Install PostgreSQL 9.4 RepositoryInstall the latest stable version of PostgreSQL 9.4 for CentOS 7 64bit. All available repositories can be found HERE . [root@node-1 ~]# rpm -ivh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm 2. Install PostgreSQL 9.4 Server and DependenciesInstall PostgreSQL 9.4 server from YUM repository installed in previous step. YUM will automatically resolve and install dependencies also. [root@node-1 ~]# yum install postgresql94-server -y 3. Initialize PostgreSQL 9.4 DatabaseYou need to initialize the PostgreSQL 9.4 database before you can successfully start it. This step differs from initializing the PostgreSQL database on CentOS version 6. You can’t run “service postgresql94 initdb” anymore, instead you must call the PostgreSQL 9.4 setup binary as follows: [root@node-1 ~]# /usr/pgsql-9.4/bin/postgresql94-setup initdb Initializing database ... OK 4. Start PostgreSQL 9.4 and Make it Start at BootYou can find the PostgreSQL 9.4 service with the following command and also see that it is not enabled to start at boot: [root@node-1 ~]# systemctl list-unit-files |grep postgres postgresql-9.4.service disabled Enable the PostgreSQL 9.4 service to start at boot: [root@node-1 ~]# systemctl enable postgresql-9.4.service ln -s '/usr/lib/systemd/system/postgresql-9.4.service' '/etc/systemd/system/multi-user.target.wants/postgresql-9.4.service' ..and start the PostgreSQL 9.4 service as follows: [root@node-1 ~]# systemctl start postgresql-9.4.service 5. Confirm the Database is RunningYou can confirm the database is running by viewing the process list: [root@node-1 ~]# ps auxf |grep postgres root 3091 0.0 0.1 112640 980 pts/0 S+ 11:41 0:00 \_ grep --color=auto postgres postgres 3042 0.0 1.9 337452 15200 ? S 11:40 0:00 /usr/pgsql-9.4/bin/postgres -D /var/lib/pgsql/9.4/data postgres 3043 0.0 0.1 192600 1368 ? Ss 11:40 0:00 \_ postgres: logger process postgres 3045 0.0 0.2 337452 1680 ? Ss 11:40 0:00 \_ postgres: checkpointer process postgres 3046 0.0 0.3 337452 2480 ? Ss 11:40 0:00 \_ postgres: writer process postgres 3047 0.0 0.2 337452 1688 ? Ss 11:40 0:00 \_ postgres: wal writer process postgres 3048 0.0 0.3 337864 2608 ? Ss 11:40 0:00 \_ postgres: autovacuum launcher process postgres 3049 0.0 0.2 192728 1744 ? Ss 11:40 0:00 \_ postgres: stats collector process .. and also by successfully connecting to the database as follows: [root@node-1 ~]# su - postgres Last login: Fri Jul 31 11:41:11 CEST 2015 on pts/0 -bash-4.2$ psql psql (9.4.4) Type "help" for help. postgres=# 6. Edit Basic ConfigurationStep 6 is still the same as with PostgreSQL 9.3 on CentOS 6 . You can read the postHERE and jump to Step 6. (责任编辑:IT) |