CentOS7 installation PostgreSQL9.4

Source: Internet
Author: User
Tags postgresql

The selected database is installed with the run file, which is easier to master. This database is all the default installation, if there is a need to modify the self.

This is my first blog, the audience master, if you feel where there is anything bad, you can leave a message to explore and discuss. There are problems can also learn together.

One , open the centos7 ssh

Because my CentOS7 is newly installed, so I need to love to open ssh, if you are already in use, this is ignored.

1.1 setting up a static IP

1.1.1 Enter the/etc/sysconfig/network-scripts/ directory to find the configuration file for the network to be modified and modify it .

Example : Vim/etc/sysconfig/network-scripts/ifcfg-eth0

1.1.2 Modify the following content

    1. bootproto= "Static" #dhcp改为static
    2. onboot= "Yes" #开机启用本配置
    3. ipaddr=192.168.200.106 #静态IP
    4. gateway=192.168.200.1 #默认网关
    5. netmask=255.255.255.0 #子网掩码
    6. dns1=192.168.99.99 #DNS Configuration

1.1.3 Final Effect

  1. #]# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
  2. Hwaddr= "00:15:5d:07:f1:02"
  3. Type= "Ethernet"
  4. bootproto= "Static" #dhcp改为static
  5. Defroute= "Yes"
  6. Peerdns= "Yes"
  7. Peerroutes= "Yes"
  8. Ipv4_failure_fatal= "No"
  9. ipv6init= "Yes"
  10. ipv6_autoconf= "Yes"
  11. Ipv6_defroute= "Yes"
  12. Ipv6_peerdns= "Yes"
  13. Ipv6_peerroutes= "Yes"
  14. Ipv6_failure_fatal= "No"
  15. Name= "Eth0"
  16. Uuid= "Aa7e302d-dc46-54u8-881e-d46cafd0nm98"
  17. onboot= "Yes" #开机启用本配置
  18. ipaddr=192.168.7.106 #静态IP
  19. gateway=192.168.7.1 #默认网关
  20. netmask=255.255.255.0 #子网掩码
  21. dns1=192.168.7.1 #DNS Configuration

1.1.4 Restart Service

    1. # Service Network Restart
1.2 open ssh

1.2.1 entering the sshd configuration file

Vi/etc/ssh/sshd_config

Open Port 22

put Passwordauthentication Set as Yes

Find #PermitRootLogin no to modify it to permitrootlogin Yes

Service sshd Restart Restart Services

two,installationpostgresql-9.4 Runfile 2.1 Installation : under root

2.1.1 -Fool installation

[Email protected] opt]# chmod 777 Postgresql-9.4.12-1-linux.run

[Email protected] opt]#./postgresql-9.4.12-1-linux.run

install directly to opt/postgresql/by default

In the middle only set user postgres password Note

2.2 assigning configuration files to postgres users ( can skip )

2.2.1 Copying a configuration file

    1. [Email protected] opt]# Su-postgres
    2. -bash-4.6$ pwd
    3. /opt/postgresql/9.4
    4. -bash-4.6$ Su-
    5. Password:
    6. [email protected] ~]# CP. bash_profile/opt/postgresql/9.4
    7. [email protected] ~]# CP. bashrc/opt/postgresql/9.4
    8. [Email protected] ~]# Su-postgres

2.2.2 changing file permissions

    1. [Email protected] postgresql]# pwd
    2. /opt/postgresql
    3. [Email protected] postgresql]# chown-r postgres:postgres/opt/postgresql/
    4. [email protected] postgresql]# LL
    5. Total 4
    6. Drwxr-xr-x postgres postgres 4096 4 months 18:52 9.0

4

2.2.3 Then set the environment variables for the Postgres user

    1. Export pghome=/opt/postgresql/9.4
    2. Export path= $PGHOME/bin: $PATH
    3. Export Pgdata= $PGHOME/data
    4. Export Ld_library_path= $PGHOME/lib

2.2.4 then we can start the service, in fact the default service and start the

    1. [[Email protected] ~]# service postgresql-9.4 start

2.2.5 checking ports and service status

  1. [Email protected] ~]# chkconfig--list postgresql-9.4
  2. postgresql-9.4 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  3. [Email protected] ~]# Netstat-ano | grep 5432
  4. TCP 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN off (0.00/0/0)
  5. TCP 0 0::: 5432:::* LISTEN off (0.00/0/0)
  6. UNIX 2 [ACC] STREAM LISTENING 3759370/tmp/.s.pgsql.5432

Direct configuration under 2.3 root ( Skip 2.2)

this does not have to assign permissions , let the root permission to do

Configure directly under root . Bash_profile

Export pghome=/opt/postgresql/9.4

Export Pgdata= $PGHOME/data

Path= $PATH: $HOME/bin: $PGHOME/bin

start the service to see the same ports

2.4 configuration pg_hba.conf

# IPV4 Local connections:

Host All 127.0.0.1/32 MD5
Host All 0.0.0.0/0 MD5

2.5 Set self-boot , open port

Sometimes it is not connected , it is possible that the 5432 is closed so need to reopen

Start the service and set it to boot

Systemctl Enable postgresql-9.4

Systemctl Start postgresql-9.4

Open firewall Port

Firewall-cmd--permanent--add-port=5432/tcp

Firewall-cmd--permanent--add-port=80/tcp

Firewall-cmd--reload

Appendix a reference to some questions

how to CentOS 7 configuration static IP address
http://Linux. cn/article-3977-1.html
in the Assign multiple IP addresses to a network adapter on CentOS 7
Https://linux.cn/article-5127-1-rel.html

PostgreSQL installation ( under linux )

Http://jingyan.baidu.com/article/4f7d5712cf761e1a20192784.html

SSH Login failed, prompting "Password authentication failed"

http://m.blog.csdn.net/article/details?id=6045176

error :: Could not connect to server:Connection refused (0x00002740/10061)

is the server running on host "xxx.xxx.xx.xx" and accepting

TCP/IP connetions on port 5432?

Http://m.ithao123.cn/content-5942383.html

Centos7 PostgreSQL Installation

http://m.blog.csdn.net/article/details?id=50359549

Common Linux directives

CentOS7 installation PostgreSQL9.4

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.