ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

cephfs挂载+nfs+nginx

2021-11-28 20:34:18  阅读:191  来源: 互联网

标签:192.168 ceph nginx client nfs key cephfs root


#创建cephfs pool

cephadmin@ceph-deploy:~/ceph-cluster$ ceph osd pool ls
device_health_metrics
cephfs-metadata
cephfs-data
cephadmin@ceph-deploy:~/ceph-cluster$ sudo ceph auth add client.user1 mon 'allow r' mds "allow rw" osd "allow rwx pool=cephfs-data"
added key for client.user1
cephadmin@ceph-deploy:~/ceph-cluster$ sudo ceph auth get client.user1
cephadmin@ceph-deploy:~/ceph-cluster$ ceph-authtool --create-keyring ceph.client.user1.keyring
cephadmin@ceph-deploy:~/ceph-cluster$ ceph auth get client.user1 -o ceph.client.user1.keyring
cephadmin@ceph-deploy:~/ceph-cluster$ ceph auth print-key client.user1
[root@centos8-client yum.repos.d]# sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
>          -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \
>          -i.bak \
>          /etc/yum.repos.d/CentOS-*.repo
[root@centos8-client yum.repos.d]# sudo yum makecache
https://mirrors.aliyun.com/ceph/rpm-octopus/el7/noarch/ceph-release-1-1.el7.noarch.rpm
centos8
[root@centos8-client yum.repos.d]# yum install epel-release
https://mirrors.aliyun.com/ceph/rpm-pacific/el8/noarch/ceph-release-1-1.el8.noarch.rpm
yum install ceph-common
cephadmin@ceph-deploy:~/ceph-cluster$ scp ceph.conf ceph.client.user1.keyring client.user1 root@192.168.192.129:/etc/ceph
[root@centos8-client ~]# ceph --user user1 -s

 

客户端挂载有两种方式,一是内核空间一是用户空间,内核空间挂载需要内核支持ceph 模块,用户空间挂载需要安装ceph-fuse。

admin

1,通过key文件挂载

cephadmin@ceph-deploy:~/ceph-cluster$ ceph auth print-key client.admin > admin.key
cephadmin@ceph-deploy:~/ceph-cluster$ scp admin.key root@192.168.192.129:/etc/ceph
[root@centos8-client cephfs-key]# mount -t ceph 192.168.192.172:6789:/ /cephfs-key -o name=admin,secretfile=/etc/ceph/admin.key
[root@centos8-client ~]# cat /etc/fstab |grep tfile
192.168.192.172:6789:/ /cephfs-key ceph defaults,name=admin,secretfile=/etc/ceph/admin.key,_netdev 0 0

2,通过secret挂载

cephadmin@ceph-deploy:~/ceph-cluster$ sudo cat ceph.client.admin.keyring 
[client.admin]
    key = AQAbJYZhP4W7FhAA4kO07jQVT1DnlSpl8u4q9A==
    caps mds = "allow *"
    caps mgr = "allow *"
    caps mon = "allow *"
    caps osd = "allow *"
[root@centos8-client ceph]# mount -t ceph 192.168.192.172:6789:/ /cephfs-key -o name=admin,secret=AQAbJYZhP4W7FhAA4kO07jQVT1DnlSpl8u4q9A==
[root@centos8-client ceph]# df -hT
192.168.192.172:6789:/ ceph      143G     0  143G    0% /cephfs-key
yum insttall nginx
vi /etc/nginx/nginx.conf
   server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /cephfs-key;
http://192.168.192.129/aa.jpg
[root@centos8-client ~]# cat /etc/fstab  |grep ceph
192.168.192.172:6789:/ /cephfs-key ceph defaults,name=admin,secret=AQAbJYZhP4W7FhAA4kO07jQVT1DnlSpl8u4q9A==,_netdev 0 0

 

[root@centos8-client ~]# showmount -e
Export list for centos8-client:
/cephfs-key 192.168.192.0/24
[root@centos8-client ~]# cat /etc/exports
/cephfs-key 192.168.192.0/24(rw,sync,no_root_squash)
服务端
yum install -y nfs-utils rpcbind
systemctl enable nfs-server.service rpcbind #客户端 yum install -y nfs-utils
systemctl enable nfs [root@centos8-client nginx]# pwd #创建多个服务目录共享 /cephfs-key/nginx [root@centos8-client nginx]# ls bb.jpg
#130挂载129 129挂载ceph集群
[root@centos7-client ~]# showmount -e 192.168.192.129
Export list for 192.168.192.129:
/cephfs-key 192.168.192.0/24
[root@centos7-client ~]# mount -t nfs 192.168.192.129:/cephfs-key/nginx /usr/share/nginx/html
[root@centos7-client ~]# df -hT |grep nfs
192.168.192.129:/cephfs-key/nginx nfs4      143G     0  143G    0% /usr/share/nginx/html

 普通用户

key文件

cephadmin@ceph-deploy:~/ceph-cluster$ scp ceph.conf ge.key ceph.client.ge.keyring root@192.168.192.129:/etc/ceph
[root@centos8-client ~]# ceph --user ge -s
cephadmin@ceph-deploy:~/ceph-cluster$ ceph auth add client.ge mon 'allow r' mds 'allow rw' osd 'allow rwx pool=cephfs-data'
added key for client.ge
cephadmin@ceph-deploy:~/ceph-cluster$ ceph auth get client.ge
[client.ge]
    key = AQBSN41hm0yZLhAAQDH7WVlXeW7Ab5PfJhHcFQ==
    caps mds = "allow rw"
    caps mon = "allow r"
    caps osd = "allow rwx pool=cephfs-data"
cephadmin@ceph-deploy:~/ceph-cluster$ ceph auth get client.ge -o ceph.client.ge.keyring 
exported keyring for client.ge
cephadmin@ceph-deploy:~/ceph-cluster$ ceph auth print-key client.ge > ge.key
[root@centos8-client ~]# mount -t ceph 192.168.192.172:6789:/ /cephfs-key -o name=ge,secretfile=/etc/ceph/ge.key
/etc/fstab
192.168.192.172:6789:/ /cephfs-key ceph defaults,name=ge,secretfile=/etc/ceph/ge.key,_netdev 0 0
/etc/fstab
192.168.192.129:/cephfs-key/nginx /usr/share/nginx/html nfs defaults        0 0
[root@client7 ~]# df -hT |grep nginx
192.168.192.129:/cephfs-key/nginx nfs4      143G     0  143G   0% /usr/share/nginx/html

secret

mount -t ceph 192.168.192.172:6789:/ /cephfs-key -o name=ge,secret=AQBSN41hm0yZLhAAQDH7WVlXeW7Ab5PfJhHcFQ==
192.168.192.172:6789:/ /cephfs-key ceph defaults,name=ge,secret=AQBSN41hm0yZLhAAQDH7WVlXeW7Ab5PfJhHcFQ==,_netdev 0 0
192.168.192.129:/cephfs-key/nginx /usr/share/nginx/html nfs defaults        0 0

 

标签:192.168,ceph,nginx,client,nfs,key,cephfs,root
来源: https://www.cnblogs.com/gxc888/p/15531755.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有