设为首页 收藏本站
查看: 1390|回复: 0

[经验分享] Linux与云计算——第二阶段 第五章:存储Storage服务器架设—分布式存储Ceph

[复制链接]

尚未签到

发表于 2019-2-2 10:57:33 | 显示全部楼层 |阅读模式
Linux与云计算——第二阶段Linux服务器架设

第五章:存储Storage服务器架设—分布式存储Ceph

1 Ceph 配置Ceph集群
Install Distributed File System "Ceph" to Configure Storage Cluster.
For example on here, Configure Cluster with 1 admin Node and 3 Storage Node like follows.
                                |
        +--------------------+           |           +-------------------+
        |   [dlp.srv.world]  |10.0.0.30  |   10.0.0.x|   [   Client  ]   |
        |    Ceph-Deploy     +-----------+-----------+                   |
        |                    |           |           |                   |
        +--------------------+           |           +-------------------+
            +----------------------------+----------------------------+
            |                            |                            |
            |10.0.0.51                   |10.0.0.52                   |10.0.0.53
+-----------+-----------+    +-----------+-----------+    +-----------+-----------+
|   [node01.srv.world]  |    |  [node02.srv.world]   |    |   [node03.srv.world]  |
|     Object Storage    +----+     Object Storage    +----+     Object Storage    |
|     Monitor Daemon    |    |                       |    |                       |
|                       |    |                       |    |                       |
+-----------------------+    +-----------------------+    +-----------------------+
[1] Add a user for Ceph admin on all Nodes.
It adds "cent" user on this exmaple.
[2] Grant root priviledge to Ceph admin user just added above with sudo settings.
And also install required packages.
Furthermore, If Firewalld is running on all Nodes, allow SSH service.
Set all of above on all Nodes.
[root@dlp ~]# echo -e 'Defaults:cent !requiretty\ncent ALL = (root) NOPASSWD:ALL' | tee /etc/sudoers.d/ceph
[root@dlp ~]# chmod 440 /etc/sudoers.d/ceph
[root@dlp ~]# yum -y install centos-release-ceph-hammer epel-release yum-plugin-priorities
[root@dlp ~]# sed -i -e "s/enabled=1/enabled=1\npriority=1/g" /etc/yum.repos.d/CentOS-Ceph-Hammer.repo
[root@dlp ~]# firewall-cmd --add-service=ssh --permanent
[root@dlp ~]# firewall-cmd –reload
[3] On Monitor Node (Monitor Daemon), If Firewalld is running, allow required port.
[root@dlp ~]# firewall-cmd --add-port=6789/tcp --permanent
[root@dlp ~]# firewall-cmd –reload
[4] On Storage Nodes (Object Storage), If Firewalld is running, allow required ports.
[root@dlp ~]# firewall-cmd --add-port=6800-7100/tcp --permanent
[root@dlp ~]# firewall-cmd –reload
[4] Login as a Ceph admin user and configure Ceph.
Set SSH key-pair from Ceph Admin Node (it's "dlp.srv.world" on this example) to all storage Nodes.
[cent@dlp ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/cent/.ssh/id_rsa):
Created directory '/home/cent/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/cent/.ssh/id_rsa.
Your public key has been saved in /home/cent/.ssh/id_rsa.pub.
The key fingerprint is:
54:c3:12:0e:d3:65:11:49:11:73:35:1b:e3:e8:63:5a cent@dlp.srv.world
The key's randomart image is:

[cent@dlp ~]$ vi ~/.ssh/config
# create new ( define all nodes and users )
Host dlp
    Hostname dlp.srv.world
    User cent
Host node01
    Hostname node01.srv.world
    User cent
Host node02
    Hostname node02.srv.world
    User cent
Host node03
    Hostname node03.srv.world
    User cent

[cent@dlp ~]$ chmod 600 ~/.ssh/config
# transfer key file
[cent@dlp ~]$ ssh-copy-id node01
cent@node01.srv.world's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'node01'"
and check to make sure that only the key(s) you wanted were added.

[cent@dlp ~]$ ssh-copy-id node02
[cent@dlp ~]$ ssh-copy-id node03
[5] Install Ceph to all Nodes from Admin Node.
[cent@dlp ~]$ sudo yum -y install ceph-deploy
[cent@dlp ~]$ mkdir ceph
[cent@dlp ~]$ cd ceph
[cent@dlp ceph]$ ceph-deploy new node01
[cent@dlp ceph]$ vi ./ceph.conf
# add to the end
osd pool default size = 2
# Install Ceph on each Node
[cent@dlp ceph]$ ceph-deploy install dlp node01 node02 node03
# settings for monitoring and keys
[cent@dlp ceph]$ ceph-deploy mon create-initial
[6] Configure Ceph Cluster from Admin Node.
Beforeit, Create a directory /storage01 on Node01, /storage02 on Node02, /storage03 on node03 on this example.
# prepare Object Storage Daemon
[cent@dlp ceph]$ ceph-deploy osd prepare node01:/storage01 node02:/storage02 node03:/storage03
# activate Object Storage Daemon
[cent@dlp ceph]$ ceph-deploy osd activate node01:/storage01 node02:/storage02 node03:/storage03
# transfer config files
[cent@dlp ceph]$ ceph-deploy admin dlp node01 node02 node03
[cent@dlp ceph]$ sudo chmod 644 /etc/ceph/ceph.client.admin.keyring
# show status (display like follows if no ploblem)
[cent@dlp ceph]$ ceph health
HEALTH_OK
[7] By the way, if you'd like to clean settings and re-configure again, do like follows.
# remove packages
[cent@dlp ceph]$ ceph-deploy purge dlp node01 node02 node03
# remove settings
[cent@dlp ceph]$ ceph-deploy purgedata dlp node01 node02 node03
[cent@dlp ceph]$ ceph-deploy forgetkeys
2 作为Block设备使用
Configure Clients to use Ceph Storage like follows.
                                         |
        +--------------------+           |           +-------------------+
        |   [dlp.srv.world]  |10.0.0.30  |   10.0.0.x|   [   Client  ]   |
        |    Ceph-Deploy     +-----------+-----------+                   |
        |                    |           |           |                   |
        +--------------------+           |           +-------------------+
            +----------------------------+----------------------------+
            |                            |                            |
            |10.0.0.51                   |10.0.0.52                   |10.0.0.53
+-----------+-----------+    +-----------+-----------+    +-----------+-----------+
|   [node01.srv.world]  |    |   [node02.srv.world]  |    |   [node03.srv.world]  |
|     Object Storage    +----+     Object Storage    +----+     Object Storage    |
|     Monitor Daemon    |    |                       |    |                       |
|                       |    |                       |    |                       |
+-----------------------+    +-----------------------+    +-----------------------+  
For exmaple, Create a block device and mount it on a Client.
[1] First, Configure Sudo and SSH key-pair for a user on a Client and next, Install Ceph from Ceph admin Node like follows.
[cent@dlp ceph]$ ceph-deploy install client
[cent@dlp ceph]$ ceph-deploy admin client
[2] Create a Block device and mount it on a Client.
[cent@client ~]$ sudo chmod 644 /etc/ceph/ceph.client.admin.keyring
# create a disk with 10G
[cent@client ~]$ rbd create disk01 --size 10240
# show list
[cent@client ~]$ rbd ls -l
NAME     SIZE PARENT FMT PROT LOCK
disk01 10240M          2

# map the image to device
[cent@client ~]$ sudo rbd map disk01
/dev/rbd0
# show mapping
[cent@client ~]$ rbd showmapped
id pool image  snap device
0  rbd  disk01 -    /dev/rbd0

# format with XFS
[cent@client ~]$ sudo mkfs.xfs /dev/rbd0
# mount device
[cent@client ~]$ sudo mount /dev/rbd0 /mnt
[cent@client ~]$ df -hT
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        27G  1.3G   26G   5% /
devtmpfs                devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                   tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                   tmpfs     2.0G  8.4M  2.0G   1% /run
tmpfs                   tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda1               xfs       497M  151M  347M  31% /boot
/dev/rbd0               xfs        10G   33M   10G   1% /mnt
3 作为文件系统使用
Configure Clients to use Ceph Storage like follows.
                                         |
        +--------------------+           |           +-------------------+
        |   [dlp.srv.world]  |10.0.0.30  |   10.0.0.x|   [   Client  ]   |
        |    Ceph-Deploy     +-----------+-----------+                   |
        |                    |           |           |                   |
        +--------------------+           |           +-------------------+
            +----------------------------+----------------------------+
            |                            |                            |
            |10.0.0.51                   |10.0.0.52                   |10.0.0.53
+-----------+-----------+    +-----------+-----------+    +-----------+-----------+
|   [node01.srv.world]  |    |   [node02.srv.world]  |    |   [node03.srv.world]  |
|     Object Storage    +----+     Object Storage    +----+     Object Storage    |
|     Monitor Daemon    |    |                       |    |                       |
|                       |    |                       |    |                       |
+-----------------------+    +-----------------------+    +-----------------------+
For example, mount as Filesystem on a Client.
[1] Create MDS (MetaData Server) on a Node which you'd like to set MDS. It sets to node01 on this exmaple.
[cent@dlp ceph]$ ceph-deploy mds create node01
[2] Create at least 2 RADOS pools on MDS Node and activate MetaData Server.
For pg_num which is specified at the end of a creating command, refer to official document and decide appropriate value.
http://docs.ceph.com/docs/master/rados/operations/placement-groups/
[cent@node01 ~]$ sudo chmod 644 /etc/ceph/ceph.client.admin.keyring
# create pools
[cent@node01 ~]$ ceph osd pool create cephfs_data 128
pool 'cephfs_data' created
[cent@node01 ~]$ ceph osd pool create cephfs_metadata 128
pool 'cephfs_metadata' created
# enable pools
[cent@node01 ~]$ ceph fs new cephfs cephfs_metadata cephfs_data
new fs with metadata pool 2 and data pool 1
# show list
[cent@node01 ~]$ ceph fs ls
name: cephfs, metadata pool: cephfs_metadata, data pools: [cephfs_data ]
[cent@node01 ~]$ ceph mds stat
e5: 1/1/1 up {0=node01=up:active}
[3] Mount CephFS on a Client.
[root@client ~]# yum -y install ceph-fuse
# get admin key
[root@client ~]# ssh cent@node01.srv.world "sudo ceph-authtool -p /etc/ceph/ceph.client.admin.keyring" > admin.key
cent@node01.srv.world's password:
[root@client ~]# chmod 600 admin.key
[root@client ~]# mount -t ceph node01.srv.world:6789:/ /mnt -o name=admin,secretfile=admin.key
[root@client ~]# df -hT
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        27G  1.3G   26G   5% /
devtmpfs                devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                   tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                   tmpfs     2.0G  8.3M  2.0G   1% /run
tmpfs                   tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda1               xfs       497M  151M  347M  31% /boot
10.0.0.51:6789:/        ceph       80G   19G   61G  24% /mnt



详细视频课程请戳—→ http://edu.运维网.com/course/course_id-6574.html








运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-670796-1-1.html 上篇帖子: 免费开源的服务器虚拟化Proxmox+分布式存储Ceph(二) 下篇帖子: vagrant 脚本
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表