Selasa, 03 Maret 2020

PGSQL-install redhat7

How to Install Postgres / Posgresql on CentOS 7 (or RHEL 7)

Timothy D Beach
Jun 29, 2018 · 3 min read
All as root as performed on two onMetal Cloud I/Ov2 instances at RackSpace with rackconnect networking to get these well spec’d instances behind our primary dedicated firewall.
For some licensing reason, Red Hat doesn’t allow RHEL licenses to these onMetal servers. So, it was a good excuse to use CentOS instead. So far, seems to be the same deal practically speaking.

1. add necessary repo

# rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
There is a yum version of this farther down. The above command assumes Centos 7 is your operating system. You can use this site to get a similar command to execute based on making some selections from a few dropdowns: https://www.postgresql.org/download/linux/redhat/
Bear in mind the current version 10 software is 10.6 at the time of last editing this article.
This should give you an idea of the EOL schedule for version of postgres going back to 9.0
BTW, instead of using rpm, we can also use yum:
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
The output of the above step should produce something similar in your terminal

2. install the necessary packages

# yum -y install postgresql10 postgresql10-server postgresql10-contrib postgresql10-libs postgresql10-devel
You at least need postgresql10, likely postgresql10-server. The other two will probably come in handy: postgresql10-contrib & postgresql10-libs.
Here’s what the transaction summary might look like
Here’s what got installed

3. enable postgres to start automatically upon reboot

# systemctl enable postgresql-10.service
The result of the above command should look something like this ^^^

4. init (initialize) the cluster

Use this command to init the cluster in its default location on the system disk.
# /usr/pgsql-10/bin/postgresql-10-setup initdb
we can check configs and whatnot from
/var/lib/pgsql/10/data

Now we can verify the install

 — — — — — — — copied from terminal — — — — — — — — — — 
 — init the cluster
[root@onMetal-db1 ~]# /usr/pgsql-10/bin/postgresql-10-setup initdb
Initializing database … OK— start the service
[root@onMetal-db1 ~]# systemctl start postgresql-10.service— switch to postgres user
[root@onMetal-db1 ~]# su — postgres — enter psql interactive terminal
-bash-4.2$ psql
psql (10.4)
Type “help” for help. — type \l for the list command that list current database instances on this cluster
postgres=# \l
 List of databases
 Name | Owner | Encoding | Collate | Ctype | Access privileges 
 — — — — — -+ — — — — — + — — — — — + — — — — — — -+ — — — — —
 postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres 
 +
 | | | | | postgres=CTc/postgres
 template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres 
 +
 | | | | | postgres=CTc/postgres
(3 rows)

This message predicts the future

Tidak ada komentar:

Posting Komentar