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 1jfgPd-0005kU-AD for pgsql-general@arkaria.postgresql.org; Mon, 01 Jun 2020 09:07:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jfgP6-0000VK-MJ for pgsql-general@arkaria.postgresql.org; Mon, 01 Jun 2020 09:06:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfgP6-0000Sa-C5 for pgsql-general@lists.postgresql.org; Mon, 01 Jun 2020 09:06:44 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jfgP4-0001R8-4D for pgsql-general@postgresql.org; Mon, 01 Jun 2020 09:06:43 +0000 Received: by mail-ej1-x641.google.com with SMTP id o15so8479327ejm.12 for ; Mon, 01 Jun 2020 02:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hidL6cxmrZTrmC1MdmZwUzI4YZp3+8/ulnPZiLUawjA=; b=BA/n5lOaJ9PiaHiSQyOeQU+mFZ7GqE+oFVaq3G3NG5x5gieDwWYGNElEDHX5Dj5C/X YR+8wGp05SoyjDsQN4kTpcM//iHO0YvcI4vyTQQvXjdg1xt+uH5sKXiaPw6AZwUaz9xF OY594n4vmAR8yYgOAk4tLBj5C4JJbsA3LFN0rZALs3M0D/3qx2wHZKsK/Hvw9GIaBmZj uODvFhJt8NuAhbYoaK/nkwGlrcZZ4SgmTg0u033p8VJrGad7IdMIBr/vVdS9OD8eLXUP uMWcL5YkckeyKJQKB0BFENlsrQC2gGZpngu4KK0KnmFg0joVNAG1AWiPjuMkG6vnjCML 4Smg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hidL6cxmrZTrmC1MdmZwUzI4YZp3+8/ulnPZiLUawjA=; b=mHbcLhZO2X+wGwqryDagRY6moy3UWxfi4wE3Julqk0jIs8RpZ+SAuNllTvZ1zLJvLp aItPgEEyP2t2NYxTgOMukasu1dY0Zy3xbjQT7syryOCtH49HawyiqLC8wLWnsqdNn8T7 tUFPlZyUxw4QtYoBwsQ6TNOYKrvTDdWjH/0HlD+eMTMDeYlvx7SYmfwLsjPAZXIENd3U fru6/kHjeD48E7WB+tAKosjaERYGnY3qYFlGGj8yByoL0gd8cx+l6ESIo+5M9dHogd2Z +MfBEn0tg3nyYXUA1cu24LyO7Ht+8PFEYhzgvlyMnQ4YJj66PkwWjDSIvVJj7sbNLTSu zNjg== X-Gm-Message-State: AOAM533sA7eOE7ePb9k8XF7QvE2PtjIc5OzVwcWZ6uZrWgqJ7ax2xK26 NkZbFCzAaYcEUxqeHqApjSE= X-Google-Smtp-Source: ABdhPJzab08aSnRkOPPxtmS/1kKoHbRwM1vCVclbnWYYvG7YX4L8kD5TJc10GG+iHb9meoOPjYLRqA== X-Received: by 2002:a17:906:b2c1:: with SMTP id cf1mr19641159ejb.135.1591002398880; Mon, 01 Jun 2020 02:06:38 -0700 (PDT) Received: from [192.168.1.8] (241-57-239-77.dyn.cable.fcom.ch. [77.239.57.241]) by smtp.gmail.com with ESMTPSA id m3sm15734881ede.58.2020.06.01.02.06.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2020 02:06:38 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: How to start slave after pg_basebackup. Why min_wal_size and wal_keep_segments are duplicated From: =?utf-8?Q?Paul_F=C3=B6rster?= X-Priority: 3 In-Reply-To: Date: Mon, 1 Jun 2020 11:06:37 +0200 Cc: pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: <8BAE2216-8683-4DEE-8529-14457F2775BC@gmail.com> References: <26EC9619620649D1B55C9C95811E4ADB@dell2> <69FF4F48E6FE4A63A2EBD820C5B2B3A3@dell2> To: Andrus X-Mailer: Apple Mail (2.3608.80.23.2.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Andrus, > On 01. Jun, 2020, at 10:17, Andrus wrote: > Shell script starts server after pg_basebackup completes = automatically: >=20 > PGHOST=3Dexample.com > PGPASSWORD=3Dmypass > PGUSER=3Dreplikaator > 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 >=20 > How to create replication server ? I always do it this way and it work for me: $ pg_basebackup -h ${PGHOST} -p ${PGPORT} -U replicator -W -R -D = ${PGDATA} -P -v -Fp -Xs After that, I edit ${PGDATA}/postgresql.conf and (w/ PostgreSQL 11 and = older ${PGDATA}/recovery.conf) to make it do what I want and then I just = launch it: $ pg_ctl start =46rom that moment onward, it replicates and applies to the replica. = Checks in pg_stat_replication on the master and pg_stat_wal_receiver on = the replica confirm that. They also show the WAL switches. To provoke a WAL switch I always do: postgres=3D# checkpoint; select pg_switch_wal(); CHECKPOINT pg_switch_wal=20 --------------- C/50000128 (1 row) I just don't understand what you're trying to achieve here. My guess is, = you want to stop and backup the old database cluster, then create a new = one in its old directory, right? In this case, you probably need to = change your script to something like this: PGHOST=3Dremote.example.com PGPASSWORD=3Dmypass PGUSER=3Dreplikaator PGDATA=3D/var/lib/postgresql/12/main export PGHOST PGPASSWORD PGUSER PGDATA /etc/init.d/postgresql stop mv ${PGDATA} /var/lib/postgresql/12/mainennebaasbakuppi pg_basebackup -h ${PGHOST} -p ${PGPORT} -U ${PGUSER} -W -R -D ${PGDATA} = -P -v -Fp -Xs /etc/init.d/postgresql start Note that my invocation of pg_basebackup asks for the replicator = password. This is intended. You'd probably want to change that. Also, no need to play around with ownership and permissions. Do it as = "postgres", not as "root". Cheers, Paul=