Thursday, 3 February 2022

CREATE CLUSTER


[root@postgres Desktop]# cd /data1/

[root@postgres data1]# mkdir prod
[root@postgres data1]# chown postgres:postgres prod/ -R

[root@postgres data1]# su - postgres

-bash-4.1$ initdb -D /data1/prod/ ---------------> starting new cluster instance 

-bash-4.1$ cd /data1/prod/
-bash-4.1$ vi postgresql.conf

port=5433

:wq

-bash-4.1$ pg_ctl -D /data1/prod/ start ---------------------> starting database

-bash-4.1$ ps -ef | grep postgres
root     17715 17705  0 13:51 pts/0    00:00:00 su - postgres
postgres 17716 17715  0 13:51 pts/0    00:00:00 -bash
postgres 17783     1  0 13:53 pts/1    00:00:00 /opt/PostgreSQL/10/bin/postgres -D ../data
postgres 17784 17783  0 13:53 ?        00:00:00 postgres: logger process                  
postgres 17786 17783  0 13:53 ?        00:00:00 postgres: checkpointer process            
postgres 17787 17783  0 13:53 ?        00:00:00 postgres: writer process                  
postgres 17788 17783  0 13:53 ?        00:00:00 postgres: wal writer process              
postgres 17789 17783  0 13:53 ?        00:00:00 postgres: autovacuum launcher process     
postgres 17790 17783  0 13:53 ?        00:00:00 postgres: stats collector process         
postgres 17791 17783  0 13:53 ?        00:00:00 postgres: bgworker: logical replication launcher   
root     17832 17741  0 13:59 pts/1    00:00:00 su - postgres
postgres 17833 17832  0 13:59 pts/1    00:00:00 -bash
postgres 17890     1  0 14:01 pts/1    00:00:00 /opt/PostgreSQL/10/bin/postgres -D /data1/prod
postgres 17892 17890  0 14:01 ?        00:00:00 postgres: checkpointer process                     
postgres 17893 17890  0 14:01 ?        00:00:00 postgres: writer process                           
postgres 17894 17890  0 14:01 ?        00:00:00 postgres: wal writer process                       
postgres 17895 17890  0 14:01 ?        00:00:00 postgres: autovacuum launcher process              
postgres 17896 17890  0 14:01 ?        00:00:00 postgres: stats collector process                  
postgres 17897 17890  0 14:01 ?        00:00:00 postgres: bgworker: logical replication launcher   

-bash-4.1$ psql -p 5433 -U postgres -d postgres
psql.bin (10.9)
Type "help" for help.

postgres=# show data_directory;
  data_directory  
------------------
 /data1/prod
(1 row)

postgres=# show port;
 port 
------
 5433
(1 row)

postgres=# select datname from pg_database;
  datname  
-----------
 postgres
 template1
 template0
(3 rows)

postgres=# 

postgres=# create table emp(name char);
CREATE TABLE
postgres=# insert into emp values('s');
INSERT 0 1
postgres=# \dt
        List of relations
 Schema | Name | Type  |  Owner   
--------+------+-------+----------
 public | emp  | table | postgres
(1 row)

postgres=# \dt+
                      List of relations
 Schema | Name | Type  |  Owner   |    Size    | Description 
--------+------+-------+----------+------------+-------------
 public | emp  | table | postgres | 8192 bytes | 
(1 row)

No comments:

Post a Comment

Master and Slave - Sync check - PostgreSQL

  1) Run the below Query on Primary:- SELECT     pid,     usename,     application_name,     client_addr,     state,     sync_state,     sen...