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 1oOYT5-00062u-Vy for pgsql-general@arkaria.postgresql.org; Thu, 18 Aug 2022 05:53:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oOYT4-00043N-Gk for pgsql-general@arkaria.postgresql.org; Thu, 18 Aug 2022 05:53:22 +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 1oOYT4-00043E-4A for pgsql-general@lists.postgresql.org; Thu, 18 Aug 2022 05:53:22 +0000 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oOYT2-0005u9-1z for pgsql-general@lists.postgresql.org; Thu, 18 Aug 2022 05:53:21 +0000 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-f2a4c51c45so688753fac.9 for ; Wed, 17 Aug 2022 22:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc; bh=/sZikwaeiD4206vRxBuGVInibLuhGs4ZKutUrKZLV+U=; b=gQNBHIlL8tHYSWIkpf0v6vYAYXOpLOHnza6r4889d9ODpfDqF0j/1o2FThHijp6DKg yG+WthV5vUdrBxtkaoQHLu8W8uidLaHX5l2HWyErA3d4ks6//TxKdzSN6P9Qim8ycfki ou7NQf24bVGr4vD972tax8l7O7rcLsKPMCaKoUGl/cHS5osk90iQ6DXN+ypTPgI4NNDy AHTm35DWTFlVzW1A0BkjIjzpj/jfYL2wCCL1LAEm/FimkHbvOICZoEMmlIiORrznTYVT r9ME4iWiSuGThNkhccxUzZzsqzOtNZ0YqjG4z9J6MQJo7hoykEESI4GsW9/gu/BmXiGs V4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=/sZikwaeiD4206vRxBuGVInibLuhGs4ZKutUrKZLV+U=; b=y011TF7OMCX7TDmI5aZYMHqwWzXRAfgBYYnzVsKo6iDFMD6m0HPrIhcxSdS2JGeTqE bZdrAGJLNClQO1t5Io0O2CB9ZBP+KSvwyc9az9yUv/XJP8juMyQWgOCpA4U9mX1nOtez 8UR5suw4cn/+FiXmh0nJZuX8vBnRwUll4xW3UzfFe0BSRmlV+gxbCxfapahvf3mLyBzG JTTFto63xBNn5JVoHg6KOA89PvoAZjyO/BMYyCW1D2a16vs5pv2btpNkOLelrvXDt+YA 4NK+V6ZprF7T6JmYHW0TFPHZe2TOpQ3OWvNxhMQNhy641m4DL0nE7XEFxMMPECiOegMq p+/g== X-Gm-Message-State: ACgBeo03uGdvLXigWHcfsIufCI644rGhlj3uRS140zPbEIvoGduZwaFF oXa9Sc8Lih5eANMBrU3oSYJpvnZdLpQ= X-Google-Smtp-Source: AA6agR7DIqB4gloofGiibATNzPPi/Cajh/DetCDCEGnqeX0HSypbrrUUeIAM6PwKKVGvndAWwW+bXQ== X-Received: by 2002:a05:6870:f693:b0:101:cb61:2937 with SMTP id el19-20020a056870f69300b00101cb612937mr646133oab.151.1660801997298; Wed, 17 Aug 2022 22:53:17 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id u24-20020a9d4d98000000b006372969fbdcsm211173otk.26.2022.08.17.22.53.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Aug 2022 22:53:16 -0700 (PDT) Message-ID: <965d939f-b84f-104c-9516-898dcd22d628@gmail.com> Date: Thu, 18 Aug 2022 00:53:15 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Setting up streaming replication on large database (20+ TB) for the first time Content-Language: en-US To: pgsql-general@lists.postgresql.org References: From: Ron In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk pg_backrest will certainly backup your data faster. It might be able to be used as a seed instead of pg_basebackup. On 8/17/22 15:06, Ivan N. Ivanov wrote: > I have a large database (~25 TB) and I want to set up streaming > replication for the first time. > > My problem is that after completion of the pg_basebackup (which completed > for 2 days with --wal-method=none) now PG is replaying the WAL files from > the WAL archive directory but it can not keep up. The replaying of WAL > files is the same as the physical time, for example: > > 2022-08-17 22:42:57 EEST [13507-6] [] DETAIL:  Last completed transaction > was at log time 2022-08-15 18:24:02.155289+03. > 2022-08-17 22:48:35 EEST [13507-12] [] DETAIL:  Last completed transaction > was at log time 2022-08-15 18:29:54.962822+03. > 2022-08-17 22:54:35 EEST [13507-16] [] DETAIL:  Last completed transaction > was at log time 2022-08-15 18:34:20.099468+03. > > From ~22:43 to ~22:48 there are 5 minutes. And completed transactions are > at ~18:24 and ~18:29 (5 minutes). > > I have even put all WAL files from the archive directly in the pg_wal > directory of the replica and now PostgreSQL skips the cp command from > restore_command, i.e. I have removed the restore_command and now the WAL > files are only recovering, this is the only operation, but it is slow: > > postgres: startup   recovering 000000010003FC7900000013 > postgres: startup   recovering 000000010003FC7900000014 > postgres: startup   recovering 000000010003FC7900000015 > ... > > And it cannot keep up and my replication cannot start since it is 2 days > behind the master... The replica has the same SSD disks as the master. > > Is there a better way to do this? How to speed up recovering of WAL files? > I have increased shared_buffers as much as I can... Is there something > that I miss from the recovery process? > > I do not have problems setting up replications for the first time for > small database (10 GB - 100 GB), but for 25 TB I can not set the > replication, because of this lag. > -- Angular momentum makes the world go 'round.