add auto fetch ssl certs

This commit is contained in:
2021-08-26 12:11:25 +08:00
parent 11ca254bed
commit 509ac048fc
237 changed files with 4968 additions and 7406 deletions

View File

@@ -45,9 +45,9 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link href="https://h.cowbay.org/css/style.css?v=1626744134" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/style.css?v=1629951055" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1626744134" rel="stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1629951055" rel="stylesheet" type='text/css' media='all'>
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
@@ -81,10 +81,6 @@ if (!doNotTrack) {
<ul id="menu-secondary-items" class="menu-secondary-items">
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/"></a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/ansible">ansible</a>
</li>
@@ -309,24 +305,15 @@ if (!doNotTrack) {
<div class="entry-content">
<article>
<p>這篇繼續講 pgbarman 透過 rsync/ssh 來備份 postgresql 資料庫的方式</p>
<p>其實呢,透過 ssh 的方式來做備份,雖然最後有弄出來,但是我不知道到底做了什麼事才搞定</p>
<p>也許要重新安裝一台來測試看看</p>
<p>所以就簡單說一下邏輯、記得的指令、還有最後的config</p>
<h5 id="ssh">ssh</h5>
<p>在db server 上,讓 barman server 可以用barman 帳號透過ssh key 登入 postgres 帳號
然後在 barman server 上,讓 db server 可以用postgres帳號透過 ssh key 登入 barman 帳號</p>
<h5 id="barman-d">barman.d</h5>
<h5 id="barmand">barman.d</h5>
<p>在/etc/barman.d/ 底下新增一個hqs019-ssh.conf</p>
<p>內容如下</p>
<pre><code>[hqs019-ssh]
description = &quot;hqs019 (via SSH)&quot;
ssh_command = ssh postgres@hqs019
@@ -335,32 +322,19 @@ backup_method = rsync
reuse_backup = link
parallel_jobs = 5
archiver = on
</code></pre>
<h5 id="postgresql-conf">postgresql.conf</h5>
</code></pre><h5 id="postgresqlconf">postgresql.conf</h5>
<p>新增跟barman有關的設定如下</p>
<pre><code>### for barman test
wal_level = 'archive'
archive_mode = on
archive_command = 'rsync -a %p barman@192.168.11.192:/var/lib/barman/hqs019-ssh/incoming/%f'
</code></pre>
<p>理論上這樣就可以了,但是實際上碰到很多問題</p>
</code></pre><p>理論上這樣就可以了,但是實際上碰到很多問題</p>
<p>主要都是這個錯誤訊息</p>
<pre><code>WAL archive: FAILED (please make sure WAL shipping is setup)
</code></pre>
<p>碰到這狀況google 都會告訴你,在 postgresql.conf 裡面 archive_command 的路徑,要和 barman server 上的設定一致
<img src="https://i.imgur.com/3dMdytn.png" alt="" /></p>
</code></pre><p>碰到這狀況google 都會告訴你,在 postgresql.conf 裡面 archive_command 的路徑,要和 barman server 上的設定一致
<img src="https://i.imgur.com/3dMdytn.png" alt=""></p>
<p>但是我的路徑就沒有問題,還是一直跳這個錯誤</p>
<p>接著我又在 barman server 這邊做了這些事情</p>
<pre><code>barman check hqs019-ssh
barman check hqs019-ssh
barman check hqs019-ssh
@@ -384,18 +358,11 @@ barman backup hqs019-ssh
barman show-server hqs019
barman check hqs019
</code></pre>
<p>前面幾次 barman check 一直都不通過</p>
</code></pre><p>前面幾次 barman check 一直都不通過</p>
<p>然後在 barman cron / barman switch-xlog hqs019-ssh (其實這個動作我做過好多次)</p>
<p>想說確認一下psql 連接是不是正確(也的確正確無誤)</p>
<p>接著第一次 check 還是FAILED 喔,過沒多久我再跑一次 check 又正常了&hellip; WTF !!!</p>
<p>只要check 正常,接著跑 backup 應該就會很順利</p>
<pre><code>barman@barman:~$ barman backup hqs019-ssh
Starting backup using rsync-exclusive method for server hqs019-ssh in /var/lib/barman/hqs019-ssh/base/20190823T113229
Backup start at LSN: 264/B7000028 (0000000100000264000000B7, 00000028)
@@ -415,16 +382,10 @@ Processing xlog segments from file archival for hqs019-ssh
0000000100000264000000B7
0000000100000264000000B7.00000028.backup
barman@barman:~$
</code></pre>
<p>檢查一下狀態</p>
</code></pre><p>檢查一下狀態</p>
<pre><code>barman@barman:~$ barman list-backup hqs019-ssh
hqs019-ssh 20190823T113229 - Thu Aug 22 20:38:13 2019 - Size: 132.9 GiB - WAL Size: 0 B (tablespaces: tablespace_a:/var/lib/postgresql/10/main/tablespace_A, tablespace_b:/var/lib/postgresql/10/main/tablespace_B)
</code></pre>
<p>然後為了驗證是不是跑增量備份,所以再執行一次 backup</p>
</code></pre><p>然後為了驗證是不是跑增量備份,所以再執行一次 backup</p>
<pre><code>barman@barman:~$ barman backup hqs019-ssh
Starting backup using rsync-exclusive method for server hqs019-ssh in /var/lib/barman/hqs019-ssh/base/20190823T132124
Backup start at LSN: 264/B9000028 (0000000100000264000000B9, 00000028)
@@ -439,22 +400,13 @@ Processing xlog segments from file archival for hqs019-ssh
0000000100000264000000B9
0000000100000264000000B9.00000028.backup
barman@barman:~$
</code></pre>
<p>可以發現第一次跑了一個多小時,第二次只跑了五秒鐘 (因為資料庫根本沒異動)</p>
</code></pre><p>可以發現第一次跑了一個多小時,第二次只跑了五秒鐘 (因為資料庫根本沒異動)</p>
<p>到這邊雖然功能驗證沒有問題,可是不知道怎麼弄出來的,還是讓我很阿雜..</p>
<p>應該會再找時間來重作一台然後順便測試看看restore</p>
<p>update</p>
<p>剛剛又做了一次測試config 都一樣</p>
<p>果然要先做 barman cron/barman switch-xlog hqs019-ssh</p>
<p>然後再做 barman check 就可以通過了</p>
<p>在文件裡面很少提到這部份筆記一下用ansible 去跑的時候才不會忘記</p>
</article>
</div>
@@ -732,7 +684,7 @@ title="pinterest icon"></i>
</ul> <div class="design-credit">
<p>&copy; 2018 Göran Svensson</p>
<p>© 2018 Göran Svensson</p>
<p>Nederburg Hugo Theme by <a href="https://appernetic.io">Appernetic</a>.</p>
@@ -744,7 +696,7 @@ title="pinterest icon"></i>
</div>
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1626744134"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1629951055"></script>
</body>
</html>