1Before you install PostgreSQL, verify that the Internet connection is working to download the installation files. Use Yum First-y update instructions to upgrade the system to the latest version. 2. Turn off Firewall service: #/etc/init.d/iptables Stop3Add user group, add user Groupadd postgres useradd postgres-g Postgres4New database execution file directory, new database data file directory mkdir-p/usr/local/pgsql mkdir-p/db/pgsql/Data5. Modify the directory owner Chown-R postgres/usr/local/pgsql/. Chown-R postgres/db/pgsql/Data Chown-R postgres/db/pgsql/data/.6. Editing path search Paths VI/etc/Profile adds the following two lines: PATH=/usr/local/pgsql/Bin: $PATH export PATH7. Effective path search Path source/etc/ Profile8. Install the tools and libraries that are required to compile the source Yum-y install wget gcc readline-devel zlib-devel Make9Enter the source tarball download directory, unzip the source package CD/usr/src tar jxvf./postgresql-9.2.4. tar.bz2TenEnter the extracted source directory and execute the compilation CD./postgresql-9.2.4Configure make make install One. Change login user, execute database initialization script Su-Postgres/usr/local/pgsql/bin/initdb--encoding=utf8-d/db/pgsql/Data A. Exit Change Login Exit -. Copy PostgreSQL execute script, increase execute privilege CP/usr/src/postgresql-9.2.4/contrib/start-scripts/linux/etc/init.d/PostgreSQL chmod+x/etc/init.d/PostgreSQL -. Edit PostgreSQL execution script, specify database file directory VI/etc/init.d/PostgreSQL PGDATA="/db/pgsql/data" the. Edit postgresql.conf Configuration VI/db/pgsql/data/postgresql.conf Configuration Content modified to: listen_addresses='*'# What IP address (es) to listen on; # comma-separated list of addresses; # defaults to'localhost'; Use'*' forAll # (change requires restart) #port=5432# (change requires restart) -. Edit pg_hba.conf Configuration VI/db/pgsql/data/pg_hba.conf Configuration content is: # IPV4 local connections:host all127.0.0.1/ +Trust host All0.0.0.0/0Trust -. Modify the database password for the postgres user su postgres psql-U postgres Postgres=# ALTER USER Postgres PASSWORD'123456'; Postgres=# \q -. Restart the PostgreSQL Services service PostgreSQL restart or/etc/init.d/PostgreSQL Restart If the restart fails, start service server PostgreSQL startremark:
Netstat-TPNL |grep5432 //View Ports # /etc/init.d/iptables status
Postgresql is installed on the CentOS server using