我正在尝试更新我的pg gem,我收到以下错误
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/larson/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb --with-pg-config=/Library/PostgreSQL/9.1/bin/pg_config
Using config values from /Library/PostgreSQL/9.1/bin/pg_config
checking for libpq-fe.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/larson/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-pg
--without-pg
--with-pg-dir …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的 rails 应用程序安装到 Heroku,但是在尝试安装 pg gem 时遇到了问题。我被告知将 Gemfile 中的“gem 'sqlite3'”行替换为以下内容:
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_stdout_logging'
end
Run Code Online (Sandbox Code Playgroud)
然后执行捆绑安装。我收到此错误消息:
...
Using coffee-rails (3.2.2)
Using jquery-rails (3.0.4)
Installing pg (0.17.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes …Run Code Online (Sandbox Code Playgroud) 我已经查看了 SO 上所有安装 Postgres gem 时出现类似错误的帖子pg。
我的问题很独特:我可以通过 Gemfile 成功地将 Postgres 添加到我的 Sinatra Ruby 项目中,bundle install但是在构建 Docker 映像时,它安装失败pg,并出现以下错误:
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/pg-0.19.0/ext
/usr/local/bin/ruby -r ./siteconf20170113-7-ottv1k.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Run Code Online (Sandbox Code Playgroud)
我已经尝试了类似答案中建议的所有内容:
pg_config和 …我在 NodeJS 后端服务中使用 PostgreSQL。突然之间,当我启动服务时,我面临以下错误
connection error error: sorry, too many clients already.
Run Code Online (Sandbox Code Playgroud)
PostgresSQL 连接配置
const pg = require(“pg”);
const client = new pg.Client({
host: “txslmxxxda6z”,
user: “mom”,
password: “mom”,
db: “mom”,
port: 5025
});
Run Code Online (Sandbox Code Playgroud)
由于上述错误,我无法查询数据库。我无法解决这个问题。你能提出解决方案吗
我使用pg node-postgres 包为我的项目进行了以下设置:
简单的表 'tmp' 如下所示:
根据jsonORG和postgres 文档对象:
{"foo" : true}
Run Code Online (Sandbox Code Playgroud)
是语法上有效的 JSON,当使用 pgAdmin 查询工具时:
UPDATE tmp SET data = '{"foo": false}' WHERE id = '1'
Run Code Online (Sandbox Code Playgroud)
工作正常,但是当我尝试使用 pg 通过快速路由更新我的表时:
router.put('/updateTMP', (req, res) => {
// I use dummies in this case instead of req.body.someKey for testing purposes
let dummyJSON = {"foo":true};
let dummyID = 1;
pg.query(`UPDATE tmp SET data = '${dummyJSON}' WHERE id = '${dummyID}'`, (errUpdate, responseUpdate) => {
if (!errUpdate) { // NO ERROR …Run Code Online (Sandbox Code Playgroud) 我在转储和恢复我的一个数据库时遇到了问题,我认为是由于公共模式中的一些扩展所致。引发错误的扩展似乎是Cube扩展或EarthDistance扩展。这是我收到的错误:
pg_restore: [archiver (db)] Error from TOC entry 2983;
pg_restore: [archiver (db)] could not execute query: ERROR: type "earth" does not exist
LINE 1: ...ians($1))*sin(radians($2))),earth()*sin(radians($1)))::earth
QUERY: SELECT cube(cube(cube(earth()*cos(radians($1))*cos(radians($2))),earth()*cos(radians($1))*sin(radians($2))),earth()*sin(radians($1)))::earth
CONTEXT: SQL function "ll_to_earth" during inlining
Command was: REFRESH MATERIALIZED VIEW public.locationsearch
Run Code Online (Sandbox Code Playgroud)
我自己编写的一些函数也遇到了类似的不同问题,问题最终是搜索路径,因此明确地将这些函数的搜索路径设置为公开解决了我的问题。我尝试了同样的方法ll_to_earth,但似乎整个扩展都是问题。我真的不想尝试安装扩展,pg_catalog因为这似乎是不好的做法。
这是我典型的转储命令:
pg_dump -U postgres -h ipAddress -p 5432 -w -F t database > database.tar
其次是:
pg_restore -U postgres -h localhost -p 5432 -w -d postgres -C "database.tar"
-s包含数据的完整转储大约为 4GB,但我尝试仅使用和转储模式-F …
我有一个非常简单的 typeorm,pg 设置,脚本只是yarn dev。我以某种方式收到此错误。
AssertionError [ERR_ASSERTION]: unknown message code: 4a
at Parser.handlePacket (/Users/dmitriyshin.io/Desktop/Web/React/1. Courses Projects/Uber Clone with TypeScript, Apollo, GraphQL and NodeJS/nuber-server/node_modules/pg-protocol/src/parser.ts:198:16)
at Parser.parse (/Users/dmitriyshin.io/Desktop/Web/React/1. Courses Projects/Uber Clone with TypeScript, Apollo, GraphQL and NodeJS/nuber-server/node_modules/pg-protocol/src/parser.ts:101:30)
at Socket.<anonymous> (/Users/dmitriyshin.io/Desktop/Web/React/1. Courses Projects/Uber Clone with TypeScript, Apollo, GraphQL and NodeJS/nuber-server/node_modules/pg-protocol/src/index.ts:7:48)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
[nodemon] app crashed - waiting for file changes before starting...
Run Code Online (Sandbox Code Playgroud) 我一直在Rails中使用Postgres没有问题,并且一直运行psql没有问题.但是,我在尝试使用pggem 连接到数据库时遇到了问题.
以下代码:
PG.connect
Run Code Online (Sandbox Code Playgroud)
生成错误/输出:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
无论我是否指定了各种dbname:值,结果都是相同的,或者只是让这个默认值.
当我点击屏幕顶部的小象图标时,它会显示"在端口5432上运行",正如我所说,我可以psql毫无问题地连接.
我发现非常相似无法使用gem"pg"从我的Ruby脚本连接到Postgres(pg)数据库(这不是rails,只是纯粹的ruby),但答案只是说Rails工作正常.
任何指导将不胜感激.(注意:我意识到我没有输入任何名称/密码信息,但我没有必要输入比运行时psql我收集它没有达到认证点).
我的数据库非常受cpu限制,我找不到问题的根本原因.我目前有两个应用程序服务器,每个服务器都有一个通过ruby-pg gem连接到PostgreSQL的Rails api.两个应用程序服务器都有sidekiq运行后台作业,我有一些支持服务器通过sidekiq处理来自国家feed的新帖子.如果我的内存耗尽,解决方案似乎很简单.为什么我受CPU约束的任何一般想法?
数据库规格:
可能的问题:
该数据库有近10GB的索引.我要将我的数据库升级到PostgreSQL版本> = 9.2.在9.2版中,引入了仅索引扫描.
在postgresql.conf中,我将max connection设置为'500'.通常在一天中,只使用175个连接,但在高峰时段,sidekiq任务会将当前连接增加到350.建议与8GB服务器实例建立多少个连接?
当我在psql控制台中查看pg_stat_activity时,我看到sidekiq留下了很多IDLE连接.这些连接会导致CPU通胀吗?修复是否存在于api或sidekiq中?
也许没有错误.我可能只需要增加服务器实例.如果我受到记忆限制,这将更有意义.但是,app服务器和3个支持sidekiq服务器都是4gb性能层实例.实质上,与数据库交互的服务器组合了数据库资源的两倍以上.这甚至不重要吗?
其他问题:
我想执行此查询.
INSERT INTO items (title, description,
start_date,
expiration_date,
type,
quantity,
state,
sold,
cover_photo_file_name,
cover_photo_content_type,
cover_photo_file_size,
instructions)
VALUES
(
'some_test_value',
'lorem ipsum',
'2015-01-01 00:00:00',
'2015-06-10 00:00:00',
0,
19,
0,
0,
'RackMultipart20150317-10093-1ny4gmx.gif',
'image/gif',
157574,
{"lorem ipsum\r","dolor sit\r","loremloremipsumipsum 'sitsit' dolor sit"}
);
Run Code Online (Sandbox Code Playgroud)
我觉得非常讨厌
ERROR: syntax error at or near "{"
Run Code Online (Sandbox Code Playgroud)
当我尝试这样做的时候
ARRAY["Lorem ipsum\r", ...]
Run Code Online (Sandbox Code Playgroud)
我明白了:
ERROR: column "Lorem ipsum" does not exist
Run Code Online (Sandbox Code Playgroud)
问题是我现在无法更改数据库(我没有时间)所以我需要构建一个将"执行"该工作的查询(尽管此数据库需要使用DROP DATABSE进行规范化...)
我的代码出了什么问题?也许我错过了一些明显的东西,但我疲惫的心灵只是在跳过它.