AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-154418

Channa's questions

Martin Hope
shiwanginio
Asked: 2023-12-09 17:34:09 +0800 CST

错误:访问方法“btree”的运算符类不存在

  • 5

我在尝试执行脚本时遇到问题。这是场景:


-- Script to create collation
CREATE COLLATION case_insensitive 
(PROVIDER = icu, LOCALE ='und-u-ks-level2', DETERMINISTIC = FALSE);

-- Followed by adding an index using the collation
CREATE UNIQUE INDEX col1_idx ON my_table (col1 case_insensitive);

遗憾的是,在索引过程中,我遇到了以下错误:


SQL Error [42704]: ERROR: operator class "case_insensitive" does not exist for access method "btree"

我已经检查过pg_opclass表,但它不存在:

SELECT * FROM pg_opclass WHERE opcname = 'case_insensitive';

知道我在这里做错/错过了什么吗?如果您对此有任何见解或帮助,我将不胜感激。

postgresql
  • 1 个回答
  • 28 Views
Martin Hope
Channa
Asked: 2021-06-09 12:00:41 +0800 CST

错误 1180 (HY000):提交期间出现错误 5

  • 1

我们正在使用 Galera 集群,我正在运行下面的语句来创建一个新表:

   create table tab2 select distinct id , report from my_table ;

它运行了一段时间,然后失败/取消并出现以下错误:

   ERROR 1180 (HY000): Got error 5 during COMMIT

我搜索了这个错误,发现如果我们设置全局变量 binlog_row_image=minimal 那么问题应该已经消失了。但是,在我的情况下并没有发生这样的事情。我跑到下面,甚至在我检查之后 - 它是在 FULL binlog_row_image。

   mysql> select @@binlog_row_image;
  +--------------------+
  | @@binlog_row_image |
  +--------------------+
  | FULL               |
  +--------------------+
  1 row in set (0.00 sec)

  mysql> SET GLOBAL binlog_row_image=minimal;
  Query OK, 0 rows affected (0.00 sec)

而且,因为即使在我的新表创建查询失败之后它也没有改变。任何,其他方式来完成它?我只需要在现有表中创建我的新表。

提前致谢!

mysql mysql-5.7
  • 1 个回答
  • 1222 Views
Martin Hope
Channa
Asked: 2020-07-09 11:07:27 +0800 CST

无法使用bloom创建部分索引

  • 0

我是bloom索引的新手,目前我的表在WHERE子句中的同一列有3个部分索引,并且同一个表有不同的列组合。我试图用 1 个bloom index 替换它们。

WHERE但是,当我使用以下语法创建带有子句的bloom索引时,出现以下错误:

CREATE EXTENSION bloom;

CREATE INDEX idx_bloom_bar ON message USING bloom  
(s, p, c, m, e, id) 
WHERE (islatest = true)
WITH (length=56, col1=4, col2=4, col3=4, col4=4, col5=4, col6=4);
SQL Error [42601]: ERROR: syntax error at or near "WITH"
Position: 165

但是,如果没有WHERE子句,我可以成功创建此索引。

请让我知道我们是否可以将它们用作多个部分索引的替换或不减少我表上的索引数量。

postgresql index
  • 1 个回答
  • 34 Views
Martin Hope
Channa
Asked: 2019-12-07 02:31:33 +0800 CST

Postgres 的分区表行为

  • 0

我创建了一个带有 1 个分区的分区表。下面是相同的脚本:

CREATE TABLE public.ms (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
a int8 NOT NULL,
b int4 NOT NULL,
c varchar(2000) NULL,
d int2 NOT NULL,
e bool NOT NULL DEFAULT false,
f timestamp NOT NULL DEFAULT timezone('UTC'::text, CURRENT_TIMESTAMP),
g jsonb NULL,
h int2 NOT NULL DEFAULT 1,
i bool NOT NULL DEFAULT true,
j int2 NULL,
CONSTRAINT me_pkey PRIMARY KEY (id)
)PARTITION BY RANGE (id) ; 


CREATE TABLE ms3_0  PARTITION OF public.msg
FOR VALUES FROM (1) to (1000);

现在,当我通过下面的循环为此运行插入语句时,我收到以下错误消息:

do $$
begin
for i in 1..1000
loop
INSERT INTO public.ms
(a, b, c, d, e, f,  h, i , j)
VALUES(2, 0, '', 0, false, '2019-01-28 23:59:51', 1, true, 0);
end loop;
end;$$

SQL 错误 [23514]:错误:没有为行详细信息找到关系“ms”的分区:失败行的分区键包含 (id) = (1001)。

但是,直到 id '1000',分区已经创建。之后,我删除了现有表并再次重新创建了相同的表和分区。现在,我开始通过单个“插入”语句手动插入记录。然后,我可以插入它们。

之后,我创建了第二个分区,如下所示:

CREATE TABLE ms3_1  PARTITION OF public.ms
FOR VALUES FROM (1001) to (2000);

并且,再次对 1000 个条目执行相同的循环并得到以下错误:

SQL 错误 [23514]:错误:没有为行找到关系“ms”的分区详细信息:失败行的分区键包含 (id) = (1000)

但是,当我插入 100 批次时,如下所示:我可以插入:

do $$
begin
for i in 0..100
loop
INSERT INTO public.ms
(a, b, c, d, e, f,  h, i, j)
VALUES(2, 0, '', 0, false, '2019-01-28 23:59:51', 1, true, 0);
end loop;
end;$$

从上面的整个场景中,我有一些疑问:

  1. 在第一种情况下,为什么在已经创建前 1000 个值的分区时没有将数据(1000 个值)插入第一个分区?
  2. 在将 3-4 条记录插入第一个分区然后再次创建另一个具有 1000 条记录的分区 (ms3_1) 之后,当我尝试将 1000 条记录批量插入到同一个 ms 表中时,为什么我无法做到这一点?

任何帮助/原因都将在这里受到赞赏。因为,它将帮助我根据我的业务需求配置分区。

postgresql partitioning
  • 1 个回答
  • 1716 Views
Martin Hope
Channa
Asked: 2019-11-26 03:12:16 +0800 CST

FDW 在 postgres 中的使用

  • 0

我需要创建一个序列,并且需要将序列用于 2 个单独服务器上的 2 个以上数据库的自动增量 ID。我指的是下面的文档(出于测试目的):https ://paquier.xyz/postgresql-2/global-sequences-with-postgres_fdw-and-postgres-core/

我已按照以下步骤操作:

    Server 1: 
CREATE DATABASE
postgres=# \c a1
You are now connected to database "a1" as user "postgres".
a1=# CREATE SEQUENCE seq;
CREATE SEQUENCE
a1=# CREATE VIEW seq_view AS SELECT nextval('seq') as a;
CREATE VIEW
a1=# \c postgres
You are now connected to database "postgres" as user "postgres".

postgres=# create database a2;
 CREATE DATABASE
 postgres=# \c a2;
You are now connected to database "a2" as user "postgres".
a2=# CREATE EXTENSION postgres_fdw;
CREATE EXTENSION
a2=# CREATE SERVER postgres_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS
a2-# (host '192.168.xx.xxx', port '5432', dbname 'a1');
CREATE SERVER
a2=# CREATE USER MAPPING FOR PUBLIC SERVER postgres_server OPTIONS (password 
'');
CREATE USER MAPPING
a2=# CREATE FOREIGN TABLE foreign_seq_table (a bigint) SERVER
a2-# postgres_server
a2-# OPTIONS (table_name 'seq_view');
CREATE FOREIGN TABLE
a2=# select * from foreign_seq_table;
 a
---
 1
(1 row)

a2=# select * from foreign_seq_table;
a
---
2
(1 row)

从上面的示例可以看出,它在同一台服务器上的 2 个数据库上正常工作。但是,当我继续使用另一台服务器时,我在那里执行了以下步骤:

    postgres=# create database kbc;
CREATE DATABASE
 postgres=# \c kbc
You are now connected to database "kbc" as user "postgres".
kbc=#  CREATE EXTENSION postgres_fdw;
CREATE EXTENSION
kbc=# CREATE SERVER postgres_server FOREIGN DATA WRAPPER postgres_fdw 
OPTIONS
kbc-# (host '192.168.xx.xxx', port '5432', dbname 'a1');
CREATE SERVER
kbc=# CREATE USER MAPPING FOR PUBLIC SERVER postgres_server OPTIONS 
(password '');
CREATE USER MAPPING
kbc=#
kbc=# CREATE FOREIGN TABLE foreign_seq_table (a bigint) SERVER 
postgres_server OPTIONS (table_name 'seq_view');
  CREATE FOREIGN TABLE
 kbc=# select * from foreign_seq_table;
  ERROR:  could not connect to server "postgres_server"
    DETAIL:  fe_sendauth: no password supplied

我终于收到了错误。我在这里缺少什么/任何步骤。我可以从新服务器(我想在其中使用该序列)轻松 ping 到旧服务器(我在其中创建序列)。两台服务器上的 pg_hba.conf 文件设置 -> 那里的条目是 md5 或仅信任。我需要添加到配置文件中的任何其他条目吗?任何跨不同服务器的 fdw 建议文档也将有所帮助。

提前致谢!

注意:由于某些应用程序要求,我不能使用 UUID。这就是我们需要一个自动递增数字列的原因。它选择最高的 id 值。

postgresql sharding
  • 1 个回答
  • 611 Views
Martin Hope
Channa
Asked: 2019-09-25 10:55:26 +0800 CST

需要有关 sys.dm_os_buffer_descriptors 的详细信息

  • -2

我试图在互联网上搜索很多关于 dmv 的信息,但搜索不多。我无法理解此 dmv 的某些列的含义。哪个是:

  • pg_level
  • allocation_unit_id
  • 行数
  • numa_node 请分享这个的意思,如果有人对此有任何想法的话。
sql-server dmv
  • 1 个回答
  • 75 Views
Martin Hope
Channa
Asked: 2019-09-20 02:27:43 +0800 CST

pg_basebackup 从另一台服务器失败

  • 0

我想从另一台服务器备份我的 PostgreSQL 数据库集群。我正在使用来自另一台服务器的以下命令:

[root@shiwangini2 pgsql]# sudo -u postgres  pg_basebackup -h 192.168.XX.XX  -p 5432  -Ft -D /var/lib/pgsql/db_file_backup

但是,运行此命令后我收到以下消息:

[root@shiwangini2 pgsql]# sudo -u postgres  pg_basebackup -h 
192.168.XX.XX  -p 5432  -Ft -D /var/lib/pgsql/db_file_backup 
Password:

pg_basebackup:无法从服务器获取预写日志结束位置:错误:无法打开文件“./pg_hba.conf”:权限被拒绝 pg_basebackup:删除数据目录“/var/lib/pgsql/db_file_backup”的内容

为了解决这个问题,在谷歌搜索后,我更新了服务器的 pg_hba.conf 文件,如下所示,以允许来自外部的连接:

host    all             all              0.0.0.0/0                       
md5
host    all             all              ::/0                            md5

之后我重新启动了 PotgreSQL 服务。同样,当我尝试从另一台服务器备份它时,我仍然遇到同样的错误。如果我在这里做错了什么,请告诉我。或任何其他方式从另一台服务器获取备份。

postgresql backup
  • 2 个回答
  • 1931 Views
Martin Hope
Channa
Asked: 2019-08-31 06:00:29 +0800 CST

11.5 中的 postgresql recovery.conf 文件位置

  • 0

我是postgres的新手。我们需要对 postgres 数据库进行增量备份,并且我们必须能够执行 PITR。我在互联网上搜索了很多,并试图找出 postgres 11.5 的增量 + PITR 的任何文章引用方法。但是,我找不到太多,发现https://www.scalingpostgres.com/tutorials/postgresql-backup-point-in-time-recovery/

有意义的。我开始解决那里提到的步骤。但是在#add recovery.conf

    # add recovery.conf
    nano /var/lib/postgresql/10/main/recovery.conf 

文章说要在主目录中创建 recovery.conf。但是,根据 11.5 安装,没有主目录。目录结构如下:

    /var/lib/pgsql/11/data
    [root@local-pos-52 data]# ls -ltr
      total 96
      -rw-------. 1 postgres postgres 23971 Aug 30 16:05 postgresql.conf
      drwx------. 6 postgres postgres    50 Aug 30 16:07 base
      -rw-------. 1 postgres postgres  4370 Aug 30 16:12 pg_hba.conf
       drwx------. 2 postgres postgres     6 Aug 30 16:12 pg_replslot
       drwx------. 2 postgres postgres    17 Aug 30 19:04 pg_notify
       -rw-------. 1 postgres postgres    58 Aug 30 19:04 postmaster.opts
       -rw-------. 1 postgres postgres    30 Aug 30 19:04 current_logfiles
        drwx------. 2 postgres postgres     6 Aug 30 19:04 pg_stat
        drwx------. 4 postgres postgres    65 Aug 30 19:04 pg_logical
        drwx------. 3 postgres postgres  4096 Aug 30 19:04 pg_wal
       -rw-------. 1 postgres postgres    96 Aug 30 19:04 postmaster.pid
        drwx------. 2 postgres postgres  4096 Aug 30 19:04 global
        drwx------. 2 postgres postgres    60 Aug 30 19:19 pg_stat_tmp
        -rw-------. 1 postgres postgres     3 Aug 30  2019 PG_VERSION
        drwx------. 2 postgres postgres     6 Aug 30  2019 pg_twophase
        drwx------. 2 postgres postgres     6 Aug 30  2019 pg_tblspc
        drwx------. 2 postgres postgres     6 Aug 30  2019 pg_snapshots
        drwx------. 2 postgres postgres     6 Aug 30  2019 pg_serial
        drwx------. 4 postgres postgres    34 Aug 30  2019 pg_multixact
        drwx------. 2 postgres postgres     6 Aug 30  2019 pg_dynshmem
        drwx------. 2 postgres postgres     6 Aug 30  2019 pg_commit_ts
        -rw-------. 1 postgres postgres 23891 Aug 30  2019 postgresql.conf- 
       bak
       -rw-------. 1 postgres postgres    88 Aug 30  2019 
       postgresql.auto.conf
       -rw-------. 1 postgres postgres  1636 Aug 30  2019 pg_ident.conf
      -rw-------. 1 postgres postgres  4269 Aug 30  2019 pg_hba.conf-bak
       drwx------. 2 postgres postgres    17 Aug 30  2019 pg_xact
       drwx------. 2 postgres postgres    17 Aug 30  2019 pg_subtrans
       drwx------. 2 postgres postgres    31 Aug 30  2019 log

此外,在此安装中的 /var/lib 位置没有创建名为“postgresql”的文件夹。

我尝试仅在此路径“/var/lib/pgsql/11/data”上创建 recovery.conf。但是,在那之后,当我重新启动 postgres 服务时,它没有工作。

如果有人指定在哪里创建recovery.conf,将不胜感激,以便它实际工作或共享文档/链接以实现增量备份以及postgres 11.5的PITR

提前感谢您的帮助!

postgresql backup
  • 1 个回答
  • 2058 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve