Nginx教程

cephfs挂载+nfs+nginx

本文主要是介绍cephfs挂载+nfs+nginx,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

#创建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

 

这篇关于cephfs挂载+nfs+nginx的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!