[英]Configure MySQL Replication with k8s StatefulSet
參考官方文檔,努力在k8s中實現MySQL Replication。
但是,當我嘗試以與官方文檔相同的方式實現它時,出現錯誤。
在 StatefulSet 的索引 0 mysql-0 pod
處發生Warning BackOff 3m32s (x26 over 8m27s) kubelet Back-off restarting failed container
錯誤。
確認容器內部發生的錯誤后,結果顯示內部日志,如下圖所示。
2021-04-06 13:36:34+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
2021-04-06 13:36:35+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-06 13:36:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.33-1debian10 started.
2021-04-06 13:36:35+00:00 [Note] [Entrypoint]: Initializing database files
2021-04-06T13:36:35.449017Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-04-06T13:36:35.465160Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2021-04-06T13:36:35.465207Z 0 [ERROR] Aborting
你在訓練過程中遇到過錯誤嗎? 或者你知道為什么會這樣嗎?
通過官方文檔似乎有一個成功的案例,但我一直無法找出它有什么問題。
為了解決 mysql 容器內部出現的錯誤,我升級了 mysql 鏡像版本並添加了args: ["--ignore-db-dir=lost+found"]
並嘗試了很多類似的操作。 我找不到它。
由於它是官方文檔的摘錄,我認為上面的代碼本身沒有問題。 我懷疑的是 StorageClass。
實驗室使用的代碼在github中。
除了一個小的名稱更改之外,與官方文檔沒有什么不同。
任何幫助,將不勝感激。 我絕對想實現它。
您遇到的錯誤:
[ERROR] --initialize specified but the data directory has files in it. Aborting.
表示您的數據目錄不為空。 為了解決它,您可以:
刪除數據目錄的內容
選擇另一個數據目錄或重命名它
確保/var/lib/mysql
之前的目錄也是空的,例如: /empty-folder:/var/lib/mysql
根據您提供的鏈接文檔,實際數據目錄是指/var/lib/mysql
,因此您應該在那里檢查。
至於警告:
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
我找到:
explicit_defaults_for_timestamp
本身已被棄用,因為它的唯一目的是允許控制將在 MySQL 的未來版本中刪除的棄用TIMESTAMP
行為。 當刪除這些行為時,explicit_defaults_for_timestamp
不再有任何用途,您也可以期望它也被刪除。
此處記錄了更多詳細信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.