{"id":225,"date":"2024-09-13T17:35:59","date_gmt":"2024-09-13T09:35:59","guid":{"rendered":"http:\/\/www.bigqq.com\/?p=225"},"modified":"2025-10-21T13:22:24","modified_gmt":"2025-10-21T05:22:24","slug":"ubuntu%e5%ae%89%e8%a3%85docker-rancher","status":"publish","type":"post","link":"http:\/\/www.bigqq.com\/?p=225","title":{"rendered":"ubuntu\u5b89\u88c5docker rancher"},"content":{"rendered":"\n<p>\u66f4\u65b0 APT \u5305\u7d22\u5f15\uff1asudo apt-get update<\/p>\n\n\n\n<p>\u5b89\u88c5\u7528\u4e8e\u9a8c\u8bc1\u5305\u7684\u5305\uff1asudo apt-get install apt-transport-https ca-certificates curl software-properties-common<\/p>\n\n\n\n<p>\u6dfb\u52a0 Docker \u7684\u5b98\u65b9 GPG \u516c\u94a5\uff1acurl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo apt-key add &#8211;<\/p>\n\n\n\n<p>\u9a8c\u8bc1\u516c\u94a5\u7684\u6307\u7eb9\u662f\u5426\u5339\u914d\uff1asudo apt-key fingerprint 0EBFCD88<\/p>\n\n\n\n<p>\u6dfb\u52a0 Docker \u7684\u7a33\u5b9a\u7248\u672c\u4ed3\u5e93\uff1asudo add-apt-repository &#8220;deb [arch=amd64] https:\/\/download.docker.com\/linux\/ubuntu $(lsb_release -cs) stable&#8221;<\/p>\n\n\n\n<p><em>\u6dfb\u52a0\u963f\u91cc\u4e91\u7684Docker\u4ed3\u5e93\u5730\u5740\uff1asudo add-apt-repository &#8220;deb [arch=amd64] http:\/\/mirrors.aliyun.com\/docker-ce\/linux\/ubuntu $(lsb_release -cs) stable&#8221;<\/em><\/p>\n\n\n\n<p>\u518d\u6b21\u66f4\u65b0 APT \u5305\u7d22\u5f15\uff1asudo apt-get update<\/p>\n\n\n\n<p>\u5c1d\u8bd5\u91cd\u65b0\u5b89\u88c5 Docker\uff1asudo apt-get install docker-ce<\/p>\n\n\n\n<p>\u5b89\u88c5docker-compose: apt install docker-compose<\/p>\n\n\n\n<p>\u6302\u8f7d\u6570\u636e\u76d8\uff1a<\/p>\n\n\n\n<ul>\n<li>fdisk -l&nbsp; \u67e5\u770b\u78c1\u76d8\u72b6\u6001<\/li>\n\n\n\n<li>df -h \u67e5\u8be2\u670d\u52a1\u5668\u786c\u76d8\u4f7f\u7528\u60c5\u51b5<\/li>\n\n\n\n<li>\u5c06dev\/vdb \u6570\u636e\u76d8\u5206\u533a\u5e76\u6302\u8f7d \uff1a\u8fdb\u5165\u4e3b\u76ee\u5f55\u4e0a cd \u56de\u8f66 \u6267\u884c&nbsp;&nbsp;fdisk \/dev\/vdb \u8fdb\u884c\u5206\u533a \u64cd\u4f5c\u5206\u522b\u4e3a n\u3001p\u30011\u3001\u56de\u8f66\u3001\u56de\u8f66\u3001wq<\/li>\n\n\n\n<li>\u683c\u5f0f\u5316\u5206\u533a\uff1amkfs.ext4 \/dev\/vdb1<\/li>\n\n\n\n<li>\u6839\u76ee\u5f55 cd \/<\/li>\n\n\n\n<li>\u521b\u5efa\u6587\u4ef6\u5939 mkdir -p mesdata<\/li>\n\n\n\n<li>\u6302\u8f7dmount \/dev\/vdb1 \/mesdata<\/li>\n\n\n\n<li>\u91cd\u542f\u81ea\u52a8\u6302\u8f7d\u8bbe\u7f6e 1\uff0c<strong>\u83b7\u53d6\u65b0\u5206\u533a\u7684UUID<\/strong> \uff1ablkid  \uff08\u627e\u5230<code>\/dev\/vdb1<\/code>\u7684\u884c\uff0c\u8bb0\u4e0bUUID\uff09  2\uff0c<strong>\u7f16\u8f91<code>\/etc\/fstab<\/code>\u4ee5\u6dfb\u52a0\u81ea\u52a8\u6302\u8f7d<\/strong>\uff1asudo nano \/etc\/fstab \u5728\u6587\u4ef6\u672b\u5c3e\u6dfb\u52a0\u4e00\u884cUUID=your-uuid \/mesdata ext4 defaults 0 2<\/li>\n<\/ul>\n\n\n\n<p>docker \u8bbe\u7f6e\uff1avim \/etc\/docker\/daemon.json<\/p>\n\n\n\n<p>{<br>&#8220;registry-mirrors&#8221;:[&#8220;https:\/\/registry.docker-cn.com&#8221;,&#8221;https:\/\/q59d4unt.mirror.aliyuncs.com&#8221;],<br>&#8220;insecure-registries&#8221;: [&#8220;0.0.0.0&#8221;],<br>&#8220;log-driver&#8221;:&#8221;json-file&#8221;,<br>&#8220;log-opts&#8221;:{<br>&#8220;max-size&#8221;:&#8221;500m&#8221;,<br>&#8220;max-file&#8221;:&#8221;3&#8243;<br>}<br>}<\/p>\n\n\n\n<p>\u542f\u7528daemon\uff1asystemctl daemon-reload<\/p>\n\n\n\n<p>\u91cd\u542fdocker\uff1asystemctl restart docker<\/p>\n\n\n\n<p>docker run &#8211;privileged -d &#8211;name rancher &#8211;restart=unless-stopped -p 8080:80 -p 8443:443 -v \/mesdata\/rancher:\/var\/lib\/rancher  rancher\/rancher:stable<\/p>\n\n\n\n<p>rancher \u65e0\u6cd5\u542f\u52a8\u6392\u67e5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4ee5\u4e0b\u5904\u7406\u662f\u9047\u5230&#91;FATAL] k3s exited with: exit status 1\u7684\u9519\u8bef\uff0c\n\u67e5\u770b\u65e5\u5fd7 rancher\u4e0bk3s-cluster-reset.log  k3s.log \u53e6\u5916docker logs -f rancher\nUbuntu\u9ed8\u8ba4\u542f\u7528cgroup v2\uff0c\u4fee\u6539\u652f\u6301v1\n\/etc\/default\/grub  \u589e\u52a0GRUB_CMDLINE_LINUX=\"cgroup_memory=1 cgroup_enable=memory swapaccount=1 systemd.unified_cgroup_hierarchy=0\"\nupdate-grub\nreboot\n\n\u53e6\u5916\u6839\u636e\u65e5\u5fd7time=\"2022-06-20T10:34:16.530473756Z\" level=fatal msg=\"starting kubernetes: preparing server: start managed \ndatabase: cluster-reset was successfully performed, please remove the cluster-reset flag and start k3s normally, if you need to perform another cluster reset, you must first manually delete the \/var\/lib\/rancher\/k3s\/server\/db\/reset-flag file\" \u5220\u9664reset-flag\u6587\u4ef6\n\n\u5728\/etc\/sysctl.conf\u4e2d\u6dfb\u52a0\uff1a\nnet.bridge.bridge-nf-call-ip6tables = 1\nnet.bridge.bridge-nf-call-iptables = 1\n\u6267\u884csysctl -p \u65f6\u5237\u65b0\n\ndocker run --privileged -d --name rancher --restart=unless-stopped -p 8080:80 -p 8443:443 -v \/mesdata\/rancher:\/var\/lib\/rancher -e CATTLE_SYSTEM_DEFAULT_REGISTRY=https:\/\/q59d4unt.mirror.aliyuncs.com -e CATTLE_BOOTSTRAP_PASSWORD=SmarteeMes2021 -e CATTLE_SYSTEM_CATALOG=bundled  mes\/rancher:latest\n\ndocker run -d --privileged --name rancher --restart=unless-stopped -p 8080:80 -p 8443:443 -v \/mesdata\/rancher:\/var\/lib\/rancher -e CATTLE_BOOTSTRAP_PASSWORD=SmarteeMes2021\n  -e CATTLE_AGENT_IMAGE=\"registry.cn-hangzhou.aliyuncs.com\/rancher\/rancher-agent:v2.6.8\" \\\n  registry.cn-hangzhou.aliyuncs.com\/rancher\/rancher:v2.6.8\n\n<strong>sudo docker run -d --name rancher --restart=unless-stopped --privileged -p 8080:80 -p 8443:443 -v \/var\/rancher:\/var\/lib\/rancher -v \/var\/rancher\/registries.yaml:\/etc\/rancher\/k3s\/registries.yaml -e CATTLE_SYSTEM_DEFAULT_REGISTRY=registry.cn-hangzhou.aliyuncs.com -e CATTLE_BOOTSTRAP_PASSWORD=SmarteeMes2021 registry.cn-hangzhou.aliyuncs.com\/rancher\/rancher:v2.9.1<\/strong>\n\n\nmirrors:\n  # \u79c1\u6709\u4ed3\u5e93\u57df\u540d\n  crpi-2ooy6l2xyewfpj4y.cn-shanghai.personal.cr.aliyuncs.com:\n    endpoint:\n      - \"https:\/\/crpi-2ooy6l2xyewfpj4y.cn-shanghai.personal.cr.aliyuncs.com\"\nconfigs:\n  \"crpi-2ooy6l2xyewfpj4y.cn-shanghai.personal.cr.aliyuncs.com\":\n    auth:\n      username: hi34841966@aliyun.com  # \u8fd9\u662f\u79c1\u6709\u955c\u50cf\u4ed3\u5e93\u7684\u7528\u6237\u540d\n      password: xxx  # \u8fd9\u662f\u79c1\u6709\u955c\u50cf\u4ed3\u5e93\u7684\u5bc6\u7801\n~                                                       <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run --privileged -d --name rancher --restart=unless-stopped -p 8080:80 -p 8443:443 -v \/mesdata\/rancher:\/var\/lib\/rancher -e CATTLE_BOOTSTRAP_PASSWORD=SmarteeMes2021 -e CATTLE_SYSTEM_CATALOG=bundled -v \/mesdata\/registries.yaml:\/etc\/rancher\/k3s\/registries.yaml  mes\/rancher:latest\n\ncat &gt; \/etc\/rancher\/k3s\/registries.yaml &lt;&lt;EOF\nmirrors:\n  docker.io:\n    endpoint:\n      - \"https:\/\/registry.cn-hangzhou.aliyuncs.com\/\"\n  quay.io:\n    endpoint:\n      - \"https:\/\/quay.tencentcloudcr.com\/\"\n  registry.k8s.io:\n    endpoint:\n      - \"https:\/\/registry.aliyuncs.com\/v2\/google_containers\"\n  gcr.io:\n    endpoint:\n      - \"https:\/\/gcr.m.daocloud.io\/\"\n  k8s.gcr.io:\n    endpoint:\n      - \"https:\/\/registry.aliyuncs.com\/google_containers\"\n  ghcr.io:\n    endpoint:\n      - \"https:\/\/ghcr.m.daocloud.io\/\"<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/forums.rancher.cn\/t\/failed-to-pull-image-rancher-mirrored-pause-3-6\/1659\/4\">https:\/\/forums.rancher.cn\/t\/failed-to-pull-image-rancher-mirrored-pause-3-6\/1659\/4<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/forums.rancher.cn\/t\/rancher2-x-rancher-shell-v0-1-19\/2013\/2\">https:\/\/forums.rancher.cn\/t\/rancher2-x-rancher-shell-v0-1-19\/2013\/2<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.jianshu.com\/p\/c71b5a1918e1\">https:\/\/www.jianshu.com\/p\/c71b5a1918e1<\/a><\/p>\n\n\n\n<p>http:\/\/docs.rancher.cn\/docs\/rancher2.5\/installation\/other-installation-methods\/single-node-docker\/_index<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> journalctl -xef -u rancher-system-agent.service \njournalctl -xeu rke2-server.service\ndocker logs rancher\n\/var\/lib\/rancher\/rke2\/bin\/kubectl --kubeconfig \/etc\/rancher\/rke2\/rke2.yaml get pods -A\n\n\/etc\/rancher\/rke2\/config.yaml.d\/50-rancher.yaml \u589e\u52a0 system-default-registry\":\"registry.cn-hangzhou.aliyuncs.com\",\n\nsystemctl list-units --type=service\nsystemctl restart rke2-server.service\nsystemctl restart rancher-system-agent<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u6e05\u7406\u73af\u5883\uff08\u53c2\u8003\u547d\u4ee4\uff0c\u9700\u8981\u65f6\u4f7f\u7528\uff09\nhttps:&#47;&#47;ranchermanager.docs.rancher.com\/zh\/v2.9\/how-to-guides\/new-user-guides\/manage-clusters\/clean-cluster-nodes#%E6%B8%85%E7%90%86%E8%8A%82%E7%82%B9\nrke\u6e05\u7406\u811a\u672c\nrke2\u6e05\u7406\u811a\u672c\n\u6e05\u7406\u811a\u672c\u6e05\u7406\u547d\u4ee4\u90fd\u6267\u884c\uff0c\u6ca1\u811a\u672c\u4e0b\u8f7d\u811a\u672c\u540e\u518d\u6267\u884c\n\nsh clear-k8s.sh\n\/usr\/local\/bin\/rke2-uninstall.sh\n\nrke2\u96c6\u7fa4\u642d\u5efa\u65f6\uff0c\u4eba\u5de5\u518d\u5ea6\u786e\u8ba4\/var\/lib\u3001\/etc\u3001\/opt\u7b49\u76ee\u5f55\u4e0b\uff0c\u662f\u5426\u8fd8\u8981rancher\u3001docker\u3001k3s\u3001kubernetes\u3001containerd\u7b49rancher\u4e0ek3s\u3001k8s\u7b49\u6b8b\u7559\u4fe1\u606f\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u8f6e\u6362\u53c2\u8003 https:\/\/forums.rancher.cn\/t\/rke2\/3659\n\u67e5\u770b\u8bc1\u4e66\u6709\u6548\u671f\nfor i in `ls \/var\/lib\/rancher\/rke2\/server\/tls\/*.crt`; do echo $i; openssl x509 -enddate -noout -in $i; done\n\nfor i in $(ls \/var\/lib\/rancher\/k3s\/server\/tls\/*.crt);do openssl x509 -enddate -noout -in $i;  done<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\u6dfb\u52a0\u96c6\u7fa4\u8282\u70b9\u65f6\u6ce8\u610f \u8282\u70b9\u4e3b\u673a\u540d\u4e0d\u80fd\u91cd\u590d\uff0c\n--\u67e5\u770b\u4e3b\u673a\u540d\nhostnamectl\n--\u4fee\u6539\u4e3b\u673a\u540d\nsudo hostnamectl set-hostname newname\n\n\u6ce8\u610f\u9632\u706b\u5899\nsystemctl status ufw\nsystemctl stop ufw\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ETCD\u5bb9\u5668\u64cd\u4f5c\nhttps:&#47;&#47;forums.rancher.cn\/t\/rke2-commands\/2110\n\nsudo apt-get install etcd-client\nexport ETCDCTL_API=3\netcdctl --cacert '\/var\/lib\/rancher\/rke2\/server\/tls\/etcd\/server-ca.crt' --cert '\/var\/lib\/rancher\/rke2\/server\/tls\/etcd\/server-client.crt' --key '\/var\/lib\/rancher\/rke2\/server\/tls\/etcd\/server-client.key' member list\n\netcdctl --cacert '\/var\/lib\/rancher\/rke2\/server\/tls\/etcd\/server-ca.crt' --cert '\/var\/lib\/rancher\/rke2\/server\/tls\/etcd\/server-client.crt' --key '\/var\/lib\/rancher\/rke2\/server\/tls\/etcd\/server-client.key' member remove 6d5305ba5c557e02\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u66f4\u65b0 APT \u5305\u7d22\u5f15\uff1asudo apt- [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.bigqq.com\/index.php?rest_route=\/wp\/v2\/posts\/225"}],"collection":[{"href":"http:\/\/www.bigqq.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bigqq.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bigqq.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bigqq.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=225"}],"version-history":[{"count":21,"href":"http:\/\/www.bigqq.com\/index.php?rest_route=\/wp\/v2\/posts\/225\/revisions"}],"predecessor-version":[{"id":356,"href":"http:\/\/www.bigqq.com\/index.php?rest_route=\/wp\/v2\/posts\/225\/revisions\/356"}],"wp:attachment":[{"href":"http:\/\/www.bigqq.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bigqq.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bigqq.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}