我正在尝试远程连接到 Postgres,但我需要在 iptables 中打开端口 5432。我目前的iptables配置如下:
*filter
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allows all outbound traffic
# You can modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
# Allows HTTP and HTTPS connections from anywhere (the normal …Run Code Online (Sandbox Code Playgroud) 我有一个磁盘阵列设备,每个磁盘有 8 个 1T(UltraStor RS8IP4)。它将仅由 PostgresQL 数据库使用,我正在尝试为其选择最佳 RAID 级别。
最优先考虑的是读取性能,因为我们操作大型数据集(表、索引)并进行大量搜索/扫描。对于我们现在拥有的旧磁盘,SELECT 的速度最慢。
容错不太重要,可以是 1 或 2 个磁盘。
空间是最不重要的因素。1T就够了。
在这种情况下,您会推荐哪种 RAID 级别。当前的选项是 60、50 和 10,但其他选项可能会更好。
我习惯了 debian/ubuntu 发行版,现在尝试使用官方的 Amazon AWS Linux AMI。
我已经安装了 postgresql-server、postgresql-devel、postgresql-contrib yum 包。
问题是我缺少pg_lsclusters、pg_ctlcluster等命令。
我应该安装什么其他软件包来获取这些命令。或者它们仅在基于 Debian 的发行版上可用?
“checkpoint_segments”这个参数我不是很了解,我个人的看法是它的意思是wal日志文件的数量;我把参数的值配置为64,但是在pg_xlog目录下可以看到131个文件。
有人能解释一下参数吗?
--detail
postgres=# show checkpoint_segments;
checkpoint_segments
---------------------
64
(1 row)
[postgres@pg_root]$ cd $PGDATA
[postgres@pg_root]$ ls -lrt pg_xlog | wc -l
132
Run Code Online (Sandbox Code Playgroud) 您好,感谢您的阅读。
我正在开发一个分布式系统,有 8 个集群,每个集群都有一个 Postgres 实例。但是,与其他实例相比,其中一个 Postgres 实例写入数据的速度非常慢。所有计算机都运行相同版本的 Ubuntu,安装了相同的规格和相同的 Postgres 版本。
这是我所做的:
对于慢速集群,我有以下执行时间(以秒为单位):
Create Data with Java WriteData
92 11055
Run Code Online (Sandbox Code Playgroud)
对于其他集群,我有更多这样的东西:
Create Data with Java WriteData
95 266
Run Code Online (Sandbox Code Playgroud)
我已经检查过表空间是否有足够的磁盘空间,并且还完全重新安装了 Postgres 实例,但不知道可能是什么问题。
感谢您的任何建议,我可以在其中寻找潜在问题!
更新:
一些性能参数:
diskSlow: sudo hdparm -t /dev/sda6
/dev/sda6: Timing buffered disk reads: 76 MB in 3.05 seconds = 24.92 MB/sec
diskOther: sudo hdparm -t /dev/sda6
/dev/sda6: Timing buffered disk reads: 314 MB in 3.00 seconds = 104.62 MB/sec
Run Code Online (Sandbox Code Playgroud)
时间缓存读取是可比的。
UPDATE2: 好的,我发现最近重新安装了慢速集群并且有更新的Ubuntu版本。
SlowCluster OtherClusters:
Release: Ubuntu …Run Code Online (Sandbox Code Playgroud) 我忘记了 postgresql 根用户的密码:postgres
所以我改变pg_hba.conf拥有trust的一切方法(这是我的本地开发框)
local all postgres trust
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
Run Code Online (Sandbox Code Playgroud)
重新启动服务后,它仍然要求我输入密码。
@omnipresent:~$ su - postgres
Password:
su: Authentication failure
Run Code Online (Sandbox Code Playgroud)
虽然,我可以登录 psql -U postgres
@omnipresent:~$ psql -U postgres
psql (8.4.8)
Type "help" for help.
postgres=#
Run Code Online (Sandbox Code Playgroud)
我陷入了困境,此时我只想为 postgresql 创建一个新角色并使该用户成为管理员。
在这种情况下我该怎么做?
我想在启动时将 PostgreSQL 服务器指向一个特定的非默认数据目录。现在,我必须(手动或在脚本中)使用 pg_ctl 来停止和重新启动数据库/new/path/to/data。
操作系统是 Ubuntu,默认数据目录是 /var/lib/postgresql/8.4/main
我想将我的 postgresdata文件夹移动到 NFS 驱动器,但我不确定什么是最好的方法。我想到了三个选择:
根据Postgres Documentation,一种方法是使用initdb带有-D选项的命令。
initdb如果您指定的目录不存在,则将尝试创建该目录。
LinuxQuestions.org上列出的另一种方法是更新postgressqlinit 脚本以指向新目录,在本例中为 NFS 驱动器。
最后,我想我只是将pgsql/data文件夹复制到 NFS 驱动器,然后简单地对文件夹进行符号链接。
IE, pgsql/data -> nfs/data
符号链接或更新 init 脚本对我来说似乎是最简单的方法,但我不确定它们是最好还是最安全的方法。这是我希望有人可以帮助我的地方。任何建议、顾虑和优点/缺点将不胜感激。
环境信息
假设 NFS 驱动器是使用-maproot=root选项安装的,并且root用户可以访问 NFS 驱动器。
我正在尝试确定在 Amazon EC2 上备份 PostgreSQL 数据库的最佳方法。我已经阅读了几个选项。
1) 为您的数据库正在使用的 EBS 卷拍摄每日快照。
我看到这种方法的问题是在写入过程中拍摄快照时会发生什么?我的数据不会被破坏吗?
2) 使用 pg_dump,压缩文件并存储在 S3 中。
pg_dump 不会创建损坏的数据,但是从 pg_dump 恢复数据库可能很耗时
应该使用什么策略?选项 1 似乎很诱人,因为它更容易执行和恢复,但我使用这种方法是否冒险?
我需要安装earthdistance,一个 Postgresql 的扩展。它的页面说:
Earthdistance 模块提供了两种不同的方法来计算地球表面的大圆距离。首先描述的依赖于cube包(必须在安装earthdistance之前安装)。第二个基于内置点数据类型,使用经度和纬度作为坐标。
这似乎是真的。。
dealermade=# CREATE EXTENSION earthdistance FROM unpackaged;
ERROR: required extension "cube" is not installed
Run Code Online (Sandbox Code Playgroud)
但是,我不能安装cube任何
dealermade=# CREATE EXTENSION cube FROM unpackaged;
ERROR: type "cube" does not exist
Run Code Online (Sandbox Code Playgroud)
cube扩展需要cube它提供的类型似乎很尴尬。我正在使用PostgreSQL 9.1.1. 我在 Ubuntu 上执行此操作,并且postgresql-contrib-9.1安装了配套软件包。也就是说,cube.sql我的系统上没有。
如果我尝试earthdistance.sql直接安装,我会得到这个
$ psql -d db -f /usr/share/postgresql/9.1/extension/earthdistance--1.0.sql
CREATE FUNCTION
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:31: ERROR: type "cube" does not exist
CREATE FUNCTION
CREATE FUNCTION
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:49: ERROR: type "earth" does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:55: …Run Code Online (Sandbox Code Playgroud) postgresql ×10
amazon-ec2 ×2
performance ×2
hard-drive ×1
iptables ×1
migration ×1
nfs ×1
raid ×1
ubuntu ×1
ubuntu-10.10 ×1
ubuntu-11.04 ×1
yum ×1