netang

postgreSQL

Jan 27th, 2020 (edited)
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.21 KB | None | 0 0
  1. # open systemd service file
  2. sudo nano ?????/postgres.service
  3. # and put path to postgres data
  4. [Service]
  5. Environment=PGDATA=/mnt/ess_storage/DN_1/storage/automall/postgres_node1
  6.  
  7. sudo systemctl enable postgresql
  8. sudo systemctl start postgresql
  9. sudo systemctl status postgresql
  10. sudo systemctl stop postgresql
  11. sudo systemctl restart postgresql
  12.  
  13.  
  14. # create database and user
  15. [user] sudo su - postgres
  16. create database car4u;
  17. create user car4u_app with encrypted password 'password';
  18. grant all privileges on database car4u to car4u_app;
  19. \q
  20.  
  21. # change owner for all tables
  22. for table in `psql -tc "select tablename from pg_tables where schemaname = 'public';" car4u` ; do  psql -c "alter table ${table} owner to car4u_app" car4u ; done
  23.  
  24.  
  25. SHOW hba_file;
  26. /mnt/ess_storage/DN_1/storage/automall/postgres_node1/pg_hba.conf
  27. SHOW config_file;
  28. /mnt/ess_storage/DN_1/storage/automall/postgres_node1/postgresql.conf
  29.  
  30.  
  31. sudo netstat -plunt |grep postmaster
  32.  
  33.  
  34. # creating backup file
  35. sudo su - postgres
  36. pg_dump automall > /tmp/automall.dump
  37. exit
  38. exit
  39. scp nano@10.9.14.110:/tmp/automall.dump /home/user/projects/automallproject/application/integration/files/
  40.  
  41. # restore from backup
  42. psql -U car4u_app -d car4u < /tmp/backup_file
Add Comment
Please, Sign In to add comment