标签云
asm恢复 bbed bootstrap$ dul In Memory kcbzib_kcrsds_1 kccpb_sanity_check_2 MySQL恢复 ORA-00312 ORA-00607 ORA-00704 ORA-00742 ORA-01110 ORA-01555 ORA-01578 ORA-08103 ORA-600 2131 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 Oracle 恢复 ORACLE恢复 ORACLE数据库恢复 oracle 比特币 OSD-04016 YOUR FILES ARE ENCRYPTED 勒索恢复 比特币加密文章分类
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (103)
- 数据库 (1,702)
- DB2 (22)
- MySQL (74)
- Oracle (1,563)
- Data Guard (52)
- EXADATA (8)
- GoldenGate (24)
- ORA-xxxxx (159)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (15)
- ORACLE 21C (3)
- Oracle 23ai (8)
- Oracle ASM (68)
- Oracle Bug (8)
- Oracle RAC (53)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (28)
- Oracle备份恢复 (571)
- Oracle安装升级 (94)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (81)
- PostgreSQL (18)
- PostgreSQL恢复 (6)
- SQL Server (27)
- SQL Server恢复 (8)
- TimesTen (7)
- 达梦数据库 (2)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (37)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (20)
-
最近发表
- Oracle各种类型坏块说明和处理
- fio测试io,导致磁盘文件系统损坏故障恢复
- ORA-742 写丢失常见bug记录
- Oracle 19c 202501补丁(RUs+OJVM)-19.26
- 避免 19c 数据库性能问题需要考虑的事项 (Doc ID 3050476.1)
- Bug 21915719 Database hang or may fail to OPEN in 12c IBM AIX or HPUX Itanium – ORA-742, DEADLOCK or ORA-600 [kcrfrgv_nextlwn_scn] ORA-600 [krr_process_read_error_2]
- ORA-600 ktuPopDictI_1恢复
- impdp导入数据丢失sys授权问题分析
- impdp 创建index提示ORA-00942: table or view does not exist
- 数据泵导出 (expdp) 和导入 (impdp)工具性能降低分析参考
- 19c非归档数据库断电导致ORA-00742故障恢复
- Oracle 19c – 手动升级到 Non-CDB Oracle Database 19c 的完整核对清单
- sqlite数据库简单操作
- Oracle 暂定和恢复功能
- .pzpq扩展名勒索恢复
- Oracle read only用户—23ai新特性:只读用户
- 迁移awr快照数据到自定义表空间
- .hmallox加密mariadb/mysql数据库恢复
- 2025年首个故障恢复—ORA-600 kcbzib_kcrsds_1
- 第一例Oracle 21c恢复咨询
分类目录归档:PostgreSQL
psql: FATAL: no pg_hba.conf entry for host
pg远程登录拒绝
C:\Users\Administrator>psql -h 192.168.222.2 -U u_xifenfei -d db_xifenfei psql: FATAL: no pg_hba.conf entry for host "192.168.222.1", user "u_xifenfei", database "db_xifenfei", SSL off
解决方法
vi $PGDATA/pg_hba.conf --加上 host all all 192.168.222.0/24 md5 --重启pg服务 -bash-4.2$ pg_ctl stop waiting for server to shut down.... done server stopped -bash-4.2$ pg_ctl start waiting for server to start....2018-08-05 23:46:08.237 EDT [44173] LOG: listening on IPv4 address "0.0.0.0", port 5432 2018-08-05 23:46:08.237 EDT [44173] LOG: listening on IPv6 address "::", port 5432 2018-08-05 23:46:08.239 EDT [44173] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2018-08-05 23:46:08.250 EDT [44173] LOG: redirecting log output to logging collector process 2018-08-05 23:46:08.250 EDT [44173] HINT: Future log output will appear in directory "log". done server started
测试远程访问
C:\Users\Administrator>psql -h 192.168.222.2 -U u_xifenfei -d db_xifenfei 用户 u_xifenfei 的口令: psql (10.4) 输入 "help" 来获取帮助信息. db_xifenfei=# select version(); version --------------------------------------------------------------------------------------------------------- PostgreSQL 10.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18), 64-bit (1 行记录)
发表在 PostgreSQL
评论关闭
pg_rman 备份还原测试
通过试验验证pg_rman的基础使用
创建测试环境
模拟创建新表空间,新数据库,新用户,新schema,并且创建表插入测试数据,这样的环境下,pg_rman 备份还原效果
[root@localhost ~]# psql Password: psql.bin (10.4) Type "help" for help. postgres=# CREATE USER u_xifenfei WITH postgres-# LOGIN postgres-# SUPERUSER postgres-# CREATEDB postgres-# CREATEROLE postgres-# INHERIT postgres-# REPLICATION postgres-# CONNECTION LIMIT -1 postgres-# PASSWORD 'xifenfei'; CREATE ROLE postgres=# CREATE TABLESPACE tbs_xifenfei postgres-# OWNER u_xifenfei postgres-# LOCATION '/opt/PostgreSQL/10/tbs_xifenfei'; CREATE TABLESPACE postgres=# CREATE DATABASE db_xifenfei postgres-# WITH postgres-# OWNER = u_xifenfei postgres-# ENCODING = 'UTF8' postgres-# TABLESPACE = tbs_xifenfei postgres-# CONNECTION LIMIT = -1; CREATE DATABASE postgres=# \q [root@localhost ~]# psql -U u_xifenfei Password for user u_xifenfei: psql.bin (10.4) Type "help" for help. postgres=# \q [root@localhost ~]# psql -U u_xifenfei -d db_xifenfei Password for user u_xifenfei: psql.bin (10.4) Type "help" for help. db_xifenfei=# db_xifenfei=# db_xifenfei=# create schema u_xifenfei; CREATE SCHEMA db_xifenfei=# create table t_xifenfei as select * from pg_tables; SELECT 69 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 69 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 138 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 276 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 552 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 1104 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 2208 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 4416 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 8832 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 17664 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 35328 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 70656 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 141312 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 282624 db_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 565248 db_xifenfei=# select count(*) from t_xifenfei; count --------- 1130496 (1 row) db_xifenfei=#
第一次全备数据库
[root@localhost backup]# pg_rman backup --backup-mode=full \ [root@localhost backup]# --backup-path=/backup -d db_xifenfei -U u_xifenfei -h 127.0.0.1 Password for user u_xifenfei: INFO: copying database files INFO: copying archived WAL files INFO: backup complete INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
模拟继续插入数据
t_xifenfei表一共有数据2260992条
b_xifenfei=# insert into t_xifenfei select * from t_xifenfei; INSERT 0 1130496 db_xifenfei=# select count(*) from t_xifenfei; count --------- 2260992 (1 row)
查看全备情况
[root@localhost 10]# pg_rman show --backup-path=/backup ===================================================================== StartTime EndTime Mode Size TLI Status ===================================================================== 2018-08-05 10:47:29 2018-08-05 10:47:43 FULL 611MB 1 DONE
备份归档日志
[root@localhost 10]# pg_rman backup --backup-mode=archive \ [root@localhost 10]# --backup-path=/backup -d db_xifenfei -U u_xifenfei -h 127.0.0.1 Password for user u_xifenfei: INFO: copying archived WAL files INFO: backup complete INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
检查全备和归档备份情况
[root@localhost 10]# pg_rman show --backup-path=/backup ===================================================================== StartTime EndTime Mode Size TLI Status ===================================================================== 2018-08-05 10:54:51 2018-08-05 10:56:07 ARCH 620MB 1 DONE 2018-08-05 10:47:29 2018-08-05 10:47:43 FULL 611MB 1 DONE
停掉pg
[root@localhost data]# su - postgres Last login: Sun Aug 5 02:19:57 EDT 2018 on pts/1 -bash-4.2$ source pg_env.sh -bash-4.2$ pg_ctl stop waiting for server to shut down.... done server stopped -bash-4.2$ ps -ef|grep postgres root 39902 30494 0 11:05 pts/0 00:00:00 su - postgres postgres 39903 39902 0 11:05 pts/0 00:00:00 -bash postgres 40021 39903 0 11:06 pts/0 00:00:00 ps -ef postgres 40022 39903 0 11:06 pts/0 00:00:00 grep --color=auto postgres
删除原库并创建相关目录
注意:对应的空间目录权限为700,所有者和组为postgres
[root@localhost 10]# pwd /opt/PostgreSQL/10 [root@localhost 10]# mv data data_bak [root@localhost 10]# mv tbs_xifenfei tbs_xifenfei_bak [root@localhost 10]# mkdir data [root@localhost 10]# mkdir tbs_xifenfei [root@localhost 10]# chmod 700 data [root@localhost 10]# chmod 700 tbs_xifenfei [root@localhost 10]# chown postgres:postgres data [root@localhost 10]# chown postgres:postgres tbs_xifenfei
还原数据库
-bash-4.2$ pg_rman restore --backup-path=/backup WARNING: pg_controldata file "/opt/PostgreSQL/10/data/global/pg_control" does not exist INFO: the recovery target timeline ID is not given INFO: use timeline ID of latest full backup as recovery target: 1 INFO: calculating timeline branches to be used to recovery target point INFO: searching latest full backup which can be used as restore start point INFO: found the full backup can be used as base in recovery: "2018-08-05 10:47:29" INFO: copying online WAL files and server log files INFO: clearing restore destination INFO: validate: "2018-08-05 10:47:29" backup and archive log files by SIZE INFO: backup "2018-08-05 10:47:29" is valid INFO: restoring database files from the full mode backup "2018-08-05 10:47:29" INFO: searching incremental backup to be restored INFO: searching backup which contained archived WAL files to be restored INFO: backup "2018-08-05 10:47:29" is valid INFO: restoring WAL files from backup "2018-08-05 10:47:29" INFO: restoring online WAL files and server log files INFO: generating recovery.conf INFO: restore complete HINT: Recovery will start automatically when the PostgreSQL server is started.
启动pg
-bash-4.2$ pg_ctl start waiting for server to start....2018-08-05 11:23:40.190 EDT [40855] LOG: listening on IPv4 address "0.0.0.0", port 5432 2018-08-05 11:23:40.190 EDT [40855] LOG: listening on IPv6 address "::", port 5432 2018-08-05 11:23:40.193 EDT [40855] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2018-08-05 11:23:40.200 EDT [40855] LOG: redirecting log output to logging collector process 2018-08-05 11:23:40.200 EDT [40855] HINT: Future log output will appear in directory "log". done server started -bash-4.2$ ps -ef|grep postgres root 40328 21806 0 11:14 pts/3 00:00:00 su - postgres postgres 40329 40328 0 11:14 pts/3 00:00:00 -bash postgres 40855 1 0 11:23 pts/3 00:00:00 /opt/PostgreSQL/10/bin/postgres postgres 40856 40855 0 11:23 ? 00:00:00 postgres: logger process postgres 40857 40855 57 11:23 ? 00:00:16 postgres: startup process waiting for 000000010000000000000025 postgres 40859 40855 0 11:23 ? 00:00:00 postgres: checkpointer process postgres 40860 40855 7 11:23 ? 00:00:02 postgres: writer process postgres 40862 40855 0 11:23 ? 00:00:00 postgres: stats collector process postgres 40892 40329 0 11:24 pts/3 00:00:00 ps -ef postgres 40893 40329 0 11:24 pts/3 00:00:00 grep --color=auto postgres -bash-4.2$
验证数据库还原结果
-bash-4.2$ psql -U u_xifenfei -d db_xifenfei Password for user u_xifenfei: psql.bin (10.4) Type "help" for help. db_xifenfei=# select count(*) from t_xifenfei; count --------- 2260992 (1 row) db_xifenfei=#
破坏环境之前表条数和还原之后完全匹配,证pg_rman在功能上备份恢复没有问题
PostgreSQL修改归档模式
pg版本
postgres=# select version(); version --------------------------------------------------------------------------------------------------------- PostgreSQL 10.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18), 64-bit (1 row)
归档配置参数
--pgdata中的postgresql.conf wal_level = replica archive_mode = on archive_command = 'test ! -f /pg_archivedir/%f && cp %p /pg_archivedir/%f' --重启pg systemctl restart postgresql-10.service postgres=# show wal_level; wal_level ----------- replica (1 row) postgres=# show archive_mode; archive_mode -------------- on (1 row) postgres=# show archive_command; archive_command -------------------------------------------------------- test ! -f /pg_archivedir/%f && cp %p /pg_archivedir/%f (1 row)
测试归档效果
[root@localhost pg_wal]# ps -ef|grep "postgres: archiver process" postgres 35300 35293 0 08:43 ? 00:00:00 postgres: archiver process last was 000000010000000000000004 root 37504 20853 0 09:55 pts/1 00:00:00 grep --color=auto postgres: archiver process [root@localhost pg_wal]# pwd /opt/PostgreSQL/10/data/pg_wal [root@localhost pg_wal]# ls -ltr total 49156 -rw------- 1 postgres postgres 309 Aug 5 06:05 000000010000000000000002.00000028.backup -rw------- 1 postgres postgres 16777216 Aug 5 08:43 000000010000000000000006 -rw------- 1 postgres postgres 16777216 Aug 5 08:50 000000010000000000000004 drwx------ 2 postgres postgres 94 Aug 5 08:50 archive_status -rw------- 1 postgres postgres 16777216 Aug 5 08:53 000000010000000000000005 [root@localhost pg_wal]# ls -l /pg_archivedir/ total 65540 -rw------- 1 postgres postgres 16777216 Aug 5 08:37 000000010000000000000001 -rw------- 1 postgres postgres 16777216 Aug 5 08:37 000000010000000000000002 -rw------- 1 postgres postgres 309 Aug 5 08:37 000000010000000000000002 -rw------- 1 postgres postgres 16777216 Aug 5 08:43 000000010000000000000003 -rw------- 1 postgres postgres 16777216 Aug 5 08:50 000000010000000000000004 --切换日志 postgres=# select pg_switch_wal(); pg_switch_wal --------------- 0/5000158 (1 row) [root@localhost pg_wal]# ps -ef|grep "postgres: archiver process" postgres 35300 35293 0 08:43 ? 00:00:00 postgres: archiver process last was 000000010000000000000005 root 37531 20853 0 09:56 pts/1 00:00:00 grep --color=auto postgres: archiver process [root@localhost pg_wal]# ls -ltr total 49156 -rw------- 1 postgres postgres 309 Aug 5 06:05 000000010000000000000002 -rw------- 1 postgres postgres 16777216 Aug 5 08:50 000000010000000000000004 -rw------- 1 postgres postgres 16777216 Aug 5 09:55 000000010000000000000005 drwx------ 2 postgres postgres 130 Aug 5 09:55 archive_status -rw------- 1 postgres postgres 16777216 Aug 5 09:55 000000010000000000000006 [root@localhost pg_wal]# ls -l /pg_archivedir/ total 81924 -rw------- 1 postgres postgres 16777216 Aug 5 08:37 000000010000000000000001 -rw------- 1 postgres postgres 16777216 Aug 5 08:37 000000010000000000000002 -rw------- 1 postgres postgres 309 Aug 5 08:37 000000010000000000000002 -rw------- 1 postgres postgres 16777216 Aug 5 08:43 000000010000000000000003 -rw------- 1 postgres postgres 16777216 Aug 5 08:50 000000010000000000000004 -rw------- 1 postgres postgres 16777216 Aug 5 09:55 000000010000000000000005