`
iwindyforest
  • 浏览: 236872 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Install Postgresql9.3 on CentOS

 
阅读更多

Install Postgresql Server 9.3

 

first, we need to add official postgresql repository for yum:

sudo yum install http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm

second, install by yum:

sudo yum install postgresql93-server postgresql93-contrib

after that, init database:

sudo service postgresql-9.3 initdb

finally, set postgresql service start automatically:

sudo chkconfig postgresql-9.3 on

And, startt the server:

sduo service postgresql-9.3 start

 

Configure Server for user access

change password for user postgres:

sudo passwd postgres

 

su as postgres, and log into pg sql server to set password of postgres on pgsql sever:

[Ivar@localhost ~]$ su - postgres
密码:
-bash-4.1$ psql
psql (9.3.4)
输入 "help" 来获取帮助信息.
postgres=# alter user postgres with password 'postgres'

Quit from user postgresql shell, and vim open postgresql.conf

sudo vim /var/lib/pgsql/9.3/data/postgresql.conf

change the value of lisen_address to '*", means server would lisent on all IP addresses:

# - Connection Settings -
listen_addresses = '*'                  # what IP address(es) to listen on;

 

save and open pg_hba.conf add the ip address or segment you would allow them to get connected on pgsql server:

sudo vim /var/lib/pgsql/9.3/data/pg_hba.conf

 

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                                    md5
# IPv4 local connections:
host    all             all             127.0.0.1/32                  md5
host    all             all             192.168.0.0/24            md5
host    all             all             192.168.84.0/24          md5
host    all             all             192.168.184.0/24        md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Note, here 192.168.0.0/24 means an IP segment from 192.168.0.1 to 192.168.0.255

/24 meas its mask is 255.255.255.0 (24 bits).

 

change fire wall policy for connection access from port 5432:

[Ivar@localhost ~]$ sudo /sbin/iptables -I INPUT -p tcp --dport 5432 -j ACCEPT
[Ivar@localhost ~]$ sudo service iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]
[Ivar@localhost ~]$ sudo service iptables restart
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
iptables:应用防火墙规则:                                 [确定]
[Ivar@localhost ~]$ sudo service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination        
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:5432
2    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
3    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0          
4    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
6    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination        
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination    

 

 

restart server

sudo service postgresql-9.3 restart

 

create user for your own, here mine is Ivar:

 

[Ivar@localhost ~]$ psql -h localhost  -U postgres
用户 postgres 的口令:
psql (9.3.4)
输入 "help" 来获取帮助信息.

postgres=# CREATE ROLE admin
postgres-#   NOSUPERUSER INHERIT CREATEDB CREATEROLE REPLICATION;
CREATE ROLE
postgres=# CREATE USER 'Ivar' WITH PASSWORD 'password';
CREATE ROLE

 

logon by your own user and create test database

[Ivar@localhost ~]$ psql postgresql

postgres=# CREATE DATABASE test

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

分享到:
评论

相关推荐

    Linux CentOS 7安装PostgreSQL9.3图文教程

    在Linux CentOS 7环境下安装PostgreSQL 9.3是一个常见的任务,尤其对于那些需要搭建数据库服务器的用户来说。本文将详细讲解如何通过二进制安装包来安装这个关系型数据库管理系统。 首先,确保你的系统已经更新到...

    chef_zabbix22_with_postgresql9:厨师独奏食谱 Zabbix 2.2 和 PostgreSQL9.3

    厨师独奏食谱 Zabbix 2.2 和 PostgreSQL9.3 #描述 本说明书包含 Zabbix2.2 服务器和 Postgresql9.3。 并且它不包含 Zabbix Agent。 它在 Sakura Internet VPS 上进行了测试。(CentOS6.5)我用其他厨师食谱...

    CentOS安装Postgresql数据库

    chkconfig postgresql-9.3 on ``` - **对于CentOS 7系统:** ```bash systemctl enable postgresql-9.3 systemctl start postgresql-9.3 ``` ##### 2.6 配置防火墙 为了确保外部可以访问PostgreSQL服务,还...

    CentOS7 安装 PostgreSQL11的方法步骤

    记住,PostgreSQL不仅是一个传统的SQL数据库,从9.3版本开始支持JSON数据类型,9.4版本开始支持JSONB,使其具有一定的NoSQL能力。因此,无论你是SQL爱好者还是NoSQL开发者,PostgreSQL都是一个值得探索的选择。在...

    postgresql及tomcat安装文档

    安装 PostgreSQL 需要先安装相应的存储库 RPM,命令为:yum install https://download.postgresql.org/pub/repos/yum/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-2.noarch.rpm 2. 安装客户端软件包: 安装 ...

    posrgresql安装文件 linux

    apt-get install postgresql-9.3 ``` 对于基于RPM的系统(如CentOS/RHEL),可以使用`yum`来安装: ```bash sudo yum install ...

    Postgresql连接oracle驱动并实现读写

    - 在PostgreSQL 9.3及以上版本,`oracle_fdw`支持对远程Oracle表的插入、删除和更新操作。 ```sql CREATE FOREIGN TABLE ora.a ( prod_id int8 OPTIONS (key 'true'), offer_spec_name varchar(1600) COLLATE ...

Global site tag (gtag.js) - Google Analytics