Postgresql Installation notes

Source: Internet
Author: User
Tags openssl rsa psql
The following describes how to install postgresql on redhat8.0. 1. Download the source code package 8.0.1  2. installation./Configure
Make
Su
Make install
Adduser postgres
Mkdir/usr/local/pgsql/data
Chown postgres/usr/local/pgsql/data
Su-postgres
/Usr/local/pgsql/bin/initdb-D/usr/local/pgsql/data 3. Self-startingCopy the contrib/start-scripts/linux to/etc/init. d/, change the name to ipvs and execute the permission. You can use/etc/init later. d/postgresql start 4. Run the following command to create a test database: /Usr/local/pgsql/bin/createdb test
/Usr/local/pgsql/bin/psql test 5. Shared Memory-semaphore and other settingsThe ipcs command displays the usage of the system's ipc object. Linux's default shared memory limit in the 2.2 kernel ( SHMMAXAnd SHMALL) Is 32 MB, but you can ProcModify these values in the file system ). For example, 128 MB is allowed: $ Echo 134217728>/proc/sys/kernel/shmall
$ Echo 134217728>/proc/sys/kernel/shmmax   You can put these commands in a script that runs during boot. In addition, you can use SysctlTo control these parameters. Find /Etc/sysctl. confAnd then add the following lines to it: kernel. shmall = 134217728
Kernel. shmmax = 134217728 this file is usually processed during boot, but you can also call Sysctl. Other parameters are sufficient for any application. If you want to view it by yourself, you can look at the following files: /Usr/src/linux/include/asm- Xxx/Shmparam. hAnd /Usr/src/linux/include/linux/sem. h. 6. Use SSL for Communication (postgresql document 16.7) 1) certificate creation request Openssl req-new-text-out server. req 2) convert the private key file to server. key openssl rsa-in privkey. pem-out server. key rm privkey. pem 3) generate the openssl req-x509-in server certificate. req-text-key server. key-out server. crt chmod og-rwx server. key 4) copy the certificate and key to the place where the system uses them. cp .... /server. crt/usr/local/pgsql/data cp .... /server. key/usr/local/pgsql/data cd/usr/local. /pgsql/data chown postgres. postgres server. crt chown postgres. postgres server. key 7. Enable connection to the 192.168.0.1/24 CIDR Block 1) Modify postgresql. conf to the following line: listen_addresses = '*' 2) Modify pg_hba.conf and add the following line: hostssl all 192.168.0.1/24 trust 8. Add a password to ipvs 1) enter the command Method /Usr/local/pgsql/bin/pgsql mydb 2) change the password alter user postgres password 'yourpass' (md5 by default) and view it in the select * from pg_shadow table. 3) change the pg_cmd.conf file to hostssl all 192.168.0.1/24 md5 9. Enable the root user to log on locally as the ipvs user1) modify the file pg_mirror.conf local all ident omicron in the/usr/local/pgsql/data directory. 2) modify the file pg_ident.conf in the/usr/local/pgsql/data directory and add omicron root ipvs.
3) restart/etc/init. d/postgresql restart 4) use the command/usr/local/pgsql/bin/psql mydb-U postgres to access the database. 10. System Table ----System tables are the places where relational databases store structural metadata, such as tables and fields, and internal registration information. The system table of PostgreSQL is a common table. You can delete and recreate these tables, add columns, insert and update values, and then thoroughly collapse your system. We should not manually modify the system table. Generally, there are always SQL commands to do these tasks. In Pg_databaseThere are two useful signs available for each database: Field DatistemplateAnd Datallowconn. DatistemplateIndicates that the database is ready for use. CREATE DATABASE. If this flag is set, the database can CREATEDBPermission user cloning; if not set, only the super user and the database owner can clone it. If DatallowconnIf the flag is false, no new connection to the database will be allowed (however, the existing session will not be killed because the flag is set to false ). Template0Databases are usually marked Datallowconn = falseTo avoid modification. Template0And Template1Should always be marked Datistemplate = true.

Statement used to modify the tag: UPDATE pg_database SET datallowconn = true WHERE datname = 'template0 ';
11. Common SQL commands   12. md5 () Hash FunctionUpdate operator set password = 'md5' | substring (md5 ('yourpass') from 1 for 20 );                      
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.