lxc-create 掛起並最終失敗

lxc-create 掛起並最終失敗

我試圖在 Linux 容器上放置一些 juju charms,但容器無法啟動。為了調試這個問題,我進入了發生這種情況的節點,並嘗試手動建立 LXC 容器,例如

ubuntu@slot13:~$ sudo lxc-create -t ubuntu -n pavan
Checking cache download in /var/cache/lxc/trusty/rootfs-amd64 ...
Installing packages in template: ssh,vim,language-pack-en
Downloading ubuntu trusty minimal ...
I: Retrieving Release

它根本沒有任何進展。它在這裡卡了很長很長一段時間。過了很長一段時間,它說,

ERROR: Unable to fetch GPG key from keyserver

並繼續掛起。最後20-30分鐘後,它放棄了

E: Failed getting release file http://archive.ubuntu.com/ubuntu/dists/trusty/Release

命令對應的日誌檔案在哪裡lxc-create?我該如何調試這個問題?

編輯:我弄清楚瞭如何查看調試日誌,因此運行了幾次以下命令

sudo lxc-create -t ubuntu -n pavan --logfile=test.txt --logpriority=DEBUG

test.txt僅包含這個

lxc-create 1414897265.204 ERROR    lxc_container - Error: pavan creation was not completed
lxc-create 1414897407.757 ERROR    lxc_container - Error: pavan creation was not completed
lxc-create 1414897407.759 WARN     lxc_log - lxc_log_init called with log already initialized

但它仍然掛起,而且調試日誌沒有提供太多幫助。

答案1

請附加--no-validate標誌以跳過 gpg 驗證:

lxc-create -t ubuntu -n pavan -- --no-validate

參考https://github.com/lxc/lxc/blob/master/templates/lxc-download.in#L240

答案2

你是在代理後面嗎?如果是,那麼您可以在 bash 中設定代理程式。問題如下,

export http_proxy="http://<proxy_host>:<port>"

答案3

實際上 juju 使用“ubuntu-cloud”模板來抓取圖像,在我運行 trusty 的系統中創建模板所執行的命令是:

lxc-create -n juju-trusty-lxc-template \
  -t ubuntu-cloud \
  -f /var/lib/juju/containers/juju-trusty-lxc-template/lxc.conf \
  -- --debug \
  --userdata /var/lib/juju/containers/juju-trusty-lxc-template/cloud-init \
  --hostid juju-trusty-lxc-template
  -r trusty

我建議您執行類似的操作,看看會發生什麼錯誤。

答案4

問題

如果您位於限制網際網路存取的防火牆後面,您可能會收到此錯誤:

$ lxc-create -t download -n my-container
Setting up the GPG keyring
ERROR: Unable to fetch GPG key from keyserver.
lxc-create: lxccontainer.c: create_run_template: 1297 container
  creation template for my-container failed
lxc-create: tools/lxc_create.c: main: 318 Error creating
  container my-container

使固定

透過80連接埠連接密鑰伺服器:

$ lxc-create -t download -n my-container \
  -- --keyserver hkp://p80.pool.sks-keyservers.net:80

細節

密鑰伺服器,hkp://p80.pool.sks-keyservers.net:80來自lxc原始碼:

apt source lxc
grep -ri hkp: .

參考

相關內容