Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jffde-00049l-SC for pgsql-general@arkaria.postgresql.org; Mon, 01 Jun 2020 08:17:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jffdc-00075r-AW for pgsql-general@arkaria.postgresql.org; Mon, 01 Jun 2020 08:17:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jffdc-00075k-2b for pgsql-general@lists.postgresql.org; Mon, 01 Jun 2020 08:17:40 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.125]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jffdZ-00028n-Tp for pgsql-general@postgresql.org; Mon, 01 Jun 2020 08:17:39 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 6DC261C0E; Mon, 1 Jun 2020 11:17:36 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CPN-WbpKkGN1; Mon, 1 Jun 2020 11:17:34 +0300 (EEST) Received: from mail.hot.ee (hot-relayhost2.estpak.ee [213.180.2.80]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 2FECB1BC9; Mon, 1 Jun 2020 11:17:34 +0300 (EEST) Received: from dell2 (66-63-196-88.sta.estpak.ee [88.196.63.66]) (Authenticated sender: kobruleht2) by HOT-Relayhost2.estpak.ee (Postfix) with ESMTPSA id 49b7MJ5mckz2JR; Mon, 1 Jun 2020 11:17:31 +0300 (EEST) Message-ID: From: "Andrus" To: =?iso-8859-1?Q?Paul_F=F6rster?= Cc: "pgsql-general" References: <26EC9619620649D1B55C9C95811E4ADB@dell2> <69FF4F48E6FE4A63A2EBD820C5B2B3A3@dell2> In-Reply-To: Subject: Re: How to start slave after pg_basebackup. Why min_wal_size and wal_keep_segments are duplicated Date: Mon, 1 Jun 2020 11:17:19 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi! > I have tried to re-initiate replica serveral times in low-use time but this error occurs again. >remove the whole replica's PGDATA/* and do a pg_basebackup again. But before that, make sure wal_keep_segments in big enough on the >master and, I renamed whole cluster before pg_basebackup >just as much important, do a vacuumdb -a (takes much space during the process) and use archiving! I run vacuumdb --full --all before pg_basebackup > If named replication slot is used commands like > vacuumdb --all --full > will cause main server crash due to disk space limit. pg_wal directory will occupy free disk space. After that main server stops. >>if you have disk constraints you will run into trouble sooner or later anyway. Make sure, you have enough disk space. There's no >>way around that anyway. This space is sufficient for base backup and replication. >> I tried using wal_keep_segments =180 >> Will setting wal_keep_segments to higher value allw replication start after pg_basebackup ? >it depends. If you start the replica immediately and don't wait for hours or days, you should be good to go. But that depends on >different factors, for example, how >many WAL files are written during the pg_basebackup and pg_ctl start of the replica. If more >than 180 WALs have gone by on the master because it is really busy, >then you're probably lost again. Point being, you'll have to >launch the replica before WALs are expired! >Again: Make sure you have enough disk space, use archiving and use a replication slot. I tried with wal_keep_segments=360 but problem persisists. Server generates lot of less than 300 wal files. Shell script starts server after pg_basebackup completes automatically: PGHOST=example.com PGPASSWORD=mypass PGUSER=replikaator export PGHOST PGPASSWORD PGUSER /etc/init.d/postgresql stop mv /var/lib/postgresql/12/main /var/lib/postgresql/12/mainennebaasbakuppi pg_basebackup --verbose --progress --write-recovery-conf -D /var/lib/postgresql/12/main chmod --recursive --verbose 0700 /var/lib/postgresql/12/main chown -Rv postgres:postgres /var/lib/postgresql/12/main /etc/init.d/postgresql start How to create replication server ? Andrus.