Installation from PostgreSQL Binaries from YUM
9:31 AM1. Configure your YUM repository (Redhet 6 64 bit)
At the main section in the file /etc/yum/pluginconf.d/rhnplugin.conf append a lineexclude=postgresql*
2. Download and install PGDG RPM file
A PGDG file is available for each distribution/architecture/database version combination. Browse http://yum.pgrpms.org/reporpms/ and find your correct RPM. For example, to install PostgreSQL 9.4 on RedHat 6 64-bit:shell> wget http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm
3. Now install RPM distribution:
shell> rpm -Uvh pgdg-redhat94-9.4-1.noarch.rpm
4. Install PostgreSQL
To list available packages:shell> yum list postgres*
For example, to install a basic PostgreSQL 9.4 server:
shell> yum install postgresql94 postgresql94-server
5. Initialize
A
database needs to be initialized and configured. For PostgreSQL version
9.x and above, the <name> is postgresql-9.x, and the PGDATA
directory is:/var/lib/pgsql/9.x/data
For versions 7.x and 8.x, the <name> is always postgresql, and the PGDATA directory is:
/var/lib/pgsql/data/
The first command (only needed once) is to initialize the database in PGDATA:
shell> service postgresql-9.4 initdb
6. Startup
Start the service:shell> service postgresql-9.4 start
If you want PostgreSQL to startup automatically on reboot:
shell> chkconfig postgresql-9.4 on
7. To control the database service, use:
shell> service postgresql-9.4 <command> where <command> can be: * start : start the database * stop : stop the database * restart : stop/start the database; used to read changes to core configuration files * reload : reload pg_hba.conf file while keeping database running
8.To uninstall & remove - To remove everything:
shell> yum erase postgresql*
9. Create a super user for accessing database server from remote network.
shell> su - postgres bash-4.1$> psql -dpostgres postgres=#create role admin login password '$0m3p@ssw0rd' superuser; postgres=#select * from pg_catalog.pg_user;
10. Make the changes in your database config file.
shell> vi /var/lib/pgsql/9.4/data/postgresql.conf Uncomment the line #listen_addresses = ‘localhost’ and change it to listen_addresses = ‘*’ shell> vi /var/lib/pgsql/9.4/data/pg_hba.conf host all admin 192.168.1.1/24 md5
11. Open the default PostgreSQL database port in server firewall to connecting from remote network.
shell> vi /etc/sysconfig/iptables Add this line before reject rule "-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT" shell> service iptables restart shell> service postgresql-9.4 restart
12. see Error log file if postgresql is not starting
tail -f /var/lib/pgsql/9.4/data/pg_log/postgresql-Friday.log result: < 2015-05-08 08:46:43.792 EDT >LOG: aborting any active transactions < 2015-05-08 08:46:43.792 EDT >LOG: autovacuum launcher shutting down < 2015-05-08 08:46:43.793 EDT >LOG: shutting down < 2015-05-08 08:46:43.804 EDT >LOG: database system is shut down < 2015-05-08 08:46:44.865 EDT >LOG: invalid IP mask "md5": Name or service not known < 2015-05-08 08:46:44.865 EDT >CONTEXT: line 83 of configuration file "/var/lib/pgsql/9.4/data/pg_hba.conf" < 2015-05-08 08:46:44.865 EDT >FATAL: could not load pg_hba.conf < 2015-05-08 09:06:26.674 EDT >LOG: invalid IP mask "md5": Name or service not known < 2015-05-08 09:06:26.674 EDT >CONTEXT: line 83 of configuration file "/var/lib/pgsql/9.4/data/pg_hba.conf" < 2015-05-08 09:06:26.674 EDT >FATAL: could not load pg_hba.conf
13. connect postgresql through remote server
remote server shell> psql -U admin -d postgres -h 192.168.1.2 Password for user admin: psql (9.1.13, server 9.4.1) WARNING: psql version 9.1, server version 9.4. Some psql features might not work. Type "help" for help. postgres=#
0 comments