Linux/Unix -- database postgreSQL installation and configuration

Source: Internet
Author: User
Master software installation and maintenance, configuration, and other skills in the Linux/Unix environment as required. Here I will record my usage experiences and share them with you. Take database installation as an example (note: The above installation is based on source code ). The following Li...

Master software installation and maintenance, configuration, and other skills in the Linux/Unix environment as required. Here I will record my usage experiences and share them with you. Take database installation as an example (note: The above installation is based on source code ). The following Linux systems are installed on virtual machines and linux enterprise 5 is used.
Prerequisites: virtual machine software and file upload tools that can be used.
First, explain how to install the database. Postgresql 8.4 is used as an example. Http://www.postgresql.org/ftp/source/
Step 1: Download the data warehouse source code package (postgresql-8.4.0.tar.gz). you can download the package from the Windows system and upload it to the Linux system directory (assuming the/opt directory );
Step 2, execute the tar command to decompress the file (tar-zxvf postgresql-8.4.0.tar.gz), decompress the package and generate a postgresql-8.4.0 folder;
Step 3: Create a user group and user postgres (note: The name must be postgres, because the database can only be started by postgres users). the default user of the database is postgres, you can set the postgres password if you do not have one in the system (addgroup postgres, adduser postgres;
Step 4: create the installation path (put my path under/usr): mkdir/usr/local/postgresql8.4; set the access user chown postgres: S/usr/local/postgresql8.4. You can also switch to postgres before creating the folder: su postgres password; mkdir/usr/local/postgresql8.4. now the installation is complete.
Step 5, go to the decompress the generated folder postgresql-8.4.0 and execute. /configure -- prefix =/usr/local/postgresql8.4. this command configures the database installation information to the newly created folder, detects the software environment required for installation, and waits patiently for several minutes.
Step 6: execute the make command to tell the system analysis, parse, compile the source code, and generate a binary file. this process takes about 15 minutes.
Step 7: execute the make install command, which tells the system to install the compiled binary file. this process takes about 10 minutes.
So far, the database installation is complete. Next, install the database instance.
Next, install the database instance and start the application.
The first step is to ensure that the system uses IPVs. if not, it switches the user to IPVs;
Step 2: Check whether/usr/local/postgresql8.4/data exists in the system. if no data exists, create the directory;
Step 3: switch the working directory to/usr/local/postgresql8.4/bin;
Step 4: Execute./initdb [Database instance name] to create a database instance. wait a few minutes.
Step 5: execute. /pg_ctl-D/usr/local/postgresql8.4/data-l syslogs start can start the database. Command description:-D + path indicates the path to store the database data information file, -l syslogs indicates logging to the specified file.
Step 6: Run./psql [user name] to enter the database operation Console platform. The operation indicates that the database is successfully installed.
So far, the database instance has been installed. if you want to use the database as a server to provide access services, you need to make necessary configurations. Next, configure the database information so that computers in the Lan (or public network) can use the database.
Step 1: modify the configuration file of postgresql. conf, switch the directory to/usr/local/postgresql8.4/data, and modify postgresql. conf. do you know how to modify it? Don't know? Modify and scatter VI, and remove # before # listen_addresses = 'localhost'. this is the listening location where you can change localhost to the IP address of the Linux system (or modify the configuration information in/etc/hosts, the IP address bound to the localhost), # port = 5432 is the same #, because this is the listening port.
Step 2: modify the pg_cmd.conf configuration file
# IPv4 local connections:
Host all 127.0.0.1/32 trust
Host all 192.168.18.1/24 trust (in this way, other computers can be accessed)
Step 3: modify the firewall configuration (this is the most important), open port 5432, and add the following configuration to VI edit/etc/sysconfi/iptables:
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 5432-j ACCEPT
Save and restart the firewall, services iptables restart.
So far, the database installation and configuration have been completed. you can use the database client installed on other computers for connection.

The installation of the software provides another method, binary file installation (that is, run the binfile), the installation steps are as follows:
Step 1: switch the working directory to the binfile directory to check whether the binfile has the executable permission (green if the color resolution is available). If no, run chmod 755 xxx. bin (or chmod a + x xxx. bin );
Step 2: Run./xxx. bin to install the database in the/usr/local directory.
The subsequent operations are the same as those for database configuration.
 
To use the database as a daemon, modify the configuration for linux in the initially decompressed folder (my:/opt/postgresql-8.4/contrib/start-scripts. Prefix =/usr/local/postgresql8.4 [line feed] PGDATA = "/usr/local/postgresql8.4/data" [line feed] PGLOG = "/usr/postgresql8.4/log/pgsql. log "(note: these three parameters exist in the configuration file. you only need to modify the value following ).
Save and exit the configuration file, copy the configuration file to the/etc/init. d Directory, and change the file name to postgresql (it is recommended to modify this name for future maintenance ). Run chmod + x postgresql to set the configuration file to an executable attribute. run chkconfig -- add postgresql to add the configuration file to the startup service list and run service restart SL start.

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.