当前位置: 首页 > news >正文

PostgreSQL最后的救命稻草 — pg_resetwal

pg_resetwal— 重置 PostgreSQL 数据库集群的预写日志和其他控制信息

适用版本:PostgreSQL 12/13/14/15

语法

pg_resetwal [ -f | --force ] [ -n | --dry-run ] [option...] [ -D | --pgdata ]datadir

描述
pg_resetwal清除预写日志 WAL,并可选地重置pg_control文件中的一些其他控制信息。当 WAL 文件或 pg_control 控制文件损坏时,导致数据库无法启动时,该操作将作为数据库修复的最后手段使用。

通过 pg_resetwal 修复而启动数据库后,可能会由于部分提交的事务,导致数据库可能存在数据不一致的情况。所以,应该立即转储数据,建议重新初始化新的数据库恢复。恢复后再检查不一致,并根据需要进一步修复。

pg_resetwal只能由安装数据库用户运行,因为它需要对数据目录进行读/写访问。注意:考虑安全原因,pg_resetwal不使用环境变量 PGDATA,所以必须在命令行上指定数据目录。

如果 pg_resetwal 提示无法确定pg_control的有效数据,可以通过指定-f(force)选项强制继续执行。大多数字段可以自动匹配,但下一个OID、下一个事务ID和epoch、下一多事务ID和偏移量以及WAL起始位置字段值可能需要手动指定。可以使用一些选项设置这些字段值。如果无法确定这些字段的正确值,也可使用-f,但必须对恢复的数据库更为严谨的处理:必须立即转储和恢复。在转储之前,不要在数据库中执行任何数据修改操作,因为任何此类操作都可能会使损坏更严重。

命令帮助

  [postgres@lyp ~]$ pg_resetwal --helppg_resetwal resets the PostgreSQL write-ahead log.Usage:pg_resetwal [OPTION]... DATADIROptions:-c, --commit-timestamp-ids=XID,XID    设置带有提交时间戳的最早和最新事务(零表示没有更改)[-D, --pgdata=]DATADIR                  数据目录-e, --epoch=XIDEPOCH                   设置下一个事务ID纪元epoch-f, --force                            强制更新完成-l, --next-wal-file=WALFILE            设置新WAL的最小起始位置-m, --multixact-ids=MXID,MXID          设置下一个和最旧的多事务ID-n, --dry-run                          没有更新,只显示将要执行的操作-o, --next-oid=OID                     设置下一个OID-O, --multixact-offset=OFFSET          设置下一个多事务偏移量-V, --version                          输出版本信息,然后退出-x, --next-transaction-id=XID          设置下一个事务ID--wal-segsize=SIZE                 WAL段的大小(MB)-?, --help                             Report bugs to <pgsql-bugs@lists.postgresql.org>.PostgreSQL home page: <https://www.postgresql.org/>[postgres@lyp ~]$

选项详解

只有当 pg_resetwal 无法通过读取pg_control 来确定适当的值时,才需要以下选项。对于采用数字参数的值,可以使用前缀0x指定十六进制值。

    -c xid1,xid2—commit-timestamp-ids=xid1,xid2

手动设置可以检索提交时间的最旧和最新事务ID。

xid1:可以通过在 $PGDATA/pg_commit_ts 目录中查找数值最小的文件名来确定可以检索提交时间的最旧事务ID的安全值(第一部分)。xid2:相反,可以通过在同一目录中查找数值最大的文件名来确定可以检索提交时间的最新事务ID的安全值。文件名为十六进制。

    -e xid_epoch—epoch=xid_epoch

手动设置下一个事务ID的epoch。

事务ID epoch实际上并没有保存在数据库中的任何位置,除非存储在由pg_resetwal设置的字段中,因此就数据库本身而言,任何值都是有效的。您可能需要调整此值,以确保复制系统(如Slony-I和Skytools)正常工作-如果是这样,应该可以从下游复制数据库的状态获得适当的值。

    -l walfile—next-wal-file=walfile

通过指定下一个WAL段文件的名称,手动设置WAL起始位置。

可以通过 $PGDATA/pg_wal 目录中查找数值最新的WAL段的文件名,+1。这些名称也是十六进制的,有三个部分。第一部分是“时间线ID”,通常应保持不变。例如,如果0000000100000009000000B7是pg_wal中最大的条目,请使用-l 0000000100000009000000B8 或更高。

注意,当使用非默认WAL段大小时,WAL文件名中的数字与系统函数和系统视图报告的LSN不同。此选项采用WAL文件名,而不是LSN。

格式:-l 0000000100000009000000B8

    -m mxid1,mxid2—multixact-ids=mxid1,mxid2

手动设置下一个和最旧的多事务ID。

mxid1:下一个多事务ID的安全值可以通过在 $PGDATA/pg_multixact/offsets 目录中查找数值最大的文件名,+1,然后乘以65536(0x10000)来确定。mxid2:相反,最旧的多事务ID的安全值可以通过 $PGDATA/pg_multixact/offsets 目录中数字最小的文件名,乘以65536来确定。文件名是十六进制的,因此最简单的方法是以十六进制指定选项值并附加四个零。

注意:若当前值为0,那么mxid2亦为0,则mxid2取mxid1的值。

格式:-m 0x10000, 0x100000

    -o oid—next-oid=oid

手动设置下一个OID。

没有相对简单的方法来确定下一个超出数据库中最大OID的OID,但幸运的是,正确设置下一个OID并不重要。

    -O mxoff—multixact-offset=mxoff

手动设置下一个多事务处理偏移量。

安全值可以通过在 $PGDATA/pg_multixact/members 目录中查找数值最大的文件名,+1,然后乘以52352(0xCC80)来确定。文件名为十六进制。没有像附加零的其他选项那样的简单方法。

若找到最大值0000,+1,乘以 52352 (0xCC80),这个需要进行计算,没有简单的加0的方法。格式:0xCC80

若找到最大值00C1(193),+1,乘以 52352 (0xCC80)。最后得值:(193+1)* 52352 = 4918288。16进制为:4B0C10,结果为:0x004B0C10

   —wal-segsize=wal_segment_size

设置新的WAL段大小(MB)。该值必须设置为介于1和1024(兆字节)之间的2的幂。

虽然pg_resetwal会将WAL起始地址设置在最新的现有WAL段文件之外,但某些段大小的更改可能会导致重用以前的WAL文件名。如果WAL文件名重叠会导致归档策略出现问题,建议将-l与此选项一起使用以手动设置WAL起始地址。

    -u xid—oldest-transaction-id=xid

手动设置最旧的未冻结交易ID。

可以通过在 $PGDATA/pg_xact 目录中查找数值最小的文件名,然后乘以1048576(0x100000)来确定安全值。请注意,文件名是十六进制的,因此最简单的方法是以十六进制指定选项值并附加五个零。例如,如果0007是pg_xact中最小的条目,-u 0x700000将起作用。

    -x xid—next-transaction-id=xid

手动设置下一个事务ID。

安全值可以通过在 $PGDATA/pg_xact 目录中查找数值最大的文件名,+1,然后乘以1048576(0x100000)来确定。请注意,文件名是十六进制的。,因此最简单的方法是以十六进制指定选项值并附加五个零。例如,如果0011是pg_xact中最大的条目,-x 0x1200000将起作用(五个尾随零提供正确的乘数)。

使用案例
pg_resetwal 用于丢失一些文件导致数据库无法启动进行修复。需要再次强调,pg_resetwal并不是日常使用的工具,是数据库最后的修复手段。常规性恢复请使用常规手段进行。

使用 pg_resetwal 修复的数据库,一般会正常启动,但是可能会因为参数的不准确而导致数据库存在其他异常问题。

如果因为丢失WAL文件导致数据库不一致,或者控制文件丢失,那么我们只需要通过这个工具生成一个最新的文件就可以强制打开数据库了。

重置WAL

创建测试数据

    [postgres@lyp pg_wal]$ psqlpsql (14.1)Type "help" for help.postgres=# create table lxs1(id int);CREATE TABLEpostgres=# insert into lxs1 values(1);INSERT 0 1postgres=# insert into lxs1 values(2);INSERT 0 1postgres=# checkpoint;CHECKPOINTpostgres=# insert into lxs1 values(3);INSERT 0 1postgres=#

模拟数据库异常

    [postgres@lyp pg_wal]$ ps -ef |grep postgresroot      19555  13684  0 16:49 pts/1    00:00:00 su - postgrespostgres  19556  19555  0 16:49 pts/1    00:00:00 -bashpostgres  19767  19556  0 16:52 pts/1    00:00:00 psqlroot      19790  18013  0 16:53 pts/2    00:00:00 su - postgrespostgres  19791  19790  0 16:53 pts/2    00:00:00 -bashpostgres  19865      1  0 16:54 ?        00:00:00 /opt/pgsql14.1/bin/postgrespostgres  19866  19865  0 16:54 ?        00:00:00 postgres: loggerpostgres  19868  19865  0 16:54 ?        00:00:00 postgres: checkpointerpostgres  19869  19865  0 16:54 ?        00:00:00 postgres: background writerpostgres  19870  19865  0 16:54 ?        00:00:00 postgres: walwriterpostgres  19871  19865  0 16:54 ?        00:00:00 postgres: autovacuum launcherpostgres  19872  19865  0 16:54 ?        00:00:00 postgres: archiver failed on 000000010000000000000012postgres  19873  19865  0 16:54 ?        00:00:00 postgres: stats collectorpostgres  19874  19865  0 16:54 ?        00:00:00 postgres: logical replication launcherpostgres  19883  19865  0 16:55 ?        00:00:00 postgres: postgres postgres [local] idlepostgres  19899  19791  0 16:55 pts/2    00:00:00 ps -efpostgres  19900  19791  0 16:55 pts/2    00:00:00 grep --color=auto postgres[postgres@lyp pg_wal]$ kill -9 19865[postgres@lyp pg_wal]$ ps -ef |grep postgresroot      19555  13684  0 16:49 pts/1    00:00:00 su - postgrespostgres  19556  19555  0 16:49 pts/1    00:00:00 -bashpostgres  19767  19556  0 16:52 pts/1    00:00:00 psqlroot      19790  18013  0 16:53 pts/2    00:00:00 su - postgrespostgres  19791  19790  0 16:53 pts/2    00:00:00 -bashpostgres  19901  19791  0 16:55 pts/2    00:00:00 ps -efpostgres  19902  19791  0 16:55 pts/2    00:00:00 grep --color=auto postgres[postgres@lyp pg_wal]$

删除WAL文件

    [postgres@lyp ~]$ cd $PGDATA/pg_wal[postgres@lyp pg_wal]$ ls -lrttotal 196620-rw-------. 1 postgres postgres 16777216 Feb 21  2022 000000010000000000000007-rw-------. 1 postgres postgres 16777216 Feb 21  2022 000000010000000000000008-rw-------. 1 postgres postgres      345 Feb 21  2022 000000010000000000000008.00000028.backup-rw-------. 1 postgres postgres 16777216 Feb 22  2022 000000010000000000000009-rw-------. 1 postgres postgres 16777216 Feb 22  2022 00000001000000000000000A-rw-------. 1 postgres postgres      318 Feb 22  2022 00000001000000000000000A.00000028.backup-rw-------. 1 postgres postgres 16777216 Feb 24  2022 00000001000000000000000B-rw-------. 1 postgres postgres 16777216 Feb 24  2022 00000001000000000000000C-rw-------. 1 postgres postgres 16777216 Feb 25  2022 00000001000000000000000D-rw-------. 1 postgres postgres 16777216 May 10  2022 00000001000000000000000E-rw-------. 1 postgres postgres 16777216 Nov 19 23:13 00000001000000000000000F-rw-------. 1 postgres postgres 16777216 Nov 26 18:21 000000010000000000000010-rw-------. 1 postgres postgres 16777216 Mar 13 16:52 000000010000000000000011-rw-------. 1 postgres postgres 16777216 Mar 13 16:52 000000010000000000000012drwx------. 2 postgres postgres     4096 Mar 13 16:52 archive_status-rw-------. 1 postgres postgres 16777216 Mar 13 16:52 000000010000000000000013[postgres@lyp pg_wal]$[postgres@lyp pg_wal]$ rm -rf 0000000100000000000000*[postgres@lyp pg_wal]$[postgres@lyp pg_wal]$ ls -lrttotal 4drwx------. 2 postgres postgres 4096 Mar 13 16:52 archive_status[postgres@lyp pg_wal]$

尝试启动数据库

    [postgres@lyp pg_wal]$ pg_ctl startpg_ctl: another server might be running; trying to start server anywaywaiting for server to start....2023-03-13 16:56:07.956 CST [19916] LOG:  redirecting log output to logging collector process2023-03-13 16:56:07.956 CST [19916] HINT:  Future log output will appear in directory "log".stopped waitingpg_ctl: could not start serverExamine the log output.[postgres@lyp pg_wal]$

重置WAL

    [postgres@lyp pg_wal]$ pg_resetwal $PGDATAThe database server was not shut down cleanly.Resetting the write-ahead log might cause data to be lost.If you want to proceed anyway, use -f to force reset.[postgres@lyp pg_wal]$ pg_resetwal -f $PGDATAWrite-ahead log reset[postgres@lyp pg_wal]$ ls -lrttotal 16384drwx------. 2 postgres postgres        6 Mar 13 17:03 archive_status-rw-------. 1 postgres postgres 16777216 Mar 13 17:03 000000010000000000000014[postgres@lyp pg_wal]$

启动数据库

    [postgres@lyp pg_wal]$ pg_ctl startwaiting for server to start....2023-03-13 17:04:10.205 CST [20173] LOG:  redirecting log output to logging collector process2023-03-13 17:04:10.205 CST [20173] HINT:  Future log output will appear in directory "log".doneserver started[postgres@lyp pg_wal]$ psqlpsql (14.1)Type "help" for help.postgres=# select * from lxs1;id----12(2 rows)postgres=#

可以看到测试数据中 checkpoint 检查点后的数据,由于WAL重置而丢失。

重建控制文件

创建测试数据

    [postgres@lyp pg_wal]$ psqlpsql (14.1)Type "help" for help.postgres=# drop table lxs1;DROP TABLEpostgres=# create table lxs1(id int);CREATE TABLEpostgres=# insert into lxs1 values(1);INSERT 0 1postgres=# insert into lxs1 values(2);INSERT 0 1postgres=# checkpoint;CHECKPOINTpostgres=# insert into lxs1 values(3);INSERT 0 1postgres=#

模拟数据库异常

    [postgres@lyp pg_wal]$ ps -ef |grep postgresroot      19555  13684  0 16:49 pts/1    00:00:00 su - postgrespostgres  19556  19555  0 16:49 pts/1    00:00:00 -bashpostgres  19767  19556  0 16:52 pts/1    00:00:00 psqlroot      19790  18013  0 16:53 pts/2    00:00:00 su - postgrespostgres  19791  19790  0 16:53 pts/2    00:00:00 -bashroot      19965  19924  0 16:56 pts/0    00:00:00 su - postgrespostgres  19966  19965  0 16:56 pts/0    00:00:00 -bashpostgres  20013  19966  0 16:56 pts/0    00:00:00 tail -100f postgresql-2023-03-13_072.logpostgres  20272      1  0 17:08 ?        00:00:00 /opt/pgsql14.1/bin/postgrespostgres  20273  20272  0 17:08 ?        00:00:00 postgres: loggerpostgres  20275  20272  0 17:08 ?        00:00:00 postgres: checkpointerpostgres  20276  20272  0 17:08 ?        00:00:00 postgres: background writerpostgres  20277  20272  0 17:08 ?        00:00:00 postgres: walwriterpostgres  20278  20272  0 17:08 ?        00:00:00 postgres: autovacuum launcherpostgres  20279  20272  0 17:08 ?        00:00:00 postgres: archiver failed on 000000010000000000000015postgres  20280  20272  0 17:08 ?        00:00:00 postgres: stats collectorpostgres  20281  20272  0 17:08 ?        00:00:00 postgres: logical replication launcherpostgres  20288  20272  0 17:08 ?        00:00:00 postgres: postgres postgres [local] idlepostgres  20359  19791  0 17:10 pts/2    00:00:00 ps -efpostgres  20360  19791  0 17:10 pts/2    00:00:00 grep --color=auto postgres[postgres@lyp pg_wal]$ kill -9 20272[postgres@lyp pg_wal]$ ps -ef |grep postgresroot      19555  13684  0 16:49 pts/1    00:00:00 su - postgrespostgres  19556  19555  0 16:49 pts/1    00:00:00 -bashpostgres  19767  19556  0 16:52 pts/1    00:00:00 psqlroot      19790  18013  0 16:53 pts/2    00:00:00 su - postgrespostgres  19791  19790  0 16:53 pts/2    00:00:00 -bashroot      19965  19924  0 16:56 pts/0    00:00:00 su - postgrespostgres  19966  19965  0 16:56 pts/0    00:00:00 -bashpostgres  20013  19966  0 16:56 pts/0    00:00:00 tail -100f postgresql-2023-03-13_072.logpostgres  20361  19791  0 17:11 pts/2    00:00:00 ps -efpostgres  20362  19791  0 17:11 pts/2    00:00:00 grep --color=auto postgres[postgres@lyp pg_wal]$

破坏控制文件

    [postgres@lyp pg_wal]$ cd $PGDATA/global[postgres@lyp global]$ ls -rlt pg_control-rw-------. 1 postgres postgres 8192 Mar 13 17:08 pg_control[postgres@lyp global]$ echo "" >pg_control[postgres@lyp global]$ ls -rlt pg_control-rw-------. 1 postgres postgres 1 Mar 13 17:12 pg_control[postgres@lyp global]$

尝试启动数据库

    [postgres@lyp global]$ pg_ctl startpg_ctl: another server might be running; trying to start server anywaywaiting for server to start....2023-03-13 17:13:06.788 CST [20419] PANIC:  could not read file "global/pg_control": read 1 of 296stopped waitingpg_ctl: could not start serverExamine the log output.[postgres@lyp global]$

重建控制文件

pg_resetwal 重建控制文件,需要参数如下:

    -l walfile—next-wal-file=walfile

通过指定下一个WAL段文件的名称,手动设置WAL起始位置。

可以通过 $PGDATA/pg_wal 目录中查找数值最新的WAL段的文件名,+1。

        [postgres@lyp global]$ cd $PGDATA/pg_wal[postgres@lyp pg_wal]$ ls -lrttotal 32768-rw-------. 1 postgres postgres 16777216 Mar 13 17:08 000000010000000000000015drwx------. 2 postgres postgres       44 Mar 13 17:08 archive_status-rw-------. 1 postgres postgres 16777216 Mar 13 17:09 000000010000000000000016[postgres@lyp pg_wal]$

当前 000000010000000000000016 是pg_wal中最大的条目,则使用-l 000000010000000000000017  

    -m mxid1,mxid2—multixact-ids=mxid1,mxid2

手动设置下一个和最旧的多事务ID。

mxid1:下一个多事务ID的安全值可以通过在 $PGDATA/pg_multixact/offsets 目录中查找数值最大的文件名,+1,然后乘以65536(0x10000)来确定。mxid2:相反,最旧的多事务ID的安全值可以通过$PGDATA/pg_multixact/offsets目录中数字最小的文件名,乘以65536来确定。文件名是十六进制的,因此最简单的方法是以十六进制指定选项值并附加四个零。

注意:若当前值为0,那么mxid2亦为0,则mxid2取mxid1的值。

        postgres@lyp offsets]$ ls -lrttotal 8-rw-------. 1 postgres postgres 8192 Mar 13 17:08 0000[postgres@lyp offsets]$

当前值为0000,则mxid1为:0x10000,mxid2取mxid1的值,则使用-m 0x10000,0x10000

    -O mxoff—multixact-offset=mxoff

 手动设置下一个多事务处理偏移量。

安全值可以通过在 $PGDATA/pg_multixact/members 目录中查找数值最大的文件名,+1,然后乘以52352(0xCC80)来确定。文件名为十六进制。没有像附加零的其他选项那样的简单方法。

  [postgres@lyp members]$ ls -rlttotal 8-rw-------. 1 postgres postgres 8192 Feb 21  2022 0000[postgres@lyp members]$

 当前值为0000,则使用 -O 0xCC80  

    -x xid—next-transaction-id=xid

手动设置下一个事务ID。

 安全值可以通过在$PGDATA/pg_xact目录中查找数值最大的文件名,+1,然后乘以1048576(0x100000)来确定。请注意,文件名是十六进制的。,因此最简单的方法是以十六进制指定选项值并附加五个零。

 [postgres@lyp members]$ cd $PGDATA/pg_xact[postgres@lyp pg_xact]$ ls -rlttotal 8-rw-------. 1 postgres postgres 8192 Mar 13 17:08 0000[postgres@lyp pg_xact]$

 当前值为0000,则使用- x 0x100000   

重建控制文件

        [postgres@lyp global]$ pg_resetwal -l 000000010000000000000017 -m 0x10000,0x10000 -O 0xCC80 -x 0x100000 $PGDATApg_resetwal: error: lock file "postmaster.pid" existspg_resetwal: Is a server running?  If not, delete the lock file and try again.[postgres@lyp global]$

 由于是数据异常关闭,所以存在锁文件,删除后重新执行。

        [postgres@lyp global]$ ls -rlt $PGDATA/postmaster.pid-rw-------. 1 postgres postgres 39 Mar 13 17:13 /opt/pgdata14.1/postmaster.pid[postgres@lyp global]$ rm -rf  $PGDATA/postmaster.pid[postgres@lyp global]$ pg_resetwal -l 000000010000000000000017 -m 0x10000,0x10000 -O 0xCC80 -x 0x100000 $PGDATApg_resetwal: warning: pg_control exists but is broken or wrong version; ignoring itGuessed pg_control values:pg_control version number:            1300Catalog version number:               202107181Database system identifier:           7209963927373898017Latest checkpoint's TimeLineID:       1Latest checkpoint's full_page_writes: offLatest checkpoint's NextXID:          0:3Latest checkpoint's NextOID:          12000Latest checkpoint's NextMultiXactId:  1Latest checkpoint's NextMultiOffset:  0Latest checkpoint's oldestXID:        3Latest checkpoint's oldestXID's DB:   0Latest checkpoint's oldestActiveXID:  0Latest checkpoint's oldestMultiXid:   1Latest checkpoint's oldestMulti's DB: 0Latest checkpoint's oldestCommitTsXid:0Latest checkpoint's newestCommitTsXid:0Maximum data alignment:               8Database block size:                  8192Blocks per segment of large relation: 131072WAL block size:                       8192Bytes per WAL segment:                16777216Maximum length of identifiers:        64Maximum columns in an index:          32Maximum size of a TOAST chunk:        1996Size of a large-object chunk:         2048Date/time type storage:               64-bit integersFloat8 argument passing:              by valueData page checksum version:           0Values to be changed:First log segment after reset:        000000010000000000000017NextMultiXactId:                      65536OldestMultiXid:                       65536OldestMulti's DB:                     0NextMultiOffset:                      52352NextXID:                              1048576OldestXID:                            3OldestXID's DB:                       0If these values seem acceptable, use -f to force reset.[postgres@lyp global]$[postgres@lyp global]$ pg_resetwal -l 000000010000000000000017 -m 0x10000,0x10000 -O 0xCC80 -x 0x100000 $PGDATA -fpg_resetwal: warning: pg_control exists but is broken or wrong version; ignoring itWrite-ahead log reset[postgres@lyp global]$[postgres@lyp global]$ ls -rlt pg_control-rw-------. 1 postgres postgres 8192 Mar 13 17:43 pg_control[postgres@lyp global]$

启动数据库

    [postgres@lyp global]$ pg_ctl startwaiting for server to start....2023-03-13 17:44:00.209 CST [20785] LOG:  redirecting log output to logging collector process2023-03-13 17:44:00.209 CST [20785] HINT:  Future log output will appear in directory "log".doneserver started[postgres@lyp global]$ psqlpsql (14.1)Type "help" for help.postgres=# select * from lxs1;id----12(2 rows)postgres=#

可以看到测试数据中 checkpoint 检查点后的数据,由于控制文件重置而丢失。

注意

1、注意据库正在运行时,不得使用此命令。
2、如果 pg_resetwal 在数据目录中找到服务器锁定文件,将启动失败。
3、如果数据库已崩溃,那么可能会留下一个锁文件(postmaster.pid);在这种情况下,可以删除锁定文件以保证 postmaster.pid 的正常运行。但在此操作之前,需要再次确保没有数据库进程在运行。
4、pg_resetwal仅适用于相同主版本的数据库服务器。

相关文章:

PostgreSQL最后的救命稻草 — pg_resetwal

pg_resetwal— 重置 PostgreSQL 数据库集群的预写日志和其他控制信息 适用版本&#xff1a;PostgreSQL 12/13/14/15语法 pg_resetwal [ -f | --force ] [ -n | --dry-run ] [option...] [ -D | --pgdata ]datadir描述pg_resetwal清除预写日志 WAL&#xff0c;并可选地重置pg_c…...

彻底关闭Windows更新

一、关闭Windows Update服务 1、按“Windows R”键&#xff0c;打开运行对话框&#xff0c;并输入“services.msc”&#xff0c;然后再单击“确定”。 2、在弹出的服务窗口中&#xff0c;找到“Windows Update”选项并双击打开它。 3、在弹出的“Windows Update的属性”对话框…...

Java正则表达式语法

Java正则表达式的语法与示例 | |目录 1匹配验证-验证Email是否正确 2在字符串中查询字符或者字符串 3常用正则表达式 4正则表达式语法 1匹配验证-验证Email是否正确 public static void main(String[] args) { // 要验证的字符串 String str "servicexsoftlab.net&q…...

【2023-3-29】JavaScript使用promise顺序调用函数并抛出异常

JavaScript使用promise顺序调用函数并抛出异常 场景 新建或者编辑时&#xff0c;一个页面中存在多个表单&#xff0c;每个表单都有单独进行表单验证。点击提交时&#xff0c;若有一个表单校验失败&#xff0c;则不能提交。 ps&#xff1a;为啥不放在一个表单中&#xff1f; (…...

Python实现GWO智能灰狼优化算法优化随机森林分类模型(RandomForestClassifier算法)项目实战

说明&#xff1a;这是一个机器学习实战项目&#xff08;附带数据代码文档视频讲解&#xff09;&#xff0c;如需数据代码文档视频讲解可以直接到文章最后获取。 1.项目背景 灰狼优化算法(GWO)&#xff0c;由澳大利亚格里菲斯大学学者 Mirjalili 等人于2014年提出来的一种群智能…...

从redis到epoll到mmap

redis为什么这么快&#xff1f; 比较容易答出的答案 1)纯粹的内存操作 2)单线程操作,不用考虑线程切换 其他优势 3)I/O 多路复用,使用epoll 4)Reactor 设计模式 I/O 多路复用有三种 select、poll、epoll select&#xff1a;使用数组存储轮询 poll&#xff1a;使用链表轮询 epo…...

STM32CubeMX快速构造工程模板(一)

STM32CubeMX作为一个免费开源的软件,能够可视化配置STM32或其他产品硬件资源,能过快速地构造工程模板,很是方便!!! 目录 STM32CubeMX快速构造工程模板 首先第一步,打开软件-点击按钮-输入型号-双击打开。...

Java Web中的ServletContext对象

目录 ServletContext对象 获取上下文初始化参数的相关方法 创建ServletContext对象 1&#xff09;通过 GenericServlet 提供的 getServletContext() 方法 2&#xff09;通过 ServletConfig 提供的 getServletContext() 方法 3&#xff09;通过 HttpSession 提供的 getServletCo…...

回归预测 | MATLAB实现PSO-RF粒子群算法优化随机森林多输入单输出回归预测

回归预测 | MATLAB实现PSO-RF粒子群算法优化随机森林多输入单输出回归预测 目录回归预测 | MATLAB实现PSO-RF粒子群算法优化随机森林多输入单输出回归预测效果一览基本介绍程序设计参考资料效果一览 基本介绍 MATLAB实现PSO-RF粒子群算法优化随机森林多输入单输出回归预测 粒子…...

在小公司工作3年,从事软件测试5年了,才发现自己还是处于“初级“水平,是不是该放弃....

毕业前三年&#xff0c;从早到晚&#xff0c;加班到深夜&#xff0c;一年又一年&#xff0c;直至刚入职场的首个黄金三年过年都去了&#xff0c;而职位却仍在原地踏步。尽管感觉自己努力过&#xff0c;但是实际上&#xff0c;自身的能力从没得到过多少提升。 所以在无数个夜晚…...

基于 OpenCV 与 Java 两个语言版本实现获取某一图片特定区域的颜色对比度

本文目录一、什么是对比度二、什么是颜色直方图三、如何通过RGB计算颜色对比度什么是HSV、Lab颜色空间四、OpenCV代码五、Java代码5.1 平滑处理5.2 完整代码一、什么是对比度 对比度是指图像中不同区域之间的明暗差异程度&#xff0c;它是图像质量中的重要指标之一。除了颜色对…...

Book:实战Java高并发程序设计(第二版)

实战Java高并发程序设计&#xff08;第二版&#xff09;为什么会有并行计算&#xff1f;并行计算需要回答的问题基本概念并发级别有哪些&#xff1f;Amdahl定律和Gustafson定律Java并发三特性进程和线程线程的生命周期Thread类run()与start()的区别为什么会有并行计算&#xff…...

LeetCode 831. Masking Personal Information【字符串,正则表达式】中等

本文属于「征服LeetCode」系列文章之一&#xff0c;这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁&#xff0c;本系列将至少持续到刷完所有无锁题之日为止&#xff1b;由于LeetCode还在不断地创建新题&#xff0c;本系列的终止日期可能是永远。在这一系列刷题文章…...

递增三元组

[蓝桥杯 2018 省 B] 递增三元组 题目描述 给定三个整数数组 A[A1,A2,⋯,AN]A [A_1, A_2,\cdots, A_N]A[A1​,A2​,⋯,AN​]&#xff0c;B[B1,B2,⋯,BN]B [B_1, B_2,\cdots, B_N]B[B1​,B2​,⋯,BN​]&#xff0c;C[C1,C2,⋯,CN]C [C_1, C_2,\cdots,C_N]C[C1​,C2​,⋯,CN​…...

java源码阅读 - TreeSet

往期文章 用最简单的话讲最明白的红黑树java源码阅读 - HashMap数据结构 - 堆与堆排序 文章目录往期文章一、介绍二、类的声明三、成员变量四、构造函数五、常用方法1. NavigableSet接口的实现2. SortedSet接口的实现六、总结一、介绍 在上期文章中&#xff0c;我们从源码层面…...

写毕业论文经验贴

首先说一句不要靠近word&#xff0c;会变得不幸。最好用latex写&#xff0c;不过我当时懒得下载latex了&#xff0c;于是后期改格式花了点时间 写论文之前 事先把所有的论文都查好并且整理好&#xff0c;论文第一、二章写起来就会很快&#xff1b; 把实验做顺溜&#xff0c;实…...

2.7 进程退出、孤儿进程、僵尸进程+2.8 wait函数+2.9 waitpid函数

1.进程退出 子进程退出时&#xff1a;父进程帮助子进程回收内核区的资源 exit.c /*#include <stdlib.h>void exit(int status);#include <unistd.h>void _exit(int status);status参数&#xff1a;是进程退出时的一个状态信息。父进程回收子进程资源的时候可以获取…...

【新2023Q2模拟题JAVA】华为OD机试 - 预订酒店

最近更新的博客 华为od 2023 | 什么是华为od,od 薪资待遇,od机试题清单华为OD机试真题大全,用 Python 解华为机试题 | 机试宝典【华为OD机试】全流程解析+经验分享,题型分享,防作弊指南华为od机试,独家整理 已参加机试人员的实战技巧本篇题解:预订酒店 题目 放暑假了,橡…...

一个完整的渗透学习路线是怎样的?如何成为安全渗透工程师?

前言 1/我是如何学习黑客和渗透&#xff1f; 我是如何学习黑客和渗透测试的&#xff0c;在这里&#xff0c;我就把我的学习路线写一下&#xff0c;让新手和小白们不再迷茫&#xff0c;少走弯路&#xff0c;拒绝时间上的浪费&#xff01; 2/学习常见渗透工具的使用 注意&…...

刷完这60个标准库模块,成为Python骨灰级玩家

python强大&#xff0c;主要是因为包多&#xff0c;且不说第三方包&#xff0c;单是标准库就已让人望而生畏。 如果从第一篇整理标准库的博客算起&#xff0c;如今已有三个年头。在整理标准库的过程中&#xff0c;查阅了大量资料和官方文档&#xff0c;很多中文资料都有一个共…...

亚洲美女-造相Z-Turbo算力适配实践:24G显存下支持batch_size=2高清图并行生成

亚洲美女-造相Z-Turbo算力适配实践&#xff1a;24G显存下支持batch_size2高清图并行生成 1. 快速了解亚洲美女-造相Z-Turbo 亚洲美女-造相Z-Turbo是一个专门针对亚洲女性形象生成优化的文生图模型&#xff0c;基于Z-Image-Turbo的LoRA版本进行深度定制。这个模型最大的特点是…...

保姆级教程:在PX4 SITL仿真中为Iris无人机挂载Kinect、RPLidar和FPV摄像头

PX4仿真环境多传感器集成实战&#xff1a;从零搭建SLAM无人机开发平台 无人机仿真开发中最令人头疼的&#xff0c;莫过于将各类传感器完美集成到飞行平台上。我曾花了整整两周时间调试Kinect和RPLidar在Gazebo中的兼容性问题&#xff0c;直到找到这套经过验证的解决方案。本文将…...

推荐算法闲谈:如何在不同业务场景下理解和拆解核心指标

巧解决的是能不能学好&#xff0c;而指标分析解决的是这次改动是否真正创造了业务价值&#xff0c;以及为什么。一个非常常见、但又极易被忽视的事实是&#xff1a;推荐系统并不存在一套放之四海而皆准的核心业务指标。不同产品形态、不同交互方式、不同公司发展阶段&#xff0…...

Visual C++运行库一键修复终极指南:快速解决系统依赖问题

Visual C运行库一键修复终极指南&#xff1a;快速解决系统依赖问题 【免费下载链接】vcredist AIO Repack for latest Microsoft Visual C Redistributable Runtimes 项目地址: https://gitcode.com/gh_mirrors/vc/vcredist Visual C运行库是Windows系统中不可或缺的组件…...

如何高效优化Windows系统性能:AtlasOS完整调优指南

如何高效优化Windows系统性能&#xff1a;AtlasOS完整调优指南 【免费下载链接】Atlas &#x1f680; An open and lightweight modification to Windows, designed to optimize performance, privacy and usability. 项目地址: https://gitcode.com/GitHub_Trending/atlas1/…...

为什么需要虚拟摄像头?OBS-VirtualCam 3大核心价值解析

为什么需要虚拟摄像头&#xff1f;OBS-VirtualCam 3大核心价值解析 【免费下载链接】obs-virtual-cam obs-studio plugin to simulate a directshow webcam 项目地址: https://gitcode.com/gh_mirrors/ob/obs-virtual-cam 在视频会议和在线教学中&#xff0c;你是否曾希…...

终极指南:3步用VR-Reversal将3D视频转为2D,普通设备也能自由探索VR世界

终极指南&#xff1a;3步用VR-Reversal将3D视频转为2D&#xff0c;普通设备也能自由探索VR世界 【免费下载链接】VR-reversal VR-Reversal - Player for conversion of 3D video to 2D with optional saving of head tracking data and rendering out of 2D copies. 项目地址…...

从RAG到Agentic RAG 的进化之路

何为Agentic RAG? RAG系统, 为大模型补充了数据, 无论是实时数据还是私域数据. Agentic RAG系统, 更近一步, 为RAG系统添加了Agent的智能, 让AI不光只作用在查询这个阶段, 而是充分利用, Agent的计划(Plan), 自省(reflect), 工具调用(tools use), 编排(orchestrate)等等能力,…...

分组网络频率同步互通测试

概述随着3G/4G网络大规模的部署和应用&#xff0c;网络和业务的全IP化发展&#xff0c;分组传送技术将替代SDH/MSTP网络而成为主流的传送承载网络。这时&#xff0c;一方面新的传送网络技术会对网络的同步性能提出相应的要求&#xff0c;另一方面在通信网络由电路交换型向分组交…...

PasteMD效果展示:3秒将ChatGPT对话转换为规范技术报告

PasteMD效果展示&#xff1a;3秒将ChatGPT对话转换为规范技术报告 1. 为什么你需要这个工具 你有没有过这样的经历&#xff1a;在ChatGPT里反复调试出一段完美的技术方案&#xff0c;复制粘贴到Word文档时却变成一团乱码&#xff1f;公式显示成一串LaTeX代码&#xff0c;表格错…...