<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>@znz blog</title> <description>ZnZ の memo のようなもの</description> <link>https://blog.n-z.jp/</link> <atom:link href="https://blog.n-z.jp/feed.xml" rel="self" type="application/rss+xml"/> <pubDate>Thu, 12 Mar 2026 01:48:13 +0000</pubDate> <lastBuildDate>Thu, 12 Mar 2026 01:48:13 +0000</lastBuildDate> <generator>Jekyll v4.4.1</generator> <item> <title>外部ドライブなしでTime Machineバックアップを設定する</title> <description>&lt;p&gt;macOS の Time Machine バックアップはネットワークストレージだとバックアップも復元も遅いという問題があったり、 外部ドライブ (USB HDD) だと接続が切れることがあるので MacBook Pro を物理的に動かしにくくなったりする問題があったりして、 他の手段を検討した結果、ローカルに sparse bundle を作成して使う方法があるとわかったので、設定してみました。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;確認環境&quot;&gt;確認環境&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;MacBook Pro 14 インチ, 11月 2024&lt;/li&gt; &lt;li&gt;macOS Tahoe 26.3&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;sparse-bundle-作成&quot;&gt;sparse bundle 作成&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://docs.wasabi.com/docs/how-to-back-up-macos-using-time-machine-to-a-mountable-drive-and-sync-to-wasabi-via-rclone&quot;&gt;Time Machine With Wasabi via a Mountable Drive and Rclone&lt;/a&gt; や &lt;a href=&quot;https://docs.wasabi.com/docs/how-to-back-up-macos-using-time-machine-to-cyberduck&quot;&gt;Time Machine With Wasabi via Cyberduck&lt;/a&gt; を参考にしました。&lt;/p&gt; &lt;p&gt;まず容量と暗号化するかどうか決めて以下のように作成します。 暗号化する場合の違いは後で説明します。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hdiutil create &lt;span class=&quot;nt&quot;&gt;-size&lt;/span&gt; 500g &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; SPARSEBUNDLE &lt;span class=&quot;nt&quot;&gt;-fs&lt;/span&gt; HFS+J &lt;span class=&quot;nt&quot;&gt;-volname&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;TimeMachineDisk&quot;&lt;/span&gt; ~/TimeMachineDisk.sparsebundle &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-size 500g&lt;/code&gt; はマウント後の &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;df -h&lt;/code&gt; で確認すると 500Gi になっています。(2026-02-22 追記: 500g は大きすぎたので &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo du -shc /Volumes/TimeMachineDisk/Backups.backupdb/knmbp24/Latest/Data/* | sort -h&lt;/code&gt; でバックアップ対象が 40G ぐらいなのを確認して 100g にして様子をみています。)&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-type SPARSEBUNDLE&lt;/code&gt; は sparse bundle を明示していますが、拡張子があれば省略可能と hdiutil の manpage に書いてありました。&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-fs HFS+J&lt;/code&gt; は hdiutil の manpage をみてもはっきりとした説明はなかったのですが、ジャーナリングの HFS+ だと思います。&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-volname&lt;/code&gt; は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/Volumes&lt;/code&gt; の中に出てくるディレクトリ名になったり、Finder で見える名前になったりしていました。&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;バックアップ設定&quot;&gt;バックアップ設定&lt;/h2&gt; &lt;p&gt;フルディスクアクセス権限が必要な操作があったはずなので、普段使いの端末ソフトに権限をつけたくないなら、 他の端末ソフトを用意するなどの準備が必要です。&lt;/p&gt; &lt;p&gt;以下のようにバックアップ設定します。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tmutil addexclusion ~/TimeMachineDisk.sparsebundle hdiutil attach ~/TimeMachineDisk.sparsebundle &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;tmutil setdestination /Volumes/TimeMachineDisk tmutil destinationinfo &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/Volumes/TimeMachineDisk&lt;/code&gt; は自動で Time Machine バックアップから除外されますが、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TimeMachineDisk.sparsebundle&lt;/code&gt; 自体は除外されなさそうなので、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tmutil addexclusion&lt;/code&gt; で明示的に除外属性をつけておきます。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hdiutil attach&lt;/code&gt; でマウントした後、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo tmutil setdestination&lt;/code&gt; で Time Machine バックアップ先に設定します。 (追加する場合は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tmutil setdestination -a&lt;/code&gt; です。)&lt;/p&gt; &lt;p&gt;最後に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tmutil destinationinfo&lt;/code&gt; で確認しています。&lt;/p&gt; &lt;h2 id=&quot;バックアップ作成&quot;&gt;バックアップ作成&lt;/h2&gt; &lt;p&gt;GUI からスタートするか、コマンドで以下のような感じでバックアップ開始します。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tmutil startbackup &lt;span class=&quot;nt&quot;&gt;--auto&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--block&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;バックアップ設定削除&quot;&gt;バックアップ設定削除&lt;/h2&gt; &lt;p&gt;Time Machine の設定で確認すると暗号化されていなかったので、 一度削除して作りなおしました。&lt;/p&gt; &lt;p&gt;Time Machine のバックアップ先からは &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tmutil removedestination&lt;/code&gt; でも削除できますが、GUI から削除しました。&lt;/p&gt; &lt;p&gt;eject して sparse bundle も削除すれば元通りです。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hdiutil eject /Volumes/TimeMachineDisk &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; ~/TimeMachineDisk.sparsebundle &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;暗号化ありで-sparse-bundle-作成&quot;&gt;暗号化ありで sparse bundle 作成&lt;/h2&gt; &lt;p&gt;まず、 &lt;a href=&quot;http://webos-goodies.jp/archives/use_google_drive_as_encrypted_backup_solution_on_mac.html&quot;&gt;Mac で Google Drive 等への暗号化バックアップを行う方法 - WebOS Goodies&lt;/a&gt; を参考にして暗号化用の証明書を作成しました。&lt;/p&gt; &lt;p&gt;まず、「キーチェーンアクセス」アプリを開きます。「パスワード」アプリとの選択肢が出てきても「キーチェーンアクセス」を開きます。 メニューの「キーチェーンアクセス」の「証明書アシスタント」の「証明書を作成…」で&lt;/p&gt; &lt;ul&gt; &lt;li&gt;名前: CloudBackup&lt;/li&gt; &lt;li&gt;固有名のタイプ: 自己署名ルート のまま&lt;/li&gt; &lt;li&gt;証明書のタイプ: S/MIME のまま&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;で証明書を作成しました。&lt;/p&gt; &lt;p&gt;作成された証明書は「デフォルトキーチェーン」の「iCloud」ではなく「ログイン」の方に入っているので、「種類」が「証明書」の行をデスクトップにドラッグアンドドロップで保存します。&lt;/p&gt; &lt;p&gt;以下のように保存した証明書を &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-certificate&lt;/code&gt; に指定して sparse bundle を作成します。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hdiutil create &lt;span class=&quot;nt&quot;&gt;-size&lt;/span&gt; 500g &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; SPARSEBUNDLE &lt;span class=&quot;nt&quot;&gt;-fs&lt;/span&gt; HFS+J &lt;span class=&quot;nt&quot;&gt;-volname&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;TimeMachineDisk&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-encryption&lt;/span&gt; AES-256 &lt;span class=&quot;nt&quot;&gt;-certificate&lt;/span&gt; ~/Desktop/CloudBackup.cer ~/TimeMachineDisk.sparsebundle &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;hdiutil の manpage によると &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-encryption&lt;/code&gt; は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AES-128&lt;/code&gt; か &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AES-256&lt;/code&gt; しか指定できないので、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AES-256&lt;/code&gt; にしておけば良さそうです。&lt;/p&gt; &lt;h2 id=&quot;証明書のバックアップ&quot;&gt;証明書のバックアップ&lt;/h2&gt; &lt;p&gt;「種類」が「証明書」の行を右クリックなどでコンテキストメニューを開いて、「”CloudBackup”を書き出す…」から「個人情報交換(.p12)」で保存します。 名前は「CloudBackup」にして「CloudBackup.p12」として保存しました。 そのとき、秘密鍵を保護するパスワードとその確認、キーチェーンのパスワード(ログインパスワード) を要求されました。&lt;/p&gt; &lt;p&gt;sparse bundle のマウントに必要になるので、「CloudBackup.p12」は別途安全な場所に保管しておきます。&lt;/p&gt; &lt;p&gt;旧 MacBook Pro がまだあるので、そちらに CloudBackup.p12 も持っていって sparse bundle が開けることを確認しています。 (秘密鍵の行から書き出したファイルを持っていっても sparse bundle を開けませんでした。)&lt;/p&gt; &lt;p&gt;再確認できていませんが、インポートはキーチェーンアクセスへのドロップではできなくて、p12 ファイルを開いて読み込みした気がします。&lt;/p&gt; &lt;h2 id=&quot;バックアップ設定-1&quot;&gt;バックアップ設定&lt;/h2&gt; &lt;p&gt;暗号化なしと同様にバックアップ設定します。 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hdiutil attach&lt;/code&gt; でキーチェーンのパスワード (ログインパスワード) を要求されました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tmutil addexclusion ~/TimeMachineDisk.sparsebundle hdiutil attach ~/TimeMachineDisk.sparsebundle &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;tmutil setdestination /Volumes/TimeMachineDisk tmutil destinationinfo &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Time Machine の設定で「空き 536.08 GB、暗号化」となっていて「暗号化」がついているのが確認できました。&lt;/p&gt; &lt;h2 id=&quot;除外設定&quot;&gt;除外設定&lt;/h2&gt; &lt;p&gt;以下のように &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tmutil addexclusion&lt;/code&gt; で追加するか、 GUI で Time Machine 設定のオプションから除外設定を追加します。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tmutil addexclusion ~/.colima tmutil addexclusion ~/.config/colima tmutil addexclusion ~/.lima tmutil addexclusion ~/.pcloud &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tmutil addexclusion&lt;/code&gt; は拡張属性の設定なので、 GUI の設定と同期していませんが、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tmutil addexclusion -p&lt;/code&gt; が GUI の設定と同期しているようなので、 フルディスクアクセス権限があれば &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-p&lt;/code&gt; ありの方が便利そうです。&lt;/p&gt; &lt;p&gt;他には &lt;a href=&quot;https://note.com/biscuit_browser/n/n4e51af034f90&quot;&gt;Biscuitの環境を他のパソコンに移す方法&lt;/a&gt; で Chromium ベースのアプリ全般で cache とつくディレクトリは消しても大丈夫そうかなと思ったので、 以下のように除外設定を追加しています。 (以下にない他の Chromium ベースのアプリも含めて設定しています。)&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;find ~/Library/Application&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Support/biscuit &lt;span class=&quot;nt&quot;&gt;-iname&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;*cache*&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-print0&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-prune&lt;/span&gt; | xargs &lt;span class=&quot;nt&quot;&gt;-0&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--verbose&lt;/span&gt; tmutil addexclusion find ~/Library/Application&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;Support/Google &lt;span class=&quot;nt&quot;&gt;-iname&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;*cache*&apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-print0&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-prune&lt;/span&gt; | xargs &lt;span class=&quot;nt&quot;&gt;-0&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--verbose&lt;/span&gt; tmutil addexclusion &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;他にも &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;du -sh .??* * | sort -h&lt;/code&gt; などでみつけた容量の大きいバックアップが不要そうなものは除外しました。&lt;/p&gt; &lt;h2 id=&quot;sparse-bundle-のバックアップ&quot;&gt;sparse bundle のバックアップ&lt;/h2&gt; &lt;p&gt;マウント確認のために rsync で旧 MacBook Pro に転送してみたり、 pCloud Drive に入れて戻して実行パーミッションなどが消えても大丈夫か試してみたりしました。&lt;/p&gt; &lt;p&gt;大丈夫そうなので、今後は rclone か何かで定期的にバックアップするようにしようと思っています。&lt;/p&gt; &lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt; &lt;p&gt;ローカルのみで Time Machine バックアップを有効にできることが確認できました。&lt;/p&gt; &lt;p&gt;外部へバックアップしなくても、Time Machine バックアップをブラウズで履歴が見えるようになるだけでも便利そうなので、 外部ディスクやクラウドストレージを用意できない環境でも試してみる価値がありそうだと思いました。&lt;/p&gt; </description> <pubDate>Sun, 15 Feb 2026 14:00:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2026-02-15-time-machine-without-usb-storage.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2026-02-15-time-machine-without-usb-storage.html</guid> <category>ruby</category> <category>macos</category> <category>blog</category> </item> <item> <title>headscale+tailscaleに移行中</title> <description>&lt;p&gt;&lt;a href=&quot;https://lilo.connpass.com/event/381726/&quot;&gt;LILO&amp;amp;東海道らぐオフラインミーティング 2026-02-01&lt;/a&gt; で発表したのですが、 VPN 環境を Headscale + Tailscale に移行しました。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;動作確認環境&quot;&gt;動作確認環境&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;Headscale 0.27.1 から 0.28.0&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;イベントでの発表時点では 0.27.1 でしたが、その後 0.28.0 に上げたら状況が変わっていました。&lt;/p&gt; &lt;h2 id=&quot;発表資料&quot;&gt;発表資料&lt;/h2&gt; &lt;p&gt;スライドはいつも通り &lt;a href=&quot;https://slide.rabbit-shocker.org/authors/znz/lilo-20260201/&quot;&gt;Rabbit Slide Show&lt;/a&gt; (&lt;a href=&quot;https://rubygems.org/gems/rabbit-slide-znz-lilo-20260201&quot;&gt;RubyGems&lt;/a&gt;), &lt;a href=&quot;http://www.slideshare.net/znzjp/headscale-tailscale-at-2026-02-01&quot;&gt;SlideShare&lt;/a&gt;, &lt;a href=&quot;https://speakerdeck.com/znz/headscale-plus-tailscale-niyi-xing-zhong&quot;&gt;Speaker Deck&lt;/a&gt; にあげています。(ソースは &lt;a href=&quot;https://github.com/znz/lilo-20260201&quot;&gt;github&lt;/a&gt; にあげています。)&lt;/p&gt; &lt;amp-iframe src=&quot;https://slide.rabbit-shocker.org/authors/znz/lilo-20260201/viewer.html&quot; width=&quot;640&quot; height=&quot;524&quot; sandbox=&quot;allow-scripts allow-same-origin&quot; scrolling=&quot;no&quot; allowfullscreen=&quot;&quot;&gt; &lt;/amp-iframe&gt; &lt;div&gt; &lt;p&gt;&lt;a href=&quot;https://slide.rabbit-shocker.org/authors/znz/lilo-20260201/&quot; title=&quot;Headscale + Tailscale に移行中&quot;&gt;Headscale + Tailscale に移行中&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; &lt;h2 id=&quot;ユーザーとタグの扱い&quot;&gt;ユーザーとタグの扱い&lt;/h2&gt; &lt;p&gt;0.28.0 に上げると、タグを設定しているノードは &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tagged-devices&lt;/code&gt; ユーザーに移動してしまいました。&lt;/p&gt; &lt;p&gt;発表中には口頭でユーザーを移動できるので、所有ユーザーは適当に設定していたと話しましたが、 &lt;a href=&quot;https://github.com/juanfont/headscale/pull/2922&quot;&gt;https://github.com/juanfont/headscale/pull/2922&lt;/a&gt; でユーザーを変える機能は消えていました。&lt;/p&gt; &lt;p&gt;すべてのノードに &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user:sakura&lt;/code&gt; なら &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tag:sakura&lt;/code&gt; などのようにユーザー名と同じタグもつけていたので、 ACL に大きな影響はありませんでした。&lt;/p&gt; &lt;p&gt;しかし、ユーザーの端末にはタグをつけないことを想定しているようで、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tag:zabbix-agent&lt;/code&gt; と併用できなくなってしまうので、 そのあたりの ACL 設定を含めてどう移行しようか、 まだ悩み中です。&lt;/p&gt; &lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt; &lt;p&gt;LILO&amp;amp;東海道らぐのイベントで発表した内容とその後の状況を紹介しました。&lt;/p&gt; &lt;p&gt;影響がなければ発表内容をまとめなおして記事にする予定だったのですが、状況が変わっていたので、その部分の追加の話になってしまいました。&lt;/p&gt; </description> <pubDate>Sat, 14 Feb 2026 14:00:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2026-02-14-headscale.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2026-02-14-headscale.html</guid> <category>headscale</category> <category>tailscale</category> <category>blog</category> </item> <item> <title>OpenLDAPのバックエンドをhdbからmdbへ移行した</title> <description>&lt;p&gt;VPS で動かしている Ubuntu や Debian のバージョンアップのブロッカーになっていた OpenLDAP (slapd) のバックエンドデータベースをやっと hdb から mdb に移行しました。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;対象環境&quot;&gt;対象環境&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;Ubuntu 20.04.6 LTS (focal) &lt;ul&gt; &lt;li&gt;slapd 2.4.49+dfsg-2ubuntu1.10&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;Debian GNU/Linux 11 (bullseye) &lt;ul&gt; &lt;li&gt;slapd 2.4.57+dfsg-3+deb11u1&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;移行手順の概要&quot;&gt;移行手順の概要&lt;/h2&gt; &lt;p&gt;まず &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;slapcat&lt;/code&gt; で LDAP データベースのバックアップをとって、 hdb のデータベースは削除します。&lt;/p&gt; &lt;p&gt;そして &lt;a href=&quot;https://github.com/DSI-Universite-Rennes2/openldap-migrate-backend&quot;&gt;https://github.com/DSI-Universite-Rennes2/openldap-migrate-backend&lt;/a&gt; を参考にして、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/ldap/slapd.d/&lt;/code&gt; の &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.&lt;/code&gt; と書いてあるファイルの内容を直接書き換えて、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CRC32&lt;/code&gt; がずれるのは &lt;a href=&quot;https://gogs.zionetrix.net/bn8/check_slapdd_crc32&quot;&gt;https://gogs.zionetrix.net/bn8/check_slapdd_crc32&lt;/a&gt; で修正します。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;slapadd&lt;/code&gt; で mdb としてデータベースを復元して動作確認ができれば終了です。&lt;/p&gt; &lt;h2 id=&quot;バックアップ&quot;&gt;バックアップ&lt;/h2&gt; &lt;p&gt;まず &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;slapcat&lt;/code&gt; を使って適当なファイル名でバックアップをとっておきます。&lt;/p&gt; &lt;p&gt;0 は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cn=config&lt;/code&gt; なので、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/ldap/slapd.d&lt;/code&gt; を直接バックアップした方が良さそうです。 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;etckeeper&lt;/code&gt; を使っているので、そこのバックアップはしていません。&lt;/p&gt; &lt;p&gt;1 がメインのデータベースなので、後で使います。&lt;/p&gt; &lt;p&gt;2 は accesslog で使う設定にしていますが、設定がちゃんとできていなかったらしく、 トップレベルの &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dn: cn=accesslog&lt;/code&gt; だけで他に何もデータが入っていませんでした。&lt;/p&gt; &lt;p&gt;普通は 1 だけとっておけばいいと思います。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;slapcat &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 0 &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; slapcat.0.&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;.ldif &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;slapcat &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 1 &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; slapcat.1.&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;.ldif &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;slapcat &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 2 &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; slapcat.2.&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;.ldif &lt;span class=&quot;nb&quot;&gt;sudo chmod &lt;/span&gt;640 slapcat.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.ldif &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;移行対象を停止&quot;&gt;移行対象を停止&lt;/h2&gt; &lt;p&gt;syncrepl で 2 台体制で動かしているので、1台止めて移行します。&lt;/p&gt; &lt;p&gt;止めても &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getent passwd&lt;/code&gt; などがちゃんと動くのを確認しておきます。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl stop slapd.service getent passwd &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;olcdbdirectory&quot;&gt;olcDbDirectory&lt;/h2&gt; &lt;p&gt;olcDbDirectory を確認して削除して空ディレクトリを作りなおしておきます。 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo slapadd&lt;/code&gt; で root 所有のファイルができるので、後でまとめて &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chown&lt;/code&gt; するので、 空ディレクトリは root 所有のままにしました。&lt;/p&gt; &lt;p&gt;ディレクトリがないと &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo slaptest -u -F /etc/ldap/slapd.d&lt;/code&gt; でエラーになります。&lt;/p&gt; &lt;p&gt;空ディレクトリの作成は普通は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo mkdir -p /var/lib/ldap&lt;/code&gt; でいいと思います。&lt;/p&gt; &lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /etc/ldap &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; olcDbDirectory &lt;span class=&quot;go&quot;&gt;slapd.d/cn=config/olcDatabase={1}hdb.ldif:olcDbDirectory: /var/lib/ldap slapd.d/cn=config/olcDatabase={2}hdb.ldif:olcDbDirectory: /var/lib/ldap/accesslog &lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-al&lt;/span&gt; /var/lib/ldap/ &lt;span class=&quot;go&quot;&gt;合計 11212 drwxr-xr-x 3 openldap openldap 4096 12月 31 18:06 . drwxr-xr-x 56 root root 4096 11月 20 2024 .. -rw-r--r-- 1 openldap openldap 96 8月 2 2014 DB_CONFIG -rw------- 1 openldap openldap 532479 12月 31 18:06 __db.001 -rw------- 1 openldap openldap 139263 12月 31 18:06 __db.002 -rw------- 1 openldap openldap 286719 12月 31 18:06 __db.003 drwxr-xr-x 2 openldap openldap 4096 12月 31 18:06 accesslog -rw-r--r-- 1 openldap openldap 4096 12月 31 18:06 alock -rw------- 1 openldap openldap 28672 3月 21 2016 cn.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 displayName.bdb -rw------- 1 openldap openldap 24576 3月 21 2016 dn2id.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 entryCSN.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 entryUUID.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 gidNumber.bdb -rw------- 1 openldap openldap 16384 3月 21 2016 givenName.bdb -rw------- 1 openldap openldap 81920 3月 21 2016 id2entry.bdb -rw------- 1 openldap openldap 10485759 12月 31 17:59 log.0000000001 -rw------- 1 openldap openldap 8192 3月 21 2016 loginShell.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 member.bdb -rw------- 1 openldap openldap 16384 3月 21 2016 memberUid.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 objectClass.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 ou.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 sambaDomainName.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 sambaGroupType.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 sambaPrimaryGroupSID.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 sambaSID.bdb -rw------- 1 openldap openldap 16384 3月 21 2016 sn.bdb -rw------- 1 openldap openldap 16384 3月 21 2016 uid.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 uidNumber.bdb &lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-al&lt;/span&gt; /var/lib/ldap/accesslog/ &lt;span class=&quot;go&quot;&gt;合計 10828 drwxr-xr-x 2 openldap openldap 4096 12月 31 18:06 . drwxr-xr-x 3 openldap openldap 4096 12月 31 18:06 .. -rw-r--r-- 1 openldap openldap 96 8月 2 2014 DB_CONFIG -rw------- 1 openldap openldap 532479 12月 31 18:06 __db.001 -rw------- 1 openldap openldap 139263 12月 31 18:06 __db.002 -rw------- 1 openldap openldap 114687 12月 31 18:06 __db.003 -rw-r--r-- 1 openldap openldap 4096 12月 31 18:06 alock -rw------- 1 openldap openldap 8192 3月 21 2016 dn2id.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 entryCSN.bdb -rw------- 1 openldap openldap 32768 3月 21 2016 id2entry.bdb -rw------- 1 openldap openldap 10485759 12月 31 17:59 log.0000000001 -rw------- 1 openldap openldap 8192 3月 21 2016 objectClass.bdb -rw------- 1 openldap openldap 8192 3月 21 2016 reqStart.bdb &lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; /var/lib/ldap/ &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /var/lib/ldap/accesslog &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;check_slapdd_crc32-を用意&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;check_slapdd_crc32&lt;/code&gt; を用意&lt;/h2&gt; &lt;p&gt;CRC32 修正用のコマンドを用意しておきます。&lt;/p&gt; &lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;git clone https://gogs.zionetrix.net/bn8/check_slapdd_crc32 &lt;span class=&quot;go&quot;&gt;Cloning into &apos;check_slapdd_crc32&apos;... warning: redirecting to https://gitea.zionetrix.net/bn8/check_slapdd_crc32/ remote: Enumerating objects: 61, done. remote: Counting objects: 100% (61/61), done. remote: Compressing objects: 100% (51/51), done. remote: Total 61 (delta 22), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (61/61), 12.16 KiB | 47.00 KiB/s, done. Resolving deltas: 100% (22/22), done. &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;書き換え&quot;&gt;書き換え&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/DSI-Universite-Rennes2/openldap-migrate-backend&quot;&gt;https://github.com/DSI-Universite-Rennes2/openldap-migrate-backend&lt;/a&gt; の手順を参考にして手で書き換えました。 シェルスクリプトの内容を確認して、直接実行でも良いと思います。&lt;/p&gt; &lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-ri&lt;/span&gt; hdb &lt;span class=&quot;go&quot;&gt;slapd.d/cn=config/olcDatabase={1}hdb.ldif:dn: olcDatabase={1}hdb slapd.d/cn=config/olcDatabase={1}hdb.ldif:objectClass: olcHdbConfig slapd.d/cn=config/olcDatabase={1}hdb.ldif:olcDatabase: {1}hdb slapd.d/cn=config/olcDatabase={1}hdb.ldif:structuralObjectClass: olcHdbConfig slapd.d/cn=config/cn=module{0}.ldif:olcModuleLoad: {0}back_hdb slapd.d/cn=config/olcBackend={0}hdb.ldif:dn: olcBackend={0}hdb slapd.d/cn=config/olcBackend={0}hdb.ldif:olcBackend: {0}hdb slapd.d/cn=config/olcDatabase={2}hdb.ldif:dn: olcDatabase={2}hdb slapd.d/cn=config/olcDatabase={2}hdb.ldif:objectClass: olcHdbConfig slapd.d/cn=config/olcDatabase={2}hdb.ldif:olcDatabase: {2}hdb slapd.d/cn=config/olcDatabase={2}hdb.ldif:structuralObjectClass: olcHdbConfig &lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo mv&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-vi&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcBackend&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;0&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;hdb.ldif slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcBackend&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;0&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif &lt;span class=&quot;gp&quot;&gt;renamed &apos;slapd.d/cn=config/olcBackend={0}hdb.ldif&apos; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;slapd.d/cn=config/olcBackend={0}mdb.ldif&apos;&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo mv&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-vi&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;1&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;hdb.ldif slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;1&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif &lt;span class=&quot;gp&quot;&gt;renamed &apos;slapd.d/cn=config/olcDatabase={1}hdb.ldif&apos; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;slapd.d/cn=config/olcDatabase={1}mdb.ldif&apos;&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo mv&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-vi&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;2&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;hdb.ldif slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;2&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif &lt;span class=&quot;gp&quot;&gt;renamed &apos;slapd.d/cn=config/olcDatabase={2}hdb.ldif&apos; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;slapd.d/cn=config/olcDatabase={2}mdb.ldif&apos;&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo mv&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-vi&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;1&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;hdb slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;1&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb &lt;span class=&quot;gp&quot;&gt;renamed &apos;slapd.d/cn=config/olcDatabase={1}hdb&apos; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;slapd.d/cn=config/olcDatabase={1}mdb&apos;&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo mv&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-vi&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;2&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;hdb slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;2&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb &lt;span class=&quot;gp&quot;&gt;renamed &apos;slapd.d/cn=config/olcDatabase={2}hdb&apos; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;slapd.d/cn=config/olcDatabase={2}mdb&apos;&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;s/back_hdb/back_mdb/&apos;&lt;/span&gt; slapd.d/cn&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;config/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;module&lt;span class=&quot;se&quot;&gt;\{&lt;/span&gt;0&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;.ldif &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;s/hdb/mdb/&apos;&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcBackend&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;0&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;1&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;2&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;s/Hdb/Mdb/&apos;&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;1&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;2&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;attr &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;olcDbCacheFree olcDbCacheSize olcDbChecksum olcDbConfig olcDbCryptFile olcDbCryptKey olcDbDNcacheSize olcDbDirtyRead olcDbIDLcacheSize olcDbLinearIndex olcDbLockDetect olcDbPageSize olcDbShmKey&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/^&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$attr&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:/d&quot;&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;1&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;/^olcAccess: {0}/i olcDbMaxSize: 1000000000&apos;&lt;/span&gt; slapd.d/cn&lt;span class=&quot;se&quot;&gt;\=&lt;/span&gt;config/olcDatabase&lt;span class=&quot;se&quot;&gt;\=\{&lt;/span&gt;1&lt;span class=&quot;se&quot;&gt;\}&lt;/span&gt;mdb.ldif &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; ~/check_slapdd_crc32/check_slapdd_crc32 &lt;span class=&quot;nt&quot;&gt;--fix&lt;/span&gt; &lt;span class=&quot;go&quot;&gt;2025-12-31 18:11:21,901 - check_slapdd_crc32 - WARNING - /etc/ldap/slapd.d/cn=config/olcDatabase={0}config.ldif: no CRC32 value found. Correct CRC32 value is &quot;47dba06d&quot;. 2025-12-31 18:11:21,902 - check_slapdd_crc32 - WARNING - /etc/ldap/slapd.d/cn=config/olcBackend={0}mdb.ldif: invalid CRC32 value found (f6ccc16c != 1918d801) 2025-12-31 18:11:21,902 - check_slapdd_crc32 - WARNING - /etc/ldap/slapd.d/cn=config/cn=module{0}.ldif: invalid CRC32 value found (bc225411 != f86810e2) 2025-12-31 18:11:21,902 - check_slapdd_crc32 - WARNING - /etc/ldap/slapd.d/cn=config/olcDatabase={1}mdb.ldif: invalid CRC32 value found (4b81209f != 7623f07e) 2025-12-31 18:11:21,903 - check_slapdd_crc32 - WARNING - /etc/ldap/slapd.d/cn=config/olcDatabase={2}mdb.ldif: invalid CRC32 value found (09c73f52 != 6c208dd4) &lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;slaptest &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-F&lt;/span&gt; /etc/ldap/slapd.d &lt;span class=&quot;go&quot;&gt;config file testing succeeded &lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;slapschema &lt;span class=&quot;nt&quot;&gt;-F&lt;/span&gt; /etc/ldap/slapd.d &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;cn=config&apos;&lt;/span&gt; &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;db-移行&quot;&gt;DB 移行&lt;/h2&gt; &lt;p&gt;mdb にバックアップしておいたデータベースを取り込んで、ファイルのオーナーなどを修正します。&lt;/p&gt; &lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;slapadd &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 1 &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; ~/slapcat.1.2025-12-31.ldif &lt;span class=&quot;gp&quot;&gt;_#&lt;/span&gt;&lt;span class=&quot;c&quot;&gt;################### 100.00% eta none elapsed none fast!&lt;/span&gt; &lt;span class=&quot;go&quot;&gt;Closing DB... &lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;slapadd &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 2 &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; ~/slapcat.2.2025-12-31.ldif &lt;span class=&quot;gp&quot;&gt;_#&lt;/span&gt;&lt;span class=&quot;c&quot;&gt;################### 100.00% eta none elapsed none fast!&lt;/span&gt; &lt;span class=&quot;go&quot;&gt;Closing DB... &lt;/span&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo chown&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; openldap:openldap /var/lib/ldap &lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;作業対象サーバーの入れ替え&quot;&gt;作業対象サーバーの入れ替え&lt;/h2&gt; &lt;p&gt;同時に起動すると syncrepl で問題が起きそうなので、 残っていた1台を &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl stop slapd.service&lt;/code&gt; で止めて、 一瞬 LDAP サーバーがなくなった状態になった後、 移行した方を &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl start slapd.service&lt;/code&gt; で起動しました。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getent passwd&lt;/code&gt; などで問題がないことを確認して、次のサーバーも同様に作業しました。&lt;/p&gt; &lt;h2 id=&quot;もう1台も移行&quot;&gt;もう1台も移行&lt;/h2&gt; &lt;p&gt;もう1台の方も &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl start slapd.service&lt;/code&gt; で起動して、 syncrepl などの状態を確認できたら移行完了です。&lt;/p&gt; &lt;h2 id=&quot;最後に&quot;&gt;最後に&lt;/h2&gt; &lt;p&gt;以前に移行作業しようとしたときは、全然具体的な情報がなくて諦めていましたが、 さすがに Debian で hdb 対応が消えた bookworm が oldstable になっていたり、 Ubuntu でも hdb が消えた jammy (22.04) の次の LTS の noble (24.04) が出ていたりするので、 具体的な移行方法もみつけられました。&lt;/p&gt; &lt;p&gt;focal も bullseye もまだ完全な EOL ではないものの、 いろんなツールなどの対応が終わってきているので、 slapd の hdb が原因でまだ上げられていない人がいれば参考にしてみてください。&lt;/p&gt; </description> <pubDate>Wed, 31 Dec 2025 09:36:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2025-12-31-openldap-hdb-to-mdb.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2025-12-31-openldap-hdb-to-mdb.html</guid> <category>debian</category> <category>ubuntu</category> <category>linux</category> <category>blog</category> </item> <item> <title>Dokkuを動かしているUbuntuを20.04から22.04に更新した</title> <description>&lt;p&gt;年末で時間がとれるようになったので、 Dokku を動かしている VPS のサーバーを Ubuntu 20.04 (focal) から Ubuntu 22.04 (jammy) に更新しました。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;データベースなどのバックアップ&quot;&gt;データベースなどのバックアップ&lt;/h2&gt; &lt;p&gt;まず、いつもの &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dokku postgres:export&lt;/code&gt; でデータベースのバックアップをとったり、その他のバックアップをとりました。&lt;/p&gt; &lt;h2 id=&quot;do-release-upgrade&quot;&gt;do-release-upgrade&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://wiki.ubuntu.com/JammyJellyfish/ReleaseNotes/Ja&quot;&gt;https://wiki.ubuntu.com/JammyJellyfish/ReleaseNotes/Ja&lt;/a&gt; を参照して大きな影響がなさそうなのを確認した後、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo do-release-upgrade&lt;/code&gt; で更新しました。&lt;/p&gt; &lt;h2 id=&quot;etc-のファイル確認&quot;&gt;etc のファイル確認&lt;/h2&gt; &lt;p&gt;前回の do-release-upgrade のときから残っているファイルが混ざっているかもしれませんが、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc&lt;/code&gt; で &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git clean -ndx&lt;/code&gt; を実行して、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;etckeeper&lt;/code&gt; で無視されている &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.dpkg-*&lt;/code&gt; や &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.ucf-*&lt;/code&gt; などを確認しました。&lt;/p&gt; &lt;h2 id=&quot;sshd_config&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd_config&lt;/code&gt;&lt;/h2&gt; &lt;p&gt;追加変更していた設定は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/ssh/sshd_config.d&lt;/code&gt; に分割しまし。&lt;/p&gt; &lt;h2 id=&quot;50unattended-upgrades&quot;&gt;50unattended-upgrades&lt;/h2&gt; &lt;p&gt;3項目だけ変更して &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;50unattended-upgrades.ucf-dist&lt;/code&gt; をマージしました。&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Unattended-Upgrade::Mail &quot;root&quot;; Unattended-Upgrade::Remove-Unused-Dependencies &quot;true&quot;; Unattended-Upgrade::Automatic-Reboot &quot;true&quot;; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;zabbix-agent2&quot;&gt;zabbix-agent2&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://www.zabbix.com/download?zabbix=7.4&amp;amp;os_distribution=ubuntu&amp;amp;os_version=22.04&amp;amp;components=agent_2&amp;amp;db=&amp;amp;ws=&quot;&gt;https://www.zabbix.com/download?zabbix=7.4&amp;amp;os_distribution=ubuntu&amp;amp;os_version=22.04&amp;amp;components=agent_2&amp;amp;db=&amp;amp;ws=&lt;/a&gt; から &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zabbix-release_latest_7.4+ubuntu22.04_all.deb&lt;/code&gt; を入れて、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zabbix-agent2&lt;/code&gt; を更新しました。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt update&lt;/code&gt; で&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;N: Skipping acquire of configured file &apos;main/binary-i386/Packages&apos; as repository &apos;https://repo.zabbix.com/zabbix/7.4/stable/ubuntu jammy InRelease&apos; doesn&apos;t support architecture &apos;i386&apos; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;というメッセージが出るので、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apt/sources.list.d/zabbix.list&lt;/code&gt; の &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;deb&lt;/code&gt; の行に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[arch=amd64]&lt;/code&gt; を追加しました。&lt;/p&gt; &lt;h2 id=&quot;dokku-と-docker&quot;&gt;dokku と docker&lt;/h2&gt; &lt;p&gt;Dokku は &lt;a href=&quot;https://dokku.com/docs/getting-started/installation/&quot;&gt;https://dokku.com/docs/getting-started/installation/&lt;/a&gt; から &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bootstrap.sh&lt;/code&gt; をダウンロードして参照して apt の設定を更新しました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget &lt;span class=&quot;nt&quot;&gt;-qO-&lt;/span&gt; https://packagecloud.io/dokku/dokku/gpgkey | &lt;span class=&quot;nb&quot;&gt;sudo tee&lt;/span&gt; /etc/apt/trusted.gpg.d/dokku.asc &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;で gpg 鍵を更新して `/etc/apt/sources.list.d/dokku.list は&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;deb https://packagecloud.io/dokku/dokku/ubuntu jammy main &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;にしました。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apt/sources.list.d/dokku.list.*&lt;/code&gt; や &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apt/sources.list.d/download_docker_com_linux_ubuntu.list*&lt;/code&gt; は削除しました。&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;https://get.docker.com/&quot;&gt;https://get.docker.com/&lt;/a&gt; をダウンロードして参照して apt の設定を更新しました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;curl &lt;span class=&quot;nt&quot;&gt;-fsSL&lt;/span&gt; https://download.docker.com/linux/ubuntu/gpg &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; /etc/apt/keyrings/docker.asc &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;deb [arch=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;dpkg &lt;span class=&quot;nt&quot;&gt;--print-architecture&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu jammy stable&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sudo tee&lt;/span&gt; /etc/apt/sources.list.d/docker.list &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt full-upgrade -V&lt;/code&gt; で更新対象を事前確認しました。&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;The following packages will be upgraded: containerd.io (1.7.27-1 =&amp;gt; 2.2.1-1~ubuntu.22.04~jammy) docker-buildx-plugin (0.23.0-1~ubuntu.20.04~focal =&amp;gt; 0.30.1-1~ubuntu.22.04~jammy) docker-ce (5:28.1.1-1~ubuntu.20.04~focal =&amp;gt; 5:29.1.3-1~ubuntu.22.04~jammy) docker-ce-cli (5:28.1.1-1~ubuntu.20.04~focal =&amp;gt; 5:29.1.3-1~ubuntu.22.04~jammy) docker-ce-rootless-extras (5:28.1.1-1~ubuntu.20.04~focal =&amp;gt; 5:29.1.3-1~ubuntu.22.04~jammy) docker-compose-plugin (2.35.1-1~ubuntu.20.04~focal =&amp;gt; 5.0.0-1~ubuntu.22.04~jammy) docker-container-healthchecker (0.14.0 =&amp;gt; 0.14.1) docker-image-labeler (0.8.1 =&amp;gt; 0.9.0) dokku (0.35.20 =&amp;gt; 0.37.3) dokku-event-listener (0.17.2 =&amp;gt; 0.18.0) dokku-update (0.9.6 =&amp;gt; 0.9.7) gliderlabs-sigil (0.11.4 =&amp;gt; 0.11.5) herokuish (0.11.3 =&amp;gt; 0.11.8) lambda-builder (0.9.1 =&amp;gt; 0.9.2) netrc (0.10.2 =&amp;gt; 0.10.3) plugn (0.16.0 =&amp;gt; 0.16.1) procfile-util (0.20.3 =&amp;gt; 0.20.4) sshcommand (0.20.0 =&amp;gt; 0.20.1) 18 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;a href=&quot;https://dokku.com/docs/appendices/0.36.0-migration-guide/&quot;&gt;https://dokku.com/docs/appendices/0.36.0-migration-guide/&lt;/a&gt; と &lt;a href=&quot;https://dokku.com/docs/appendices/0.37.0-migration-guide/&quot;&gt;https://dokku.com/docs/appendices/0.37.0-migration-guide/&lt;/a&gt; を確認して、&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;dokku-update run &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;で更新しました。&lt;/p&gt; &lt;p&gt;0.36.0 で Ubuntu 20.04 がサポート対象外になっていたようです。&lt;/p&gt; &lt;h2 id=&quot;その他のファイル&quot;&gt;その他のファイル&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ca-certificates.conf.dpkg-old&lt;/code&gt; や &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cron.daily/bsdmainutils.dpkg-remove&lt;/code&gt; は単純に削除しました。 他のファイルも変更をマージして削除しました。&lt;/p&gt; &lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt; &lt;p&gt;Dokku のドキュメントには OS の更新についての記述がないので、大丈夫なのかわからず、なかなか上げられずにいましたが、 Dokku 専用環境だからか OS 更新でひっかかるようなものはなくて、すんなり更新できました。&lt;/p&gt; &lt;p&gt;しばらく様子をみて、問題なさそうなら早めに 24.04 まで上げてしまうと良さそうだと思いました。&lt;/p&gt; </description> <pubDate>Sat, 27 Dec 2025 05:36:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2025-12-27-ubuntu-f2j-with-dokku.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2025-12-27-ubuntu-f2j-with-dokku.html</guid> <category>ubuntu</category> <category>linux</category> <category>docker</category> <category>dokku</category> <category>blog</category> </item> <item> <title>systemdのtimerの時間が重なって想定外の挙動になっていた</title> <description>&lt;p&gt;概要としては systemd timer でデータベースのバックアップをしていて、 ディレクトリの中身のサイズの単調増加でバックアップ成功を確認していたら、 古いファイルの削除は systemd-tmpfiles に任せていたのとタイミングが重なって、 サイズの単調増加チェックが失敗するようになった、 という話です。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;バックアップ設定&quot;&gt;バックアップ設定&lt;/h2&gt; &lt;p&gt;バックアップ先は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/srv/postgres-export&lt;/code&gt; というディレクトリにしています。&lt;/p&gt; &lt;p&gt;バックアップ用スクリプトとして &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/srv/postgres-export.sh&lt;/code&gt; に以下の内容を用意しています。 最後の &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test&lt;/code&gt; でダンプが成功して容量が単調増加しているのを確認しています。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash -x&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-euo&lt;/span&gt; pipefail &lt;span class=&quot;nb&quot;&gt;umask &lt;/span&gt;027 &lt;span class=&quot;nv&quot;&gt;DUMP_DIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/srv/postgres-export&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;OLD_TOTAL_SIZE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;du&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DUMP_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-z&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;dokku postgres:list&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$0&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;: No databases&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exit &lt;/span&gt;0 &lt;span class=&quot;k&quot;&gt;fi for &lt;/span&gt;db &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;dokku postgres:list | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;NR&amp;gt;=2{print $1}&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;DUMP_FILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DUMP_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +&lt;span class=&quot;s1&quot;&gt;&apos;%Y%m%d%H%M%S&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;.dump dokku postgres:export &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;db&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &amp;lt;/dev/null &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DUMP_FILE&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DUMP_FILE&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;NEW_TOTAL_SIZE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;du&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-b&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$DUMP_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$OLD_TOTAL_SIZE&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-lt&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NEW_TOTAL_SIZE&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/srv/postgres-export.sh&lt;/code&gt; を dokku ユーザー権限で定期実行しています。 バックアップ先は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ExecStartPre&lt;/code&gt; に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt; をつけて root 権限で &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;install&lt;/code&gt; コマンドを実行してパーミッションなどを含めて期待している状態にしています。 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OnFailure&lt;/code&gt; で1人Slackに通知して失敗に気付けるようにしていたので、今回の失敗に気がつきました。&lt;/p&gt; &lt;div class=&quot;language-ini highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# /etc/systemd/system/postgres-export.service &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;[Unit]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Backup dokku postgres&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;After&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;docker.service&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Requires&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;docker.service&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;OnFailure&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;notify-to-slack@%n.service&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[Service]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;oneshot&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;ExecStartPre&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;+/usr/bin/install -o dokku -g dokku -m 0750 -d /srv/postgres-export&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/srv/postgres-export.sh&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;dokku&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;systemd timer で3時と15時に実行しています。&lt;/p&gt; &lt;div class=&quot;language-ini highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# /etc/systemd/system/postgres-export.timer &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;[Unit]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Backup dokku postgres&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[Timer]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;OnCalendar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;*-*-* 3,15:00&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Persistent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[Install]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;WantedBy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;timers.target&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;通知設定&quot;&gt;通知設定&lt;/h2&gt; &lt;p&gt;本筋とは関係ないですが、通知の設定もついでに公開しておきます。&lt;/p&gt; &lt;p&gt;こんな感じの &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/local/bin/notify-to-slack.rb&lt;/code&gt; で通知しています。&lt;/p&gt; &lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/ruby&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# frozen_string_literal: true&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;json&apos;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;uri&apos;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;open3&apos;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;net/http&apos;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;key?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;SLACK_WEBHOOK_URL&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;abort&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;Set SLACK_WEBHOOK_URL into /etc/systemd/system/notify-to-slack.env&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uri&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;URI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;SLACK_WEBHOOK_URL&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ARGV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;shift&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;status&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Open3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;capture2e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;sx&quot;&gt;%W&quot;systemctl status --full &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unit&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sx&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;payload&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;text: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;SLACK_USERNAME&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;key?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;SLACK_USERNAME&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:icon_emoji&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;SLACK_ICON_EMOJI&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ENV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;key?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;SLACK_ICON_EMOJI&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;content-type&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;application/json&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Net&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;HTTP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;use_ssl&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_debug_output&lt;/span&gt; &lt;span class=&quot;vg&quot;&gt;$stderr&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;vg&quot;&gt;$DEBUG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;payload&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;service unit はこんな感じです。&lt;/p&gt; &lt;div class=&quot;language-ini highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# /etc/systemd/system/notify-to-slack@.service &lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;[Unit]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Notify systemd %i unit status to slack&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[Service]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;oneshot&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/usr/local/bin/notify-to-slack.rb %i&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;nobody&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;systemd-journal&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# SLACK_WEBHOOK_URL=&quot;https://hooks.slack.com/services/...&quot; &lt;/span&gt;&lt;span class=&quot;py&quot;&gt;EnvironmentFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/etc/systemd/system/notify-to-slack.env&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;EnvironmentFile の内容は以下のような感じです。 置く場所は特に決まった場所がなさそうなので、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;service&lt;/code&gt; ファイルと同じ場所に owner=root group=systemd-journal mode=0440 で置いています。&lt;/p&gt; &lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;SLACK_USERNAME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hostname&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;SLACK_ICON_EMOJI&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;:red_circle:&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;SLACK_WEBHOOK_URL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https://hooks.slack.com/services/... &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;systemd-tmpfiles&quot;&gt;systemd-tmpfiles&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/tmpfiles.d/postgres-export.conf&lt;/code&gt; に&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;d /srv/postgres-export - - - 7d &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;という設定をして1週間分残すようにしています。 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ExecStartPre&lt;/code&gt; の方でパーミッションなどは設定しているので、こちらでは &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt; にしています。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemctl list-timers&lt;/code&gt; で確認すると、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemd-tmpfiles-clean.timer&lt;/code&gt; が毎日 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;15:00:14&lt;/code&gt; で動いていました。&lt;/p&gt; &lt;p&gt;設定は以下の通りでした。&lt;/p&gt; &lt;div class=&quot;language-ini highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# /lib/systemd/system/systemd-tmpfiles-clean.timer # SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. &lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[Unit]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Daily Cleanup of Temporary Directories&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Documentation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;man:tmpfiles.d(5) man:systemd-tmpfiles(8)&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[Timer]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;OnBootSec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;15min&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;OnUnitActiveSec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;1d&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class=&quot;language-ini highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# /lib/systemd/system/systemd-tmpfiles-clean.service # SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. &lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[Unit]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Cleanup of Temporary Directories&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Documentation&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;man:tmpfiles.d(5) man:systemd-tmpfiles(8)&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;DefaultDependencies&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;no&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Conflicts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;shutdown.target&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;After&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;local-fs.target time-set.target&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Before&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;shutdown.target&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;[Service]&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;oneshot&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;systemd-tmpfiles --clean&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;SuccessExitStatus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;DATAERR&lt;/span&gt; &lt;span class=&quot;py&quot;&gt;IOSchedulingClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;idle&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;原因&quot;&gt;原因&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;postgres-export.timer&lt;/code&gt; が 15:00:00 に動いて、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemd-tmpfiles-clean.timer&lt;/code&gt; が 15:00:14 に動いているため、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OLD_TOTAL_SIZE&lt;/code&gt; の取得後、バックアップ中に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemd-tmpfiles --clean&lt;/code&gt; が動いてしまって、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NEW_TOTAL_SIZE&lt;/code&gt; の取得のタイミングではサイズが減っているのが原因でした。&lt;/p&gt; &lt;p&gt;Slack 通知は 15 時だけきていて 3 時にはきていなかったので、 その理由もこれで説明できます。&lt;/p&gt; &lt;h2 id=&quot;対応案&quot;&gt;対応案&lt;/h2&gt; &lt;p&gt;バックアップのサイズ制限が &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemd-tmpfiles&lt;/code&gt; に依存しているので、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;postgres-export.timer&lt;/code&gt; も &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OnBootSec&lt;/code&gt; と &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OnUnitActiveSec&lt;/code&gt; に変更して実行タイミングをずらすのが一番確実そうです。&lt;/p&gt; &lt;p&gt;個人サーバーで厳密な処理でもないので、 設定はこのままで、 次の再起動でタイミングがずれて解決でも、 大きな問題は良さそうです。&lt;/p&gt; &lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt; &lt;p&gt;systemd timer のタイミングの組み合わせでたまたま些細な問題が起きたという例を紹介しました。&lt;/p&gt; &lt;p&gt;組み合わせが重要な timer が複数あるときは実行時刻や実行間隔の設定で問題が起きないように注意した方が良さそうです。&lt;/p&gt; </description> <pubDate>Sun, 30 Nov 2025 14:10:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2025-11-30-systemd-timer-collision.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2025-11-30-systemd-timer-collision.html</guid> <category>linux</category> <category>systemd</category> <category>blog</category> </item> <item> <title>kube-prometheus-stackでinit-chown-dataがエラーになっていたのを対処した</title> <description>&lt;p&gt;kube-prometheus-stack helm chart でインストールしている grafana で init-chown-data がエラーになっていたので、 対処する設定を追加しました。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;確認バージョン&quot;&gt;確認バージョン&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;&lt;a href=&quot;https://prometheus-community.github.io/helm-charts&quot;&gt;https://prometheus-community.github.io/helm-charts&lt;/a&gt; の kube-prometheus-stack 79.1.1&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;エラー内容&quot;&gt;エラー内容&lt;/h2&gt; &lt;p&gt;正常起動する前のログなので、k9s では確認できなかったのですが、 後で loki で確認できたログによると &lt;a href=&quot;https://github.com/grafana/helm-charts/pull/3698&quot;&gt;https://github.com/grafana/helm-charts/pull/3698&lt;/a&gt; と同じで、&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;chown: /var/lib/grafana/csv: Permission denied chown: /var/lib/grafana/png: Permission denied chown: /var/lib/grafana/pdf: Permission denied &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;というエラーが出ていました。&lt;/p&gt; &lt;h2 id=&quot;仮対応&quot;&gt;仮対応&lt;/h2&gt; &lt;p&gt;最初は init-chown-data が失敗しているという情報しかなく、 local-path-provisioner を使っていたので、 PV の場所を確認して、 何かできることはないかと思って、とりあえず空ディレクトリの削除を&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo rmdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; /opt/local-path-provisioner/pvc-&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;_monitoring_kube-prometheus-stack-grafana/&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;csv,pdf,png&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;で試したら起動するようになったので、その対応を繰り返していました。&lt;/p&gt; &lt;h2 id=&quot;設定&quot;&gt;設定&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/grafana/helm-charts/pull/3698&quot;&gt;https://github.com/grafana/helm-charts/pull/3698&lt;/a&gt; に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;readOnlyRootFilesystem: true&lt;/code&gt; と &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;capabilities&lt;/code&gt; に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DAC_READ_SEARCH&lt;/code&gt; を追加する、 という pull request があったので、その設定を追加しました。&lt;/p&gt; &lt;p&gt;grafana は kube-prometheus-stack の helm subchart なのでの設定方法に悩みましたが、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;initChownData.securityContext&lt;/code&gt; が &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grafana.initChownData.securityContext&lt;/code&gt; になるようにするだけでした。&lt;/p&gt; &lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## Using default values from https://github.com/grafana/helm-charts/blob/main/charts/grafana/values.yaml&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;##&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;grafana&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Fix init-chown-data error&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# pick from https://github.com/grafana/helm-charts/pull/3698&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;initChownData&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;securityContext&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;readOnlyRootFilesystem&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;capabilities&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;CHOWN&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;DAC_READ_SEARCH&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ALL&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;別の方法&quot;&gt;別の方法&lt;/h2&gt; &lt;p&gt;pull request がマージされない原因のコメントのように細かいセキュリティを気にするなら、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;initChownData.enabled&lt;/code&gt; を &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; にして &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;init-chown-data&lt;/code&gt; 自体を実行しない、 という方法もあるようです。&lt;/p&gt; &lt;h2 id=&quot;原因&quot;&gt;原因&lt;/h2&gt; &lt;p&gt;問題のディレクトリが &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;drwx------&lt;/code&gt; で owner 472 なので、 root ユーザーには &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chown -R&lt;/code&gt; をするときにパーミッションによるディレクトリの中のファイル一覧を読む許可がなくて、 通常の root 権限はパーミッションを無視して読めるのも &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DAC_READ_SEARCH&lt;/code&gt; という capabilities を drop していると無理、 というのが原因だったようです。&lt;/p&gt; &lt;p&gt;capabilities の &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DAC_READ_SEARCH&lt;/code&gt; を add してしまうと root 権限でなくてもパーミッションを無視してディレクトリの中のファイル一覧を読めてしまう、 というのが pull request でセキュリティを気にする人がコメントしている内容だと思うので、 root 権限にだけ &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DAC_READ_SEARCH&lt;/code&gt; を残せれば良さそうなのですが、できるのかどうかわかりませんでした。&lt;/p&gt; &lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kube-prometheus-stack&lt;/code&gt; helm chart の value.yaml に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grafana.initChownData.securityContext&lt;/code&gt; で許可を追加するか、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grafana.initChownData.enabled&lt;/code&gt; を &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;false&lt;/code&gt; にすればエラーは解消されそうです。&lt;/p&gt; &lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## Using default values from https://github.com/grafana/helm-charts/blob/main/charts/grafana/values.yaml&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;##&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;grafana&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Fix init-chown-data error&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# pick from https://github.com/grafana/helm-charts/pull/3698&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;initChownData&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;securityContext&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;readOnlyRootFilesystem&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;capabilities&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;CHOWN&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;DAC_READ_SEARCH&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ALL&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description> <pubDate>Sat, 29 Nov 2025 04:00:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2025-11-29-kube-prometheus-stack-chown-error.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2025-11-29-kube-prometheus-stack-chown-error.html</guid> <category>kubernetes</category> <category>grafana</category> <category>blog</category> </item> <item> <title>limaでNFSサーバーを用意した</title> <description>&lt;p&gt;k8s からの NFS のテスト用に NFS サーバーがほしくなったので、 lima で試してみました。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;動作確認バージョン&quot;&gt;動作確認バージョン&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;macOS Sequoia 15.7.1&lt;/li&gt; &lt;li&gt;limactl version 1.2.1&lt;/li&gt; &lt;li&gt;Ubuntu 24.04.2 LTS&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;最初の動作確認&quot;&gt;最初の動作確認&lt;/h2&gt; &lt;p&gt;最初は以下のように同じネットワークに接続して動作確認しました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;limactl start template://ubuntu-lts &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; nfs-server &lt;span class=&quot;nt&quot;&gt;--containerd&lt;/span&gt; none &lt;span class=&quot;nt&quot;&gt;--vm-type&lt;/span&gt; vz &lt;span class=&quot;nt&quot;&gt;--network&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;lima:user-v2 &lt;span class=&quot;nt&quot;&gt;--tty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false &lt;/span&gt;limactl start template://ubuntu-lts &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; nfs-client &lt;span class=&quot;nt&quot;&gt;--containerd&lt;/span&gt; none &lt;span class=&quot;nt&quot;&gt;--vm-type&lt;/span&gt; vz &lt;span class=&quot;nt&quot;&gt;--network&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;lima:user-v2 &lt;span class=&quot;nt&quot;&gt;--tty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;nfs-サーバー側設定&quot;&gt;NFS サーバー側設定&lt;/h2&gt; &lt;p&gt;最初は以下の設定で試しました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt update &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;nfs-kernel-server &lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; /exports sudoedit /etc/exports &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/exports&lt;/code&gt; には以下の設定をしました。&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/exports *(rw,fsid=0,sync,no_subtree_check,no_root_squash) &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;nfs-クライアント側&quot;&gt;NFS クライアント側&lt;/h2&gt; &lt;p&gt;最初は以下のコマンドで試しました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt update &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;nfs-common &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; /tmp/nfs &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nfs &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2049,rw,nfsvers&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;4,soft lima-nfs-server.internal:/ /tmp/nfs &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;実際には soft 以外のオプションはデフォルトなので不要でした。 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-t nfs&lt;/code&gt; も明示する必要はありませんでした。&lt;/p&gt; &lt;h2 id=&quot;nfsv4-のみに変更&quot;&gt;NFSv4 のみに変更&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://it-notebox.com/archives/181&quot;&gt;Ubuntu 22.04 に NFSv4 サーバ構築（NFSv3 無効化）&lt;/a&gt; を参考にして以下のように設定変更しました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl mask &lt;span class=&quot;nt&quot;&gt;--now&lt;/span&gt; rpc-statd.service rpcbind.socket rpcbind.service sudoedit /etc/nfs.conf &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ufw allow 22/tcp &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ufw allow 2049/tcp &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ufw &lt;span class=&quot;nb&quot;&gt;enable&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/nfs.conf&lt;/code&gt; は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vers3=y&lt;/code&gt; がコメントアウトされていた &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[nfsd]&lt;/code&gt; セクションに以下の設定を追加しました。 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vers2=&lt;/code&gt; の行はありませんでしたが、一緒に追加しないとエラーになるようでした。&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vers2=n vers3=n &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;この状態でもマウントできたので、ポートは 2049/tcp しか使われていないのが確認できました。&lt;/p&gt; &lt;h2 id=&quot;外部からの接続確認&quot;&gt;外部からの接続確認&lt;/h2&gt; &lt;p&gt;minikube などの他の仮想マシンから接続するには、ホスト側の IP アドレスで接続できる必要があります。&lt;/p&gt; &lt;p&gt;確認用に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--network=lima:user-v2&lt;/code&gt; なしで VM を作りなおしました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;limactl start template://ubuntu-lts &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; nfs-client &lt;span class=&quot;nt&quot;&gt;--containerd&lt;/span&gt; none &lt;span class=&quot;nt&quot;&gt;--vm-type&lt;/span&gt; vz limactl start template://ubuntu-lts &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; nfs-server &lt;span class=&quot;nt&quot;&gt;--containerd&lt;/span&gt; none &lt;span class=&quot;nt&quot;&gt;--vm-type&lt;/span&gt; vz &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;port-forwarding-の設定変更&quot;&gt;port forwarding の設定変更&lt;/h2&gt; &lt;p&gt;ホスト側で &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nc -v localhost 2049&lt;/code&gt; はつながるのに、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nc -v 192.168.253.154 2049&lt;/code&gt; でつながりませんでした。 (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.253.154&lt;/code&gt; は macOS の IP アドレス)&lt;/p&gt; &lt;p&gt;server 側の lima.yaml で&lt;/p&gt; &lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;portForwards&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;guestPort&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2049&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hostIP&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;0.0.0.0&quot;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;として localhost 限定じゃなくす必要がありました。&lt;/p&gt; &lt;h2 id=&quot;nat-経由の問題対応&quot;&gt;NAT 経由の問題対応&lt;/h2&gt; &lt;p&gt;client 側から TCP 接続がつながるようになっても、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Operation not permitted&lt;/code&gt; でつながりませんでした。&lt;/p&gt; &lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; nfs &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2049,rw,nfsvers&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;4,soft 192.168.253.154:/ /tmp/nfs &lt;span class=&quot;go&quot;&gt;mount.nfs: Operation not permitted for 192.168.253.154:/ on /tmp/nfs &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;エラーメッセージで原因がわかりにくいですが、 &lt;a href=&quot;https://tkjzblog.com/2021/03/20/virtualbox%E3%81%AEnat%E7%92%B0%E5%A2%83%E3%81%A7nfs%E3%82%AF%E3%83%A9%E3%82%A4%E3%82%A2%E3%83%B3%E3%83%88%E3%81%A8%E3%81%97%E3%81%A6%E3%83%9E%E3%82%A6%E3%83%B3%E3%83%88%E3%81%99%E3%82%8B/&quot;&gt;VirtualBoxのNAT環境でNFSクライアントとしてマウントする&lt;/a&gt; に書いてあるように、 NAT 経由だと /etc/exports に&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/exports *(rw,fsid=0,sync,no_subtree_check,no_root_squash,insecure) &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;という感じで insecure も必要でした。&lt;/p&gt; &lt;p&gt;分離されたネットワークにいるマシンなので insecure にしてしまいましたが、 共有のネットワークにいるマシンなら他の方法の方が良いかもしれません。&lt;/p&gt; &lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt; &lt;p&gt;いくつかひっかかる点がありましたが、簡単な NFS サーバーを用意して、 クライアントからのマウントまで試せました。&lt;/p&gt; &lt;p&gt;最後に設定例をまとめておきます。&lt;/p&gt; &lt;h3 id=&quot;サーバー側&quot;&gt;サーバー側&lt;/h3&gt; &lt;p&gt;lima.yaml に追加:&lt;/p&gt; &lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;portForwards&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;guestPort&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2049&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;hostIP&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;0.0.0.0&quot;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;設定コマンド:&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt update &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;nfs-kernel-server &lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; /exports sudoedit /etc/exports &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl mask &lt;span class=&quot;nt&quot;&gt;--now&lt;/span&gt; rpc-statd.service rpcbind.socket rpcbind.service sudoedit /etc/nfs.conf &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ufw allow 22/tcp &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ufw allow 2049/tcp &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;ufw &lt;span class=&quot;nb&quot;&gt;enable&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/exports&lt;/code&gt; に追加:&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/exports *(rw,fsid=0,sync,no_subtree_check,no_root_squash,insecure) &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/nfs.conf&lt;/code&gt; の &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[nfsd]&lt;/code&gt; セクションに設定:&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vers2=n vers3=n &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h3 id=&quot;クライアント側&quot;&gt;クライアント側&lt;/h3&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt update &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;nfs-common &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; /tmp/nfs &lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; soft &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;NFS_SERVER&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;:/ /tmp/nfs &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; </description> <pubDate>Wed, 29 Oct 2025 07:30:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2025-10-29-nfs-server-in-lima.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2025-10-29-nfs-server-in-lima.html</guid> <category>osx</category> <category>lima</category> <category>linux</category> <category>blog</category> </item> <item> <title>ciliumのGateway APIをminikubeで試した</title> <description>&lt;p&gt;cilium の Gateway API Support を有効にして Gateway や HTTPRoute や CiliumNetworkPolicy の動作を確認したかったので、 minikube で試せる環境を作成しました。 (CiliumNetworkPolicy は この記事の対象外です。) &lt;!--more--&gt;&lt;/p&gt; &lt;h2 id=&quot;動作確認環境&quot;&gt;動作確認環境&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;macOS Sequoia 15.7.1&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;colima&lt;/code&gt; 0.9.1 で動かしている docker 環境&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;minikube&lt;/code&gt; v1.37.0&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vfkit&lt;/code&gt; 0.6.1&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kubectl&lt;/code&gt; v1.34.1&lt;/li&gt; &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cilium-cli&lt;/code&gt; v0.18.7&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;8080-番ポートで動作確認&quot;&gt;8080 番ポートで動作確認&lt;/h2&gt; &lt;p&gt;privileged port は別途設定追加が必要なので、 最初に 8080 番ポートで動作確認しました。&lt;/p&gt; &lt;p&gt;ホスト側の macOS からノードの IP アドレスに直接接続できるようにするため、 &lt;a href=&quot;https://minikube.sigs.k8s.io/docs/drivers/vfkit/&quot;&gt;vfkit&lt;/a&gt; を使ったので、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;brew install vfkit&lt;/code&gt; でインストールしておく必要があります。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;minikube&lt;/code&gt; は &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--cni cilium&lt;/code&gt; に対応していましたが、 Gateway API CRDs を cilium より先に入れる必要があったので &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--cni false&lt;/code&gt; にしました。&lt;/p&gt; &lt;p&gt;gateway-api の最新は 1.4.0 になっていますが、 cilium との組み合わせが確認されている 1.3.0 にしました。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatewayAPI.hostNetwork.enabled=true&lt;/code&gt; で &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NodePort&lt;/code&gt; などを使わずに直接見えるようにしました。 これと &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vfkit&lt;/code&gt; の組み合わせでホスト側のブラウザーなどからも直接見えるようになります。&lt;/p&gt; &lt;p&gt;80番ポートは &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;default/cilium-gateway-cilium-gateway/listener: cannot bind &apos;0.0.0.0:80&apos;: Permission denied&lt;/code&gt; (cilium の pod のログで確認) で使えないので 8080 番ポートにしています。&lt;/p&gt; &lt;p&gt;動作確認のテスト用アプリケーションは Claude が出してくれたものを使いました。 テスト用なので Gateway なども default namespace のままになっています。&lt;/p&gt; &lt;p&gt;起動待ちをしていないため、最後の curl で表示されなかったので別途実行して確認しました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-euxo&lt;/span&gt; pipefail &lt;span class=&quot;c&quot;&gt;# 最終的な構成&lt;/span&gt; minikube start &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--driver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;vfkit &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--network-plugin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;cni &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--cni&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--extra-config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;kubeadm.skip-phases&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;addon/kube-proxy kubectl apply &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.3.0/standard-install.yaml cilium &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;kubeProxyReplacement&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;k8sServiceHost&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;minikube ip&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;k8sServicePort&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;8443 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; gatewayAPI.enabled&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; gatewayAPI.hostNetwork.enabled&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; ingressController.enabled&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false &lt;/span&gt;cilium status &lt;span class=&quot;nt&quot;&gt;--wait&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Gateway (8080ポート)&lt;/span&gt; kubectl apply &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; - &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: cilium-gateway spec: gatewayClassName: cilium listeners: - name: http protocol: HTTP port: 8080 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# テスト用アプリケーション&lt;/span&gt; kubectl create deployment &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ealen/echo-server:latest kubectl expose deployment &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;80 &lt;span class=&quot;c&quot;&gt;# HTTPRoute&lt;/span&gt; kubectl apply &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; - &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: echo-route spec: parentRefs: - name: cilium-gateway rules: - matches: - path: type: PathPrefix value: / backendRefs: - name: echo port: 80 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# テスト&lt;/span&gt; curl http://&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;minikube ip&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;:8080 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;80番ポートで確認&quot;&gt;80番ポートで確認&lt;/h2&gt; &lt;p&gt;80番ポートを使えるようにするには &lt;a href=&quot;https://docs.cilium.io/en/latest/network/servicemesh/gateway-api/gateway-api/&quot;&gt;https://docs.cilium.io/en/latest/network/servicemesh/gateway-api/gateway-api/&lt;/a&gt; の説明にあるように &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;envoy.securityContext.capabilities&lt;/code&gt; の設定も必要でした。&lt;/p&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values.yaml&lt;/code&gt; に書くなら以下のようになります。&lt;/p&gt; &lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;envoy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;securityContext&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;capabilities&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;keepCapNetBindService&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;envoy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NET_ADMIN&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SYS_ADMIN&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Add NET_BIND_SERVICE to the list (keep the others!)&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NET_BIND_SERVICE&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;keep the others! 用の値は cilium の chart の &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values.yaml&lt;/code&gt; の以下のところから持ってきています。&lt;/p&gt; &lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;na&quot;&gt;capabilities&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# -- Capabilities for the `cilium-envoy` container.&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Even though granted to the container, the cilium-envoy-starter wrapper drops&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# all capabilities after forking the actual Envoy process.&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# `NET_BIND_SERVICE` is the only capability that can be passed to the Envoy process by&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# setting `envoy.securityContext.capabilities.keepNetBindService=true` (in addition to granting the&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# capability to the container).&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Note: In case of embedded envoy, the capability must be granted to the cilium-agent container.&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;envoy&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Used since cilium proxy uses setting IPPROTO_IP/IP_TRANSPARENT&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;NET_ADMIN&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# We need it for now but might not need it for &amp;gt;= 5.11 specially&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# for the &apos;SYS_RESOURCE&apos;.&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# In &amp;gt;= 5.8 there&apos;s already BPF and PERMON capabilities&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;SYS_ADMIN&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Both PERFMON and BPF requires kernel 5.8, container runtime&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# cri-o &amp;gt;= v1.22.0 or containerd &amp;gt;= v1.5.0.&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# If available, SYS_ADMIN can be removed.&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#- PERFMON&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#- BPF&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# -- Keep capability `NET_BIND_SERVICE` for Envoy process.&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;keepCapNetBindService&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;最終的に動作確認用のコマンドは以下のようになりました。&lt;/p&gt; &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-euxo&lt;/span&gt; pipefail &lt;span class=&quot;c&quot;&gt;# 最終的な構成&lt;/span&gt; minikube start &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--driver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;vfkit &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--network-plugin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;cni &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--cni&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--extra-config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;kubeadm.skip-phases&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;addon/kube-proxy kubectl apply &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.3.0/standard-install.yaml cilium &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;kubeProxyReplacement&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;k8sServiceHost&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;minikube ip&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;k8sServicePort&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;8443 &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; gatewayAPI.enabled&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; gatewayAPI.hostNetwork.enabled&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; ingressController.enabled&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; envoy.securityContext.capabilities.keepCapNetBindService&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; envoy.securityContext.capabilities.envoy&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;{NET_ADMIN,SYS_ADMIN,NET_BIND_SERVICE}&apos;&lt;/span&gt; cilium status &lt;span class=&quot;nt&quot;&gt;--wait&lt;/span&gt; &lt;span class=&quot;c&quot;&gt;# Gateway (8080ポート)&lt;/span&gt; kubectl apply &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; - &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: name: cilium-gateway spec: gatewayClassName: cilium listeners: - name: http protocol: HTTP port: 80 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# テスト用アプリケーション&lt;/span&gt; kubectl create deployment &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ealen/echo-server:latest kubectl expose deployment &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;80 &lt;span class=&quot;c&quot;&gt;# HTTPRoute&lt;/span&gt; kubectl apply &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; - &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt; apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: echo-route spec: parentRefs: - name: cilium-gateway rules: - matches: - path: type: PathPrefix value: / backendRefs: - name: echo port: 80 &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;EOF &lt;/span&gt;&lt;span class=&quot;c&quot;&gt;# テスト&lt;/span&gt; curl &lt;span class=&quot;nt&quot;&gt;--head&lt;/span&gt; http://&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;minikube ip&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;最後に&quot;&gt;最後に&lt;/h2&gt; &lt;p&gt;いくつかはまりどころがありましたが、 やりたかったことができる環境を作成できました。&lt;/p&gt; &lt;p&gt;これで既存の環境を壊さずに CiliumNetworkPolicy の設定を試行錯誤できそうです。&lt;/p&gt; </description> <pubDate>Thu, 16 Oct 2025 07:45:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2025-10-16-cilium-with-gateway-api-on-minikube.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2025-10-16-cilium-with-gateway-api-on-minikube.html</guid> <category>kubernetes</category> <category>minikube</category> <category>cilium</category> <category>blog</category> </item> <item> <title>BrowserosaurusでクリップボードにURLをコピーする</title> <description>&lt;p&gt;今はデフォルトブラウザーとして &lt;a href=&quot;https://github.com/will-stone/browserosaurus&quot;&gt;Browserosaurus&lt;/a&gt; という実際にURLを開くアプリを選べるアプリを使っていて、 ブラウザーを開く変わりにクリップボードにURLを調べたことがあったので、 その方法のメモです。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;動作確認バージョン&quot;&gt;動作確認バージョン&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;Browserosaurus Version 20.11.0&lt;/li&gt; &lt;li&gt;Browserosaurus Version 20.12.0&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;この記事を書くときに &lt;a href=&quot;https://github.com/will-stone/browserosaurus&quot;&gt;https://github.com/will-stone/browserosaurus&lt;/a&gt; を確認したところ、&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;This repository was archived by the owner on Aug 3, 2025. It is now read-only.&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;になっていて、 &lt;a href=&quot;https://wstone.uk/blog/the-retirement-of-browserosaurus/&quot;&gt;The retirement of Browserosaurus — Will Stone&lt;/a&gt; というブログ記事へのリンクがあったので、 新しく使うなら、リンク先の記事の最後の方に書いてある別のアプリを候補にした方が良さそうです。&lt;/p&gt; &lt;h2 id=&quot;クリップボードへのコピー&quot;&gt;クリップボードへのコピー&lt;/h2&gt; &lt;p&gt;結論から先に書くと、 ブラウザーを選択するメニューが出ているときに、 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Command+c&lt;/code&gt; を押すとコピーできました。&lt;/p&gt; &lt;p&gt;ポップアップメニューの下のドメインが表示されている部分のクリックでもコピーできました。&lt;/p&gt; &lt;h2 id=&quot;browserosaurus-のポリシーとか&quot;&gt;Browserosaurus のポリシーとか&lt;/h2&gt; &lt;p&gt;Browserosaurus は簡単に使えるようにするため、 あらかじめソースに対応アプリ一覧が埋めこまれていて、 ユーザーが自由に対応アプリなどの設定を追加はできない、 という思想になっています。&lt;/p&gt; &lt;p&gt;そこで、機能を追加してもらうとしたらどんな感じだろうと思って、 ソースをながめてみると、 &lt;a href=&quot;https://github.com/will-stone/browserosaurus/blob/5a0a8263d7f8de5fb0082e4b53f92fcbd8c7ecd1/src/main/state/middleware.action-hub.ts#L152-L154&quot;&gt;Command+cでクリップボードにコピー&lt;/a&gt; できるようになっていました。&lt;/p&gt; &lt;p&gt;記事を書きながら確認しなおしていたところ、 &lt;a href=&quot;https://github.com/will-stone/browserosaurus/blob/5a0a8263d7f8de5fb0082e4b53f92fcbd8c7ecd1/src/main/state/middleware.action-hub.ts#L106-L108&quot;&gt;URL barのクリック&lt;/a&gt; でもコピーできるようになっていたので試したところ、 ポップアップメニューの下のドメインが表示されている部分のクリックでコピーできました。&lt;/p&gt; &lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt; &lt;p&gt;クリップボードへのコピー方法を書いたドキュメントはみつけられませんでしたが、 ソースを確認することで機能が存在して使えることがわかりました。&lt;/p&gt; &lt;p&gt;以前に調べてから、記事を書くまで間が開いてしまって、 状況が変わっていて驚きました。&lt;/p&gt; &lt;p&gt;まだしばらくは問題なく使えそうですが、対応アプリの追加が望めなかったり、 新しい macOS で動かなくなる可能性があったりするので、 そのうち別アプリへの移行を検討したいと思いました。&lt;/p&gt; </description> <pubDate>Sat, 30 Aug 2025 06:00:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2025-08-30-browserosaurus-to-clipboard.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2025-08-30-browserosaurus-to-clipboard.html</guid> <category>macos</category> <category>blog</category> </item> <item> <title>macOSのターミナルの「Control +V で非ASCII入力をエスケープ」の挙動を調べた</title> <description>&lt;p&gt;macOSのターミナル.appで「Control +V で非ASCII入力をエスケープ」を有効にしているとマルチバイト文字の入力が変になるという話を調べてみました。&lt;/p&gt; &lt;!--more--&gt; &lt;h2 id=&quot;経緯&quot;&gt;経緯&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://github.com/ohmyzsh/ohmyzsh/issues/7412&quot;&gt;Unable to type non-ASCII chars on Mac &amp;lt;ffffffff&amp;gt;&lt;/a&gt; ではまったという話をみて気になったので調べました。&lt;/p&gt; &lt;h2 id=&quot;調査&quot;&gt;調査&lt;/h2&gt; &lt;p&gt;最初は雑に &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;system(&quot;stty raw -echo&quot;)&lt;/code&gt; で調査したら、戻し忘れて変になったので、ちゃんと &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;STDIN.raw&lt;/code&gt; を使って戻すようにして試しなおしました。&lt;/p&gt; &lt;p&gt;通常の「Control +V で非ASCII入力をエスケープ」が無効の状態では &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; でも &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;あ&lt;/code&gt; でも問題なく入力できました。&lt;/p&gt; &lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;% ruby -r io/console -e &apos;p STDIN.raw{STDIN.sysread(80)}&apos; &quot;a&quot; % ruby -r io/console -e &apos;p STDIN.raw{STDIN.sysread(80)}&apos; &quot;\xE3\x81\x82&quot; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;設定から「Control +V で非ASCII入力をエスケープ」にチェックを入れて有効にした状態では &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; は問題なくて、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;あ&lt;/code&gt; の各バイトに Control-V (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\x16&lt;/code&gt;) がついていました。&lt;/p&gt; &lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;% ruby -r io/console -e &apos;p STDIN.raw{STDIN.sysread(80)}&apos; &quot;a&quot; % ruby -r io/console -e &apos;p STDIN.raw{STDIN.sysread(80)}&apos; &quot;\x16\xE3\x16\x81\x16\x82&quot; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;zsh-での-control-v&quot;&gt;zsh での Control-V&lt;/h2&gt; &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bindkey&lt;/code&gt; の出力から Control-V の割り当てを確認します。 そして &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zshzle&lt;/code&gt; の manpage から &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/quoted-insert&lt;/code&gt; で検索しました。&lt;/p&gt; &lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;% bindkey | grep V &quot;^V&quot; quoted-insert &quot;^X^V&quot; vi-cmd-mode % man zshzle &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;名前の通り、次の文字をそのまま入力する機能です。 個人的には &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo ^V^G&lt;/code&gt; で BEL 文字を入力して visual bell になっているか試す、というような用途に使うことがあります。&lt;/p&gt; &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; quoted-insert vi-quoted-insert Quote the character to insert into the minibuffer. &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h2 id=&quot;まとめ&quot;&gt;まとめ&lt;/h2&gt; &lt;p&gt;zsh で Control-V は quoted-insert なので、環境によってはマルチバイトの入力に必要なことがあるのかもしれませんが、 日本語環境では文字が壊れて困ることが多そうで変更しない方が良い設定だとわかりました。&lt;/p&gt; </description> <pubDate>Fri, 04 Jul 2025 00:25:00 +0000</pubDate> <link>https://blog.n-z.jp/blog/2025-07-04-macos-terminal-control-v.html</link> <guid isPermaLink="true">https://blog.n-z.jp/blog/2025-07-04-macos-terminal-control-v.html</guid> <category>ruby</category> <category>macos</category> <category>blog</category> </item> </channel> </rss>