标签: postgresql

有哪些好的 PostgreSQL 管理工具?

PostgreSQL 是否具有良好的性能或管理工具?

我已经使用 postgres 有一段时间了,但我仍然不知道很多关于优化和维护数据库并保持其运行良好的方法。

我已经浏览了手册,但由于它是一个相当成熟的产品,我假设它有几个“必备”实用程序?

postgresql

11
推荐指数
3
解决办法
1万
查看次数

在 postgres 中创建一个新的只读用户

我想postgresql在 Ubuntu 机器上的现有数据库中创建一个新用户。我想授予此用户对所有表的只读访问权限。

我该怎么做?我是否也需要在 Ubuntu 上创建一个新用户?

谢谢,

乌迪

postgresql user-management read-only

11
推荐指数
1
解决办法
2万
查看次数

无法在 VirtualBox 来宾上连接到 PostgreSQL

当我尝试从主机系统上的 PostgreSQL 客户端连接到 VirtualBox 来宾系统上的 PostgreSQL 服务器时,我收到一条“连接尝试失败”消息。

主机系统是Windows XP。我正在运行 VirtualBox 3.1.2。来宾系统是带有 PostgreSQL 8.4 的 Ubuntu 9.10 Karmic Koala。

我已经按照手册和这篇文章中的描述在 VirtualBox 中转发了端口 5432 。当我运行时vboxmanage getextradata vmname enumerate,我得到这些条目(以及其他条目):

Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/GuestPort, Value: 5432
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/HostPort, Value: 5432
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/Protocol, Value: TCP
Run Code Online (Sandbox Code Playgroud)

我在 /etc/postgresql/8.4/main/pg_hba.conf 中使用以下条目配置了 PostgreSQL 安全性:

# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
host    all         all         192.168.1.0/24        md5
host    all         all         10.0.2.2/32        md5
Run Code Online (Sandbox Code Playgroud)

然后我用sudo /etc/init.d/postgresql-8.4 reload.

仅出于诊断目的,我已禁用 Windows 防火墙和 Ubuntu 防火墙 ( sudo ufw …

postgresql ubuntu virtualbox

11
推荐指数
1
解决办法
2万
查看次数

删除大量行后是否需要重新索引和清空表?

我正在运行一个 PostgreSQL 数据库,它有几个存储日志信息的表。此信息仅用于报告目的,如果超过 30 天,则会转储到文件中并从数据库中删除。

可能有数百万行被删除,每次删除后我们都在运行一个 REINDEX。

这是否足够,或者我们还应该运行 VACUUM 或 VACUUM ANALYZE 吗?还是不需要 REINDEX 而我们应该只运行 VACUUM 或 VACUUM ANALYZE?

我们正在使用 PostgreSQL 8.2.3,我认为它不允许自动清空。

postgresql database-performance vacuum

11
推荐指数
1
解决办法
1万
查看次数

phpPgAdmin 导出空的 SQL 转储?

我正在尝试从 phpPgAdmin 导出 PostgreSQL 数据库,但出于某种原因,它正在转储一个空的 SQL 文件。

数据库肯定不是空的。

要导出它,我单击数据库,然后导出,然后选择结构和数据。

知道为什么会这样吗?谢谢

postgresql

10
推荐指数
2
解决办法
2万
查看次数

如何在 puppet 中为服务使用自定义状态命令?

我正在使用来自 backports 的 PostgreSQL 9.1 的 debian 挤压。Puppet 版本为 2.7.14。不幸的是,init 脚本返回了错误的状态退出代码。因此我编写了一个自定义status命令来检测 postgresql 是否正在运行。

service { 'postgresql':
  ensure => running,
  enable => true,
  hasstatus  => false,
  hasrestart => true,
  status => "pg_lsclusters -h | awk 'BEGIN {rc=0} {if ($4 != \"online\") rc=3} END { exit rc }'",
  provider => debian,
}
Run Code Online (Sandbox Code Playgroud)

我的命令像魔法一样有效,但 puppet 似乎有问题。notice: /Stage[main]/Postgresql/Service[postgresql]/ensure: ensure changed 'stopped' to 'running'尽管它已经在运行,但我总是得到。

所以尝试了以下方法:

service { 'postgresql':
  ensure => running,
  enable => true,
  hasstatus  => false,
  hasrestart => true,
  status …
Run Code Online (Sandbox Code Playgroud)

postgresql debian puppet debian-squeeze

10
推荐指数
1
解决办法
6925
查看次数

在 ubuntu 包上安装 postgres 不可用

我正在使用 Ruby 和 Postgres 设置 VPS。在我的本地机器上,我安装了 postgresql 9.2.3(客户端和服务器),因此想在我的 VPS 上安装它。按照这篇博客文章http://hendrelouw73.wordpress.com/2012/11/14/how-to-install-postgresql-9-1-on-ubuntu-12-10-linux/的说明在 ubuntu 上安装 postgres (唯一的区别是我尝试安装 9.2.3。而他安装了 9.1),我做了以下操作

sudo apt-get install postgresql-9.2.3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package postgresql-9.2.3
E: Couldn't find any package by regex 'postgresql-9.2.3'
Run Code Online (Sandbox Code Playgroud)

但是,如您所见,它找不到 package postgresql-9.2.3。然而,我在我的本地机器上安装了那个包(我用 Homebrew 安装在我的 Mac 上)。

你能帮我理解我做错了什么吗?

更新 我也尝试安装它,就像你在下面看到的那样,在末尾去掉“3”,但正如你所看到的那样,它不起作用。

 sudo apt-get install postgresql-9.2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package postgresql-9.2 is not available, but is …
Run Code Online (Sandbox Code Playgroud)

postgresql ubuntu

10
推荐指数
1
解决办法
4万
查看次数

如何使用 Chef 确保服务正在运行?

我的情况是,Chef 可能会启动一项服务 (postgres),但随后可能会在带外停止。我想要一个后续的 Chef 运行来导致服务运行。我试过这个:

service "postgresql" do
    action :start
end
Run Code Online (Sandbox Code Playgroud)

但它没有效果,(up to date)大概是因为 Chef 知道它已经启动并且无法判断它已经停止。(可能是由于service ... status此服务的行为方式?)如果我这样写:

# anti-pattern warning!
execute "force-start-postgresql" do
  command "service postgresql start || /etc/init.d/postgresql start"
  action :run
end
Run Code Online (Sandbox Code Playgroud)

我得到了想要的行为。也action :restart让它运行。然而,由于可移植性,这些看起来像是反模式(并且在后一种情况下可能会在再次启动之前停止它)。

那么,我如何告诉 Chef 强制启动该服务,即使它认为它已经在运行呢?

这是使用由 OpsCode 托管的 Chef 11.6 和默认的 postgresql 配方。(注意这很相似,但我认为与如何在 Chef 中强制对“最新”资源执行操作不完全相同?。)

---编辑(在 jtimberland 帖子后澄清)---

在-l debug这里显示:

DEBUG: service[postgresql] supports status, running
DEBUG: service[postgresql] is running
Run Code Online (Sandbox Code Playgroud)

即使它没有运行。所以这听起来像是一个错误,我对此很感兴趣。但是,我主要对是否有办法告诉厨师“始终调用服务启动命令,跳过状态检查”感兴趣。这就是这里的问题。

(我不是专家,但我认为确保服务运行的最便携方法是启动服务,这几乎总是幂等的。OTOH检查 …

postgresql service chef

10
推荐指数
1
解决办法
1万
查看次数

Munin Postgres 插件:未找到 DBD::Pg

我正在尝试为 Munin 激活一些 Postgresql 插件。当我运行时,munin-node-configure --suggest | grep postgres我得到以下输出:

postgres_bgwriter          | no   | no [DBD::Pg not found, and cannot do psql yet]
postgres_cache_            | no   | no [DBD::Pg not found, and cannot do psql yet]
postgres_checkpoints       | no   | no [DBD::Pg not found, and cannot do psql yet]
postgres_connections_      | no   | no [DBD::Pg not found, and cannot do psql yet]
postgres_connections_db    | no   | no [DBD::Pg not found, and cannot do psql yet]
postgres_locks_            | no   | …
Run Code Online (Sandbox Code Playgroud)

postgresql ubuntu munin perl

10
推荐指数
1
解决办法
4000
查看次数

使用 psql 命令行界面设置连接超时

有没有办法使用psqlcli 设置连接超时?如何使用以下命令将连接超时设置为 3 秒之类的低值:

PGPASSWORD=passwordhere psql -h 10.0.0.144 -U myuser -c "select 1" -d mydatabase
Run Code Online (Sandbox Code Playgroud)

据我所知,psql不支持连接超时参数。在上面的示例中,10.0.0.144该命令无效并且挂起很长时间。如果主机不正确,我需要命令快速失败。

postgresql psql

10
推荐指数
1
解决办法
1万
查看次数