{"id":1362,"date":"2022-04-09T21:21:30","date_gmt":"2022-04-09T13:21:30","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=1362"},"modified":"2022-04-25T10:38:55","modified_gmt":"2022-04-25T02:38:55","slug":"6-k8s%e4%bd%bf%e7%94%a8ceph%e5%88%86%e5%b8%83%e5%bc%8f%e9%9b%86%e7%be%a4%e5%ad%98%e5%82%a8","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=1362","title":{"rendered":"6.k8s\u4f7f\u7528ceph\u5206\u5e03\u5f0f\u96c6\u7fa4\u5b58\u50a8"},"content":{"rendered":"\n<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.Ceph\u5206\u5e03\u5f0f\u5b58\u50a8\u7cfb\u7edf\u6982\u8ff0<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>Ceph\u662f\u4e00\u4e2a\u5bf9\u8c61(object)\u5f0f\u5b58\u50a8\u7cfb\u7edf\uff0c\u5b83\u628a\u6bcf\u4e00\u4e2a\u5f85\u7ba1\u7406\u7684\u6570\u636e\u6d41(\u4f8b\u5982\u4e00\u4e2a\u6587\u4ef6)\u5207\u5206\u4e3a\u4e00\u5230\u591a\u4e2a\u56fa\u5b9a\u5927\u5c0f\u7684\u5bf9\u8c61\u6570\u636e\uff0c\u5e76\u4ee5\u5176\u4e3a\u539f\u5b50\u5355\u5143\u5b8c\u6210\u6570\u636e\u5b58\u53d6\u3002\r\n\u5bf9\u8c61\u6570\u636e\u7684\u5e95\u5c42\u5b58\u50a8\u670d\u52a1\u65f6\u7531\u591a\u4e2a\u4e3b\u673a(host)\u7ec4\u6210\u7684\u5b58\u50a8\u7cfb\u7edf\uff0c\u8be5\u96c6\u7fa4\u4e5f\u88ab\u79f0\u4e4b\u4e3aRADOS(Reliable Automatic Distributed Object Store)\u5b58\u50a8\u96c6\u7fa4\uff0c\u5373\u53ef\u9760\uff0c\u81ea\u52a8\u5316\uff0c\u5206\u5e03\u5f0f\u5bf9\u8c61\u5b58\u50a8\u7cfb\u7edf\u3002\r\nlibrados\u662fRADOS\u5b58\u50a8\u96c6\u7fa4\u7684API\uff0c\u5b83\u652f\u6301C\uff0cC++\uff0cJava\uff0cPython\uff0cRuby\u548cPHP\u7b49\u7f16\u7a0b\u8bed\u8a00\u3002\r\n\u7531\u4e8e\u76f4\u63a5\u57fa\u4e8elibrados\u8fd9\u4e2aAPI\u624d\u80fd\u4f7f\u7528Ceph\u96c6\u7fa4\u7684\u8bdd\u5bf9\u4f7f\u7528\u8005\u662f\u6709\u4e00\u5b9a\u95e8\u69db\u7684\u3002\u5f53\u7136\uff0c\u8fd9\u4e00\u70b9Ceph\u5b98\u65b9\u4e5f\u610f\u8bc6\u5230\u4e86\uff0c\u4e8e\u662f\u4ed6\u4eec\u8fd8\u5bf9Ceph\u505a\u51fa\u4e86\u4e09\u4e2a\u62bd\u8c61\u8d44\u6e90\uff0c\u5206\u522b\u4e3aRADOSGW,RBD,CEPHFS\u7b49\u3002\r\nRadosGw,RBD\u548cCephFS\u90fd\u662fRADOS\u5b58\u50a8\u670d\u52a1\u7684\u5ba2\u6237\u7aef\uff0c\u4ed6\u4eec\u628aRADOS\u7684\u5b58\u50a8\u670d\u52a1\u63a5\u53e3(librados)\u5206\u522b\u4ece\u4e0d\u540c\u7684\u89d2\u5ea6\u505a\u4e86\u8fdb\u4e00\u6b65\u62bd\u8c61\uff0c\u56e0\u800c\u5404\u81ea\u9002\u7528\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\uff0c\u5982\u4e0b\u6240\u793a:\r\nRadosGw:\r\n  \u5b83\u662f\u4e00\u4e2a\u66f4\u62bd\u8c61\u7684\u80fd\u591f\u8de8\u4e92\u8054\u7f51\u7684\u4e91\u5b58\u50a8\u5bf9\u8c61\uff0c\u5b83\u662f\u57fa\u4e8eRESTful\u98ce\u683c\u63d0\u4f9b\u7684\u670d\u52a1\u3002\u6bcf\u4e00\u4e2a\u6587\u4ef6\u90fd\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u800c\u6587\u4ef6\u5927\u5c0f\u662f\u5404\u4e0d\u76f8\u540c\u7684\u3002\r\n  \u4ed6\u548cCeph\u96c6\u7fa4\u7684\u5185\u90e8\u7684\u5bf9\u8c61(object\uff0c\u5b83\u662f\u56fa\u5b9a\u5927\u5c0f\u7684\u5b58\u50a8\u5757\uff0c\u53ea\u80fd\u5728Ceph\u96c6\u7fa4\u5185\u90e8\u4f7f\u7528\uff0c\u57fa\u4e8eRPC\u534f\u8bae\u5de5\u4f5c\u7684)\u5e76\u4e0d\u76f8\u540c\u3002\r\n  \u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0cRadosGw\u4f9d\u8d56\u4e8elibrados\u54df\uff0c\u8bbf\u95ee\u4ed6\u53ef\u4ee5\u57fa\u4e8ehttp\/https\u534f\u8bae\u6765\u8fdb\u884c\u8bbf\u95ee\u3002\r\nRBD:\r\n  \u5c06ceph\u96c6\u7fa4\u63d0\u4f9b\u7684\u5b58\u50a8\u7a7a\u95f4\u6a21\u62df\u6210\u4e00\u4e2a\u53c8\u4e00\u4e2a\u72ec\u7acb\u7684\u5757\u8bbe\u5907\u3002\u6bcf\u4e2a\u5757\u8bbe\u5907\u90fd\u76f8\u5f53\u4e8e\u4e00\u4e2a\u4f20\u7edf\u78c1(\u786c)\u76d8\u4e00\u6837\uff0c\u4f60\u53ef\u4ee5\u5bf9\u5b83\u505a\u683c\u5f0f\u5316\uff0c\u5206\u533a\uff0c\u6302\u8f7d\u7b49\u5904\u7406\u3002\r\n  \u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0cRBD\u4f9d\u8d56\u4e8elibrados\u54df\uff0c\u8bbf\u95ee\u9700\u8981Linux\u5185\u6838\u652f\u6301librdb\u76f8\u5173\u6a21\u5757\u54df\u3002\r\nCephFS:\r\n  \u5f88\u660e\u663e\uff0c\u8fd9\u662fCeph\u96c6\u7fa4\u7684\u6587\u4ef6\u7cfb\u7edf\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u8f7b\u677e\u7684\u50cfNFS\u90a3\u6837\u4f7f\u7528\uff0c\u4f46\u5b83\u7684\u6027\u80fd\u74f6\u9888\u76f8\u6bd4NFS\u6765\u8bf4\u662f\u5f88\u96be\u9047\u5230\u7684\u3002\r\n  \u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0cCephFS\u5e76\u4e0d\u4f9d\u8d56\u4e8elibrados\u54df\uff0c\u5b83\u548clibrados\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u7ec4\u4ef6\u3002\u4f46\u8be5\u7ec4\u4ef6\u4f7f\u7528\u7684\u70ed\u5ea6\u76f8\u6bd4RadosGw\u548cRBD\u8981\u4f4e\u3002\r\n\u63a8\u8350\u9605\u8bfb:\r\n   \u67e5\u770bceph\u7684\u5b98\u65b9\u6587\u6863: https:\/\/docs.ceph.com\/en\/latest\/\r\n   \u4e2d\u6587\u793e\u533a\u6587\u6863: http:\/\/docs.ceph.org.cn\r\n\u6e29\u99a8\u63d0\u793a:\r\n  (1)CRUSH\u7b97\u6cd5\u662fCeph\u5185\u90e8\u6570\u636e\u5bf9\u8c61\u5b58\u50a8\u8def\u7531\u7684\u7b97\u6cd5\u3002\u5b83\u6ca1\u6709\u4e2d\u5fc3\u8282\u70b9\uff0c\u5373\u6ca1\u6709\u5143\u6570\u636e\u4e2d\u5fc3\u670d\u52a1\u5668\u3002\r\n  (2)\u65e0\u8bba\u4f7f\u7528librados\uff0cRadosGw\uff0cRBD\uff0cCephFS\u54ea\u4e2a\u5ba2\u6237\u7aef\u6765\u5b58\u50a8\u6570\u636e\uff0c\u6700\u7ec8\u7684\u6570\u636e\u90fd\u4f1a\u88ab\u5199\u5165\u5230Rados Cluster\uff0c\u503c\u5f97\u6ce8\u610f\u7684\u662f\u8fd9\u4e9b\u5ba2\u6237\u7aef\u548cRados Cluster\u4e4b\u95f4\u5e94\u8be5\u6709\u591a\u4e2a\u5b58\u50a8\u6c60(pool)\uff0c\u6bcf\u4e2a\u5ba2\u6237\u7aef\u7c7b\u578b\u90fd\u6709\u81ea\u5df1\u7684\u5b58\u50a8\u6c60\u8d44\u6e90\u3002\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">2.Ceph\u90e8\u7f72\u5b9e\u6218<\/h2>\n\n\n\n<p><strong><em>1.\u51c6\u59073\u53f0\u8282\u70b9<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4e09\u53f0\u8282\u70b9\u6bcf\u53f02\u5757\u786c\u76d8\uff0c\u5e76\u6dfb\u52a0hosts\u89e3\u6790\r\n&#91;root@ceph01 ~]# cat \/etc\/hosts\r\n127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4\r\n::1         localhost localhost.localdomain localhost6 localhost6.localdomain6\r\n10.0.0.14 ceph01\r\n10.0.0.15 ceph02\r\n10.0.0.16 ceph03\r\n&#91;root@ceph01 ~]# scp -rp \/etc\/hosts 10.0.0.15:\/etc\/hosts\r\n&#91;root@ceph01 ~]# scp -rp \/etc\/hosts 10.0.0.16:\/etc\/hosts\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u914d\u7f6e\u514d\u5bc6\u767b\u5f55\uff08\u540e\u7eedceph-deploy\u5de5\u5177\u4f9d\u8d56\u514d\u5bc6\u767b\u5f55\uff09<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ceph01 ~]# ssh-keygen -t rsa -f ~\/.ssh\/id_rsa -P '' -q\r\n&#91;root@ceph01 ~]# ssh-copy-id ceph01\r\n&#91;root@ceph01 ~]# scp -rp .ssh\/ ceph02:\/root\/\r\n&#91;root@ceph01 ~]# scp -rp .ssh\/ ceph03:\/root\/\r<\/code><\/pre>\n\n\n\n<p><strong><em>3.\"ceph01\"\u8282\u70b9\u5b89\u88c5\"ceph-deploy\"\u5de5\u5177\uff0c\u7528\u4e8e\u540e\u671f\u90e8\u7f72ceph\u96c6\u7fa4<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u51c6\u5907\u56fd\u5185\u7684\u8f6f\u4ef6\u6e90\uff08\u542b\u57fa\u7840\u955c\u50cf\u8f6f\u4ef6\u6e90\u548cepel\u6e90\uff09\r\n&#91;root@ceph01 ~]# curl  -o \/etc\/yum.repos.d\/CentOS-Base.repo http:\/\/mirrors.aliyun.com\/repo\/Centos-7.repo\r\n&#91;root@ceph01 ~]# curl  -o \/etc\/yum.repos.d\/epel.repo http:\/\/mirrors.aliyun.com\/repo\/epel-7.repo\r\n###\u914d\u7f6eceph\u8f6f\u4ef6\u6e90\r\n&#91;root@ceph01 ~]# cat \/etc\/yum.repos.d\/ceph.repo\r\n&#91;ceph]\r\nname=ceph 2021\r\nbaseurl=https:\/\/mirrors.tuna.tsinghua.edu.cn\/ceph\/rpm-octopus\/el7\/x86_64\/\r\ngpgcheck=0\r\nenable=1\r\n&#91;ceph-tools]\r\nname=ceph tools\r\nbaseurl=https:\/\/mirrors.tuna.tsinghua.edu.cn\/ceph\/rpm-octopus\/el7\/noarch\/\r\ngpgcheck=0\r\nenable=1\r\n###ceph01\u8282\u70b9\u5b89\u88c5\"ceph-deploy\"\u5de5\u5177\uff0c\u7528\u4e8e\u540e\u671f\u90e8\u7f72ceph\u96c6\u7fa4\r\n&#91;root@ceph01 ~]# sed -ri 's#(keepcache=)0#\\11#' \/etc\/yum.conf\r\n&#91;root@ceph01 ~]# yum makecache\r\n&#91;root@ceph01 ~]# yum -y install ceph-deploy\r\n###\u5c06rpm\u8f6f\u4ef6\u6e90\u63a8\u9001\u5230\u5176\u5b83\u8282\u70b9\r\n&#91;root@ceph01 ~]# scp \/etc\/yum.repos.d\/*.repo ceph02:\/etc\/yum.repos.d\/\r\n&#91;root@ceph01 ~]# scp \/etc\/yum.repos.d\/*.repo ceph03:\/etc\/yum.repos.d\/\r<\/code><\/pre>\n\n\n\n<p><strong><em>4.ceph\u73af\u5883\u51c6\u5907<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###ceph01\u8282\u70b9\u5b89\u88c5ceph\u73af\u5883\r\n&#91;root@ceph01 ~]# yum -y install ceph ceph-mon ceph-mgr ceph-radosgw ceph-mds ceph-osd\r\n\u76f8\u5173\u8f6f\u4ef6\u5305\u529f\u80fd\u8bf4\u660e\u5982\u4e0b:\r\nceph:ceph\u901a\u7528\u6a21\u5757\u8f6f\u4ef6\u5305\u3002\r\nceph-mon: ceph\u6570\u636e\u7684\u76d1\u63a7\u548c\u5206\u914d\u6570\u636e\u5b58\u50a8\uff0c\u5176\u4e2dmon\u662fmonitor\u7684\u7b80\u5199\u3002\r\nceph-mgr:\u7ba1\u7406\u96c6\u7fa4\u72b6\u6001\u7684\u7ec4\u4ef6\u3002\u5176\u4e2dmgr\u662fmanager\u7684\u7b80\u5199\u3002\u57fa\u4e8e\u8be5\u7ec4\u4ef6\u6211\u4eec\u53ef\u4ee5\u8ba9zabbix\u6765\u76d1\u63a7ceph\u96c6\u7fa4\u54df\u3002\r\nceph-radosgw:\u5bf9\u8c61\u5b58\u50a8\u7f51\u5173\uff0c\u591a\u7528\u4e8eceph\u5bf9\u8c61\u5b58\u50a8\u76f8\u5173\u6a21\u5757\u8f6f\u4ef6\u5305\u3002\r\nceph-mds: ceph\u7684\u6587\u4ef6\u5b58\u50a8\u76f8\u5173\u6a21\u5757\u8f6f\u4ef6\u5305\uff0c\u5373\"metadata server\"    \r\nceph-osd:ceph\u7684\u5757\u5b58\u50a8\u76f8\u5173\u6a21\u5757\u8f6f\u4ef6\u5305\r\n###\u5c06\u8f6f\u4ef6\u6253\u5305\u5230\u672c\u5730\u5e76\u63a8\u9001\u5230\u5176\u5b83\u8282\u70b9\r\n&#91;root@ceph01 ~]# mkdir ceph-rpm\r\n&#91;root@ceph01 ~]# find \/var\/cache\/yum\/ -type f -name \"*.rpm\" | xargs mv -t ceph-rpm\/\r\n&#91;root@ceph01 ~]# tar zcf ceph.tar.gz ceph-rpm\r\n&#91;root@ceph01 ~]# scp ceph.tar.gz ceph02:~\r\n&#91;root@ceph01 ~]# scp ceph.tar.gz ceph03:~\r\n###\u5176\u5b83\u8282\u70b9\u5b89\u88c5ceph\u73af\u5883\r\n&#91;root@echp02 ~]# tar xf ceph.tar.gz\r\n&#91;root@echp02 ~]# cd ceph-rpm\/\r\n&#91;root@echp02 ceph-rpm]# yum localinstall *.rpm -y\r<\/code><\/pre>\n\n\n\n<p><strong><em>5.\u521d\u59cb\u5316ceph\u7684\u914d\u7f6e\u6587\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u81ea\u5b9a\u4e49\u521b\u5efaceph\u7684\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55\r\n&#91;root@ceph01 ~]# mkdir ceph-cluster\r\n&#91;root@ceph01 ~]# cd ceph-cluster\r\n###\u521d\u59cb\u5316ceph\u7684\u914d\u7f6e\u6587\u4ef6\r\n&#91;root@ceph01 ceph-cluster]# ceph-deploy new --public-network 10.0.0.0\/24 ceph01 ceph02 ceph03\r\n\u53d1\u73b0\u62a5\u9519\u4e86\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"210\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-64.png\" alt=\"\" class=\"wp-image-1367\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-64.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-64-300x73.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-64-768x186.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>##\u89e3\u51b3\u529e\u6cd5\r\n&#91;root@ceph01 ceph-cluster]# yum -y install gcc python-setuptools python-devel\r\n\u6e29\u99a8\u63d0\u793a:\r\n\u53ef\u4ee5\u4f7f\u7528\"--cluster-network\"\u53c2\u6570\u521b\u5efa\u96c6\u7fa4\u5185\u90e8\u7684\u7f51\u7edc\uff0c\u5176\u901a\u5e38\u662f\u96c6\u7fa4\u5185\u90e8\u901a\u4fe1\u7684\u7f51\u6bb5\u3002\u800c\"--public-network\"\u53c2\u6570\u7528\u4e8e\u521b\u5efa\u96c6\u7fa4\u5916\u90e8\u7684\u7f51\u7edc\uff0c\u901a\u5e38\u662f\u5ba2\u6237\u7aef\u8bbf\u95ee\u7684\u7f51\u7edc\uff0c\u751f\u4ea7\u73af\u5883\u4e2d\u5efa\u8bae\u5206\u5f00\u914d\u7f6e\u3002\u6211\u8fd9\u91cc\u5c31\u6ca1\u6709\u4f7f\u7528\"--cluster-network\"\u53c2\u6570\uff0c\u82e5\u4e0d\u662f\u7528\u5219\u9ed8\u8ba4\u4ec5\u4f7f\u7528\u540c\u4e00\u5957\u7f51\u7edc<\/code><\/pre>\n\n\n\n<p><strong><em>6.\u5b89\u88c5ceph-monitor\u5e76\u542f\u52a8ceph-mon<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ceph01 ceph-cluster]# ceph-deploy mon create-initial<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"411\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-65.png\" alt=\"\" class=\"wp-image-1368\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-65.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-65-300x143.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-65-768x365.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p><strong><em>7.\u5c06\u914d\u7f6e\u548cclient.admin\u5bc6\u94a5\u63a8\u9001\u5230\u6307\u5b9a\u7684\u8fdc\u7a0b\u4e3b\u673a\u4ee5\u4fbf\u4e8e\u7ba1\u7406\u96c6\u7fa4<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>admin\u7528\u6237\u662fceph\u96c6\u7fa4\u81ea\u5e26\u7684\u7528\u6237\uff0c\u5c06\u7528\u6237\u63a8\u9001\u5230\u8282\u70b9\u5373\u53ef\r\n&#91;root@ceph01 ceph-cluster]# ceph-deploy admin ceph01 ceph02 ceph03\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"470\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-66.png\" alt=\"\" class=\"wp-image-1369\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-66.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-66-300x163.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-66-768x417.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p><strong><em>8.\u5b89\u88c5\u5e76\u542f\u52a8ceph-mgr\u7ec4\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ceph01 ceph-cluster]# ceph-deploy mgr create ceph01 ceph02 ceph03<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"293\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-67.png\" alt=\"\" class=\"wp-image-1370\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-67.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-67-300x102.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-67-768x260.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p><strong><em>9.\u5b89\u88c5OSD\u8bbe\u5907<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ceph01 ceph-cluster]# ceph-deploy osd create ceph01 --data \/dev\/sdb\r\n&#91;root@ceph01 ceph-cluster]# ceph-deploy osd create ceph02 --data \/dev\/sdb\r\n&#91;root@ceph01 ceph-cluster]# ceph-deploy osd create ceph03 --data \/dev\/sdb\r\n\u521b\u5efaOSD\u662f\u8981\u6ce8\u610f\u7684\u76f8\u5173\u53c2\u6570\u8bf4\u660e:\r\n--data DATA:\u6307\u5b9a\u903b\u8f91\u5377\u6216\u8005\u8bbe\u5907\u7684\u7edd\u5bf9\u8def\u5f84\u3002\r\n--journal JOURNAL:\u6307\u5b9a\u903b\u8f91\u5377\u6216\u8005GPT\u5206\u533a\u7684\u5206\u533a\u8def\u5f84\u3002\u751f\u4ea7\u73af\u5883\u5f3a\u70c8\u6307\u5b9a\u8be5\u53c2\u6570\uff0c\u5e76\u63a8\u8350\u4f7f\u7528SSD\u8bbe\u5907\u3002\u56e0\u4e3aceph\u9700\u8981\u5148\u9884\u5199\u65e5\u5fd7\u800c\u540e\u624d\u4f1a\u771f\u5b9e\u5199\u5165\u6570\u636e\uff0c\u4ece\u800c\u8fbe\u5230\u9632\u6b62\u6570\u636e\u4e22\u5931\u7684\u76ee\u7684\u3002\u82e5\u4e0d\u6307\u5b9a\u8be5\u53c2\u6570\uff0c\u5219\u65e5\u5fd7\u4f1a\u5199\u5165\"--data\"\u6307\u5b9a\u7684\u8def\u5f84\u54df\u3002\u4ece\u800c\u964d\u4f4e\u6027\u80fd\u3002\u5bf9\u4e8e\u4e00\u4e2a4T\u7684\u6570\u636e\u76d8\uff0c\u5176\u65e5\u5fd7\u5e76\u4e0d\u4f1a\u5360\u636e\u7279\u522b\u591a\u7684\u7a7a\u95f4\uff0c\u901a\u5e38\u60c5\u51b5\u4e0b\u5206\u914d50G\u8db3\u4ee5\uff0c\u5f53\u7136\uff0cLVM\u662f\u652f\u6301\u52a8\u6001\u6269\u5bb9\u7684\r\n\u7efc\u4e0a\u6240\u8ff0\u2014journal\u6307\u5b9a\u65e5\u5fd7\u76d8\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u7684\u8bdd\uff0c\u65e5\u5fd7\u76d8\u548c\u6570\u636e\u76d8\u90fd\u5728\u2014data\u6307\u5b9a\uff0c\u8fd9\u6837\u4f1a\u62c9\u4f4eceph\u7684\u6027\u80fd\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"617\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-68.png\" alt=\"\" class=\"wp-image-1371\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-68.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-68-300x214.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-68-768x548.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">3.Ceph\u5757\u5b58\u50a8\u7684\u4f7f\u7528<\/h2>\n\n\n\n<p><strong><em>1.ceph\u7684\u5b58\u50a8\u6c60\u57fa\u672c\u7ba1\u7406<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u67e5\u770b\u73b0\u6709\u7684\u6240\u6709\u8d44\u6e90\u6c60\r\n&#91;root@ceph01 ~]# ceph osd pool ls\r\n###\u521b\u5efa\u8d44\u6e90\u6c60\r\n&#91;root@ceph01 ~]# ceph osd pool create sfy-test 128 128\r\n\u8fd9\u4e2a128\u662fpg\u7684\u4e2a\u6570\uff0c\u6570\u503c\u8d8a\u5927\uff0c\u6570\u636e\u5206\u5e03\u8d8a\u5206\u6563\uff0c\u6700\u5927\u503c251\uff0c\u5e76\u4e14\u53ea\u80fd\u662f2\u7684\u500d\u6570\uff0c\u8bbe\u7f6e128\u5728\u4efb\u4f55\u573a\u666f\u4e0b\u90fd\u591f\u7528\u4e86\r\n###\u67e5\u770b\u5b58\u50a8\u6c60\u7684\u53c2\u6570\u4fe1\u606f\uff08\u8fd9\u4e2a\u503c\u53ef\u80fd\u4f1a\u4e0d\u65ad\u7684\u53d8\u5316~\u5c24\u5176\u662f\u5728\u91cd\u547d\u540d\u540e!\uff09\r\n&#91;root@ceph01 ~]# ceph osd pool get sfy-test pg_num\r\n###\u8d44\u6e90\u6c60\u7684\u91cd\u547d\u540d\r\nceph osd pool rename sfy-test sfy01\r\n###\u67e5\u770b\u8d44\u6e90\u6c60\u7684\u72b6\u6001\r\n&#91;root@ceph01 ~]# ceph osd pool stats\r\n###\u5220\u9664\u8d44\u6e90\u6c60(\u9700\u8981\u5f00\u542f\u5220\u9664\u7684\u529f\u80fd\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u54df~\u800c\u4e14\u6c60\u7684\u540d\u5b57\u5f97\u51992\u6b21!)\r\n&#91;root@ceph01 ~]# ceph osd pool rm  sfy-test sfy-test --yes-i-really-really-mean-it\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.rbd\u7684\u5757\u8bbe\u5907\uff08\u955c\u50cf\uff0cimage\uff09\u7ba1\u7406<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u67e5\u770bsfy-test\u8d44\u6e90\u6c60\u4e0b\u7684rbd\u7684\u5757\uff08\u955c\u50cf\uff0cimage\uff09\u8bbe\u5907\r\n&#91;root@ceph01 ~]# rbd list -p sfy-test\r\nrbd ls -p sfy-test --long --format json --pretty-format   #\u6307\u5b9a\u8f93\u51fa\u7684\u6837\u5f0f\r\n###\u521b\u5efarbd\u7684\u5757\u8bbe\u5907:(\u4e0b\u9762\u5199\u6cd5\u7b49\u6548\u54df)\r\nrbd create --size 1024 --pool sfy-test test.img  # \u4e0d\u6307\u5b9a\u5355\u4f4d\u9ed8\u8ba4\u4e3aM\r\nrbd create --size 1024 sfy-test\/test.img\r\nrbd create -s 2G -p sfy-test test.img  # \u4e5f\u53ef\u4ee5\u6307\u5b9a\u5355\u4f4d\uff0c\u6bd4\u5982G\r\n###\u4fee\u6539\u955c\u50cf\u8bbe\u5907\u7684\u540d\u79f0\r\n&#91;root@ceph02 ~]# rbd rename -p  sfy-test test.img test\r\n###\u67e5\u770b\u955c\u50cf\u7684\u72b6\u6001\r\n&#91;root@ceph02 ~]# rbd status -p sfy-test test\r\n###\u79fb\u9664\u955c\u50cf\u6587\u4ef6\r\n&#91;root@ceph02 ~]# rbd remove -p sfy-test test\r\n###\u67e5\u770brbd\u7684\u8be6\u7ec6\u4fe1\u606f\r\n&#91;root@ceph02 ~]# rbd info -p sfy-test test.img\r<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u6302\u8f7drbd\u7684\u5757\u8bbe\u5907<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u6dfb\u52a0\u6620\u5c04\u5173\u7cfb\r\n&#91;root@ceph01 ~]# rbd map sfy-test\/test.img\r\n\u4f46\u662f\u63d0\u793a\u5185\u6838\u4e0d\u652f\u6301\uff0c\u9700\u8981\u6309\u7167\u63d0\u793a\u7981\u7528\u4e00\u4e9b\u6838\u5fc3\u7279\u6027\uff0c\u8fd9\u662f\u56e0\u4e3acentos7\u7684\u5185\u6838\u7248\u672c\u592a\u8001\u4e86\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"117\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-69.png\" alt=\"\" class=\"wp-image-1374\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-69.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-69-300x41.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-69-768x104.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u7981\u7528\u4e0d\u652f\u6301\u7684\u6838\u5fc3\u7279\u6027\u5e76\u91cd\u65b0\u6dfb\u52a0\u6620\u5c04\u5173\u7cfb\r\n&#91;root@ceph01 ~]# rbd feature disable sfy-test\/test.img object-map fast-diff deep-flatten\r\n###\u683c\u5f0f\u5316\u78c1\u76d8\u5e76\u6302\u8f7d\u78c1\u76d8\r\n&#91;root@ceph01 ~]# mkfs.xfs \/dev\/rbd0\r\n&#91;root@ceph01 ~]# mount \/dev\/rbd0 \/mnt\/\r\n\u5982\u4e0b\u56fe\u53ef\u4ee5\u770b\u5230\u5df2\u7ecf\u6302\u8f7d\u6210\u529f\u4e86\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"460\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-70.png\" alt=\"\" class=\"wp-image-1375\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-70.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-70-300x160.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-70-768x408.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p><strong><em>4.\u4f7f\u7528rbd\u5757\u8bbe\u5907<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@ceph01 ~]# cd \/mnt\/\r\n###\u67e5\u770b\u5757\u8bbe\u5907\u4fe1\u606f\r\n&#91;root@ceph01 mnt]# rbd info -p sfy-test test.img | grep block\r\n###\u67e5\u770b\u5b58\u50a8\u7684object\u5bf9\u8c61\r\n&#91;root@ceph01 mnt]# rados ls -p sfy-test | grep \"rbd_data.5f756fec4f9e\"\r\n###\u521b\u5efa\u6d4b\u8bd5\u6587\u4ef6\r\n&#91;root@ceph01 mnt]# dd if=\/dev\/zero of=\/mnt\/bigfile.log bs=100M count=1\r\n\u5982\u4e0b\u56fe\uff0c\u5199\u5165\u7684\u6570\u636e\u88ab\u5206\u6210\u4e86\u591a\u4e2a\u5bf9\u8c61\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"746\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-71.png\" alt=\"\" class=\"wp-image-1376\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-71.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-71-300x259.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-71-768x662.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>###ceph02\u8282\u70b9\u6302\u8f7d\u8bbe\u5907\u4f7f\u7528\r\n&#91;root@ceph02 ~]# rbd map sfy-test\/test.img\r\n&#91;root@ceph02 ~]# mount \/dev\/rbd\r\n&#91;root@ceph02 ~]# cd \/mnt\/\r\n###\u6b64\u65f6\u518d\u5728ceph02\u4e0a\u521b\u5efa\u6570\u636e\r\n&#91;root@ceph02 mnt]# dd if=\/dev\/zero of=\/mnt\/bigfile2.log bs=100M count=1\r\n\u5982\u4e0b\u56fe\uff0c\u4e00\u4e2arbd\u96c6\u7fa4\u7684\u540c\u4e00\u4e2aimage\u8bbe\u5907\u53ef\u4ee5\u6302\u8f7d\u5230\u4e0d\u540c\u7684\u8282\u70b9\u4e0a;\u4f46\u540c\u4e00\u4e2aimage\u8bbe\u5907\u5728\u4e0d\u540c\u7684\u8282\u70b9\u4e0a\u65e0\u6cd5\u5b9e\u73b0\u7684\u6570\u636e\u7684\u540c\u6b65\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"210\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-72.png\" alt=\"\" class=\"wp-image-1377\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-72.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-72-300x73.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-72-768x186.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p><strong><em>5.\u6269\u5bb9rbd\u5757\u8bbe\u5907<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>##\u81ea\u52a8\u6269\u7f29\u5bb9\u78c1\u76d8\u5927\u5c0f:(\u6269\u5bb9\u6b63\u5e38\uff0c\u7f29\u5bb9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8bbe\u5907\u4e0d\u53ef\u7528!\u9700\u8981\u8fdb\u4e00\u6b65\u8c03\u7814\uff0c\u751f\u4ea7\u73af\u5883\u8981\u5145\u5206\u6d4b\u8bd5\u65b9\u80fd\u4f7f\u7528!)\r\nrbd resize --size 4096 sfy-test\/test.img\r\nrbd resize -s 1G sfy-test\/test.img --allow-shrink  # \u614e\u7528\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8bbe\u5907\u4e0d\u53ef\u7528!\r\n\u81ea\u52a8\u6269\u5c55XFS\u6587\u4ef6\u7cfb\u7edf\u5230\u6700\u5927\u7684\u53ef\u7528\u5927\u5c0f:xfs_growfs \/mnt\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">4.ceph\u589e\u52a0osd\u8282\u70b9<\/h2>\n\n\n\n<p><strong><em>1.\u6dfb\u52a0osd\u7684\u51c6\u5907\u6761\u4ef6<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4e3a\u4ec0\u4e48\u8981\u6dfb\u52a0OSD\uff1f\r\n\u56e0\u4e3a\u968f\u7740\u6211\u4eec\u5bf9ceph\u96c6\u7fa4\u7684\u4f7f\u7528\uff0c\u8d44\u6e90\u53ef\u80fd\u4f1a\u88ab\u6d88\u8017\u6b86\u5c3d\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u5f97\u60f3\u6cd5\u6269\u5bb9\u96c6\u7fa4\u8d44\u6e90\uff0c\u5bf9\u4e8eceph\u5b58\u50a8\u8d44\u6e90\u7684\u6269\u5bb9\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6dfb\u52a0\u76f8\u5e94\u7684OSD\u8282\u70b9\u5373\u53ef\u3002\r\n\u6dfb\u52a0OSD\u7684\u51c6\u5907\u6761\u4ef6:\r\n\u6211\u4eec\u9700\u8981\u5355\u72ec\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u8282\u70b9\u5e76\u4e3a\u5176\u591a\u6dfb\u52a0\u4e00\u5757\u78c1\u76d8\r<\/code><\/pre>\n\n\n\n<p><em><strong>2.\u65b0\u589e\u8282\u70b9\u914d\u7f6e\u89e3\u6790\u8bb0\u5f55\u5e76\u914d\u7f6e\u514d\u5bc6\u7801\u767b\u5f55<\/strong><\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/hosts\r\n127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4\r\n::1         localhost localhost.localdomain localhost6 localhost6.localdomain6\r\n10.0.0.14 ceph01\r\n10.0.0.15 ceph02\r\n10.0.0.16 ceph03\r\n10.0.0.17 ceph04\r\n&#91;root@ceph01 ~]# scp -rp .ssh\/ ceph04:\/root\/\r<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u65b0\u589e\u8282\u70b9\u90e8\u7f72ceph\u8f6f\u4ef6\u5305<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u914d\u7f6e\u6848\u4f8b\u7684\u8f6f\u4ef6\u6e90\r\ncurl -o \/etc\/yum.repos.d\/epel.repo http:\/\/mirrors.aliyun.com\/repo\/epel-7.repo\r\n###\u5c06ceph01\u7684yum\u4ed3\u5e93\u914d\u7f6e\u6587\u4ef6\u62f7\u8d1d\u5230ceph04\r\nscp \/etc\/yum.repos.d\/ceph.repo ceph204:\/etc\/yum.repos.d\/\r\n###ceph04\u8282\u70b9\u53ea\u9700\u5b89\u88c5osd\u76f8\u5173\u7684\u7ec4\u4ef6\u5373\u53ef\uff0c\u56e0\u4e3a\u5b83\u5e76\u4e0d\u4f5c\u4e3a\u7ba1\u7406\u8282\u70b9\uff0c\u800c\u662f\u4f5c\u4e3a\u5b58\u50a8\u8282\u70b9\u54df\u3002\r\nyum -y install ceph-osd\r\nsystemctl stop firewalld &amp;&amp; systemctl disable firewalld  # \u7981\u7528\u9632\u706b\u5899\u529f\u80fd\u3002\r\n###\u5728ceph\u8282\u70b9\u5b89\u88c5\u4ee5\u4e0b\u7684\u8f6f\u4ef6\u5305\uff0c\u5426\u5219\u65e0\u6cd5\u6dfb\u52a0\u8282\u70b9\u3002\r\n     python36-PyYAML-3.13-1.el7.x86_64.rpm  \r\n     python36-six-1.14.0-3.el7.noarch.rpm  \r\n     # python-six-1.9.0-2.el7.noarch.rpm  # \u8be5\u6a21\u5757\u53ef\u4ee5\u4e0d\u9009\u62e9\u5b89\u88c5\u54c8\uff01\r<\/code><\/pre>\n\n\n\n<p><strong><em>4.\u5728ceph01\u7ba1\u7406\u8282\u70b9\u6dfb\u52a0\u65b0\u589e\u8282\u70b9\u7684OSD<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/root\/ceph\/cluster\r\nceph-deploy osd create ceph04 --data \/dev\/sdb\r\nps:\u5f53\u6211\u4eec\u6dfb\u52a0OSD\u65f6\u4f1a\u81ea\u52a8\u8fdb\u884c\u6570\u636e\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u56e0\u6b64\u5efa\u8bae\u5927\u5bb6\u5982\u679c\u771f\u9700\u8981\u6269\u5bb9\u65f6\u53ef\u4ee5\u8003\u8651\u5728\u4e1a\u52a1\u7684\u4f4e\u8c37\u671f\u8fdb\u884c\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">5.\u4f7f\u7528ceph\u5bf9\u63a5kubernetes<\/h2>\n\n\n\n<p><strong><em>1.\u5728K8S\u96c6\u7fa4\u4e2d\u5b89\u88c5ceph\u7684\u57fa\u7840\u5305\u73af\u5883<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u5c06ceph\u8f6f\u4ef6\u6e90\uff0cepel\u7684\u8f6f\u4ef6\u6e90\u62f7\u8d1d\u5230k8s\u7684master\u8282\u70b9\r\n&#91;root@ceph01 yum.repos.d]#  scp ceph.repo  epel.repo 10.0.0.12:`pwd`\r\n###\u5b89\u88c5ceph\u7684\u57fa\u7840\u5305\r\n&#91;root@k8s-node-1 ~]# yum -y install ceph-common\r\n&#91;root@k8s-node-2 ~]# yum -y install ceph-common\r\n\u53c2\u8003\u8fde\u63a5:\r\n\thttps:&#47;&#47;kubernetes.io\/docs\/concepts\/storage\/volumes\/#rbd\r\n\thttps:\/\/github.com\/kubernetes\/examples\/tree\/master\/volumes\/rbd\r<\/code><\/pre>\n\n\n\n<p><strong><em>2.\u521b\u5efasercet\u8d44\u6e90\u4f7f\u7528Ceph\u8eab\u4efd\u9a8c\u8bc1\u5bc6\u94a5<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u5982\u679c\u63d0\u4f9b\u4e86Ceph\u8eab\u4efd\u9a8c\u8bc1\u5bc6\u94a5\uff0c\u5219\u8be5\u5bc6\u94a5\u5e94\u9996\u5148\u8fdb\u884cbase64\u7f16\u7801\uff0c\u7136\u540e\u5c06\u7f16\u7801\u540e\u7684\u5b57\u7b26\u4e32\u653e\u5165\u5bc6\u94a5yaml\u4e2d\r\n&#91;root@ceph01 yum.repos.d]# grep key \/etc\/ceph\/ceph.client.admin.keyring |awk '{printf \"%s\", $NF}'|base64\r\nQVFDZmJGWmk1RHV2SWhBQUJlcXh4b2RpdXBtSW9RRFNFeEtCaWc9PQ==\r\n###\u521b\u5efaSecret\u8d44\u6e90\uff0c\u6ce8\u610f\u66ff\u6362key\u7684\u503c\uff0c\u8981\u548cceph\u96c6\u7fa4\u7684key\u4fdd\u6301\u4e00\u81f4\u54df\uff0c\u4e0a\u4e00\u6b65\u6211\u5df2\u7ecf\u53d6\u51fa\u6765\u4e86\r\n&#91;root@k8s-master ceph-chijiuhua]# cat ceph-secret.yaml\r\napiVersion: v1\r\nkind: Secret\r\nmetadata:\r\n  name: ceph-secret\r\ntype: \"kubernetes.io\/rbd\"\r\ndata:\r\n  key: QVFDZmJGWmk1RHV2SWhBQUJlcXh4b2RpdXBtSW9RRFNFeEtCaWc9PQo=\r\n###\u5728K8S\u96c6\u7fa4\u4e2d\u521b\u5efaSecret\u8d44\u6e90\uff0c\u4ee5\u4fbf\u4e8e\u540e\u671fPod\u4f7f\u7528\u8be5\u8d44\u6e90\r\n&#91;root@k8s-master ceph-chijiuhua]# kubectl apply -f ceph-secret.yaml\r\n\u53c2\u8003\u8fde\u63a5:\r\nhttps:&#47;&#47;github.com\/kubernetes\/examples\/blob\/master\/volumes\/rbd\/secret\/ceph-secret.yaml\r<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u521b\u5efak8s\u4e13\u7528\u5b58\u50a8\u6c60\u53camysql\u4e13\u7528\u5757\u8bbe\u5907<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u521b\u5efa\u5b58\u50a8\u6c60\r\n&#91;root@ceph01 yum.repos.d]# ceph osd pool create k8s 128 128\r\n###\u521b\u5efa\u5757\u8bbe\u5907\r\n\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u8be5\u955c\u50cf\u7684\u7279\u6027\uff0c\u5426\u5219\u7531\u4e8e\u5185\u6838\u7248\u672c\u8fc7\u4f4e\u800c\u65e0\u6cd5\u6302\u8f7d\u54df\r\n&#91;root@ceph01 yum.repos.d]# rbd create -p k8s --size 1024 --image-feature layering k8s-mysql\r<\/code><\/pre>\n\n\n\n<p><strong><em>4.\u521b\u5efayaml\u6587\u4ef6\u5bf9\u63a5ceph\u5757\u8bbe\u5907<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@k8s-master ceph-chijiuhua]# cat deploy-pvc.yaml \r\napiVersion: extensions\/v1beta1\r\nkind: Deployment\r\nmetadata:\r\n  name: mysql\r\nspec:\r\n  replicas: 1\r\n  template:\r\n    metadata:\r\n      labels:\r\n        app: mysql\r\n    spec:\r\n      volumes:\r\n      - name: rbdpd\r\n        rbd: ###\u6307\u5b9a\u6301\u4e45\u5316\u7c7b\u578b\u4e3arbd\r\n          monitors:  ###\u6307\u5b9amon\u8282\u70b9ip\r\n          - '10.0.0.14:6789'\r\n          - '10.0.0.15:6789'\r\n          - '10.0.0.16:6789'\r\n          pool: k8s  ###\u6307\u5b9a\u5b58\u50a8\u6c60\u540d\u5b57,\u8fd9\u4e2a\u540d\u5b57\u5fc5\u987b\u5b58\u5728\r\n          image: k8s-mysql ###\u6307\u5b9a\u5757\u8bbe\u5907\uff0c\u8fd9\u4e2a\u4e5f\u5fc5\u987b\u5b58\u5728\r\n          fsType: xfs ###\u6307\u5b9a\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\r\n          readOnly: false ###\u662f\u5426\u53ea\u8bfb\r\n          user: admin  ###ceph\u96c6\u7fa4\u7ba1\u7406\u7528\u6237\r\n          secretRef: ###\u6307\u5b9asecret\u8d44\u6e90\u540d\u79f0\r\n            name: ceph-secret ###\u9700\u8981\u4f7f\u7528\u7684secret\u8d44\u6e90\u540d\u5b57\r\n        #  imageformat: \"2\" \u683c\u5f0f\r\n        #  imagefeatures: \"layering\" \u6307\u5b9a\u5757\u8bbe\u5907\u7279\u6027\r\n      containers:\r\n      - name: mysql\r\n        volumeMounts:\r\n        - name: rbdpd  # \u6ce8\u610f\u54c8\uff0c\u8be5\u540d\u79f0\u5fc5\u987b\u5728\u4e0a\u9762\u7684\"volumes\"\u7684name\u5b57\u6bb5\u4e2d\u5b58\u5728\u54df~\r\n          mountPath: \/var\/lib\/mysql  # \u6307\u5b9a\u6302\u8f7d\u5230\u5bb9\u5668\u7684\u4f4d\u7f6e\r\n        image: k8s-master:5000\/mysql:5.7\r\n        ports:\r\n        - containerPort: 3306\r\n        env:\r\n        - name: MYSQL_ROOT_PASSWORD\r\n          value: somewordpress\r\n        - name: MYSQL_DATABASE\r\n          value: wordpress\r\n        - name: MYSQL_USER\r\n          value: wordpress\r\n        - name: MYSQL_PASSWORD\r\n          value: wordpress\r\n---\r\n\r\napiVersion: v1\r\nkind: Service   #\u7b80\u79f0svc\r\nmetadata:\r\n  name: musql-svc\r\n  namespace: kube-system\r\nspec:\r\n  clusterIP: 10.254.86.101\r\n  type: ClusterIP\r\n  ports:\r\n    - port: 3306\r\n      targetPort: 3306    #pod port\r\n  selector:\r\n    app: mysql\r\n\r\n---\r\napiVersion: extensions\/v1beta1\r\nkind: Deployment\r\nmetadata:\r\n  name: wordpress\r\nspec:\r\n  replicas: 1\r\n  template:\r\n    metadata:\r\n      labels:\r\n        app: wordpress\r\n    spec:\r\n      containers:\r\n      - name: wordpress\r\n        image: k8s-master:5000\/wordpress:latest\r\n        ports:\r\n        - containerPort: 80\r\n        env:\r\n        - name: WORDPRESS_DB_HOST\r\n          value: musql-svc.kube-system.svc.cluster.local\r\n        - name: WORDPRESS_DB_USER\r\n          value: wordpress\r\n        - name: WORDPRESS_DB_PASSWORD\r\n          value: wordpress\r\n---\r\n\r\napiVersion: v1\r\nkind: Service   #\u7b80\u79f0svc\r\nmetadata:\r\n  name: wordpress-svc\r\nspec: \r\n  type: NodePort\r\n  ports:\r\n    - port: 80\r\n      nodePort: 31001\r\n      targetPort: 80   #pod port\r\n  selector:\r\n    app: wordpress\r\n&#91;root@k8s-master ceph-chijiuhua]# kubectl apply -f deploy-pvc.yaml\r<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"329\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-73.png\" alt=\"\" class=\"wp-image-1382\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-73.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-73-300x114.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/04\/image-73-768x292.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":246,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/1362"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1362"}],"version-history":[{"count":6,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/1362\/revisions"}],"predecessor-version":[{"id":1383,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/1362\/revisions\/1383"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/media\/246"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}