小白成长之路-centos7部署ceph存储

发布于:2025-09-11 ⋅ 阅读:(23) ⋅ 点赞:(0)

一、准备

5台centos7主机 

node节点双网卡

(1个内部检测,1个外部使用)

node节点都添加新网卡


关闭防火墙和上下文

都需要

添加hosts文件

都需要


 
  1. cat > /etc/hosts << EOF
  2. > 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. > ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. > 192.168.11.200 admin
  5. > 192.168.11.201 node01
  6. > 192.168.11.202 node02
  7. > 192.168.11.203 node03
  8. > 192.168.11.204 client
  9. > EOF
AI运行代码

admin对node免密

配时间同步


 
  1. timedatectl set-timezone Asia/Shanghai
  2. timedatectl set-ntp yes
  3. ###
  4. ntpdate ntp.aliyun.com
AI运行代码

创建工作目录

配置下载源


 
  1. wget https://download.ceph.com/rpm-nautilus/el7/noarch/ceph-release-1-1.el7.noarch.rpm --no-check-certificate
  2. rpm -ivh ceph-release-1-1.el7.noarch.rpm --force
AI运行代码

安装软件包及依赖


 
  1. curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  2. curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  3. yum clean all
  4. yum makecache
  5. yum -y install epel-release
  6. yum -y install yum-plugin-priorities yum-utils ntpdate python-setuptools python-pip gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel zip unzip ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssh openssl-devel nss_ldap openldap openldap-devel openldap-clients openldap-servers libxslt-devel libevent-devel ntp libtool-ltdl bison libtool vim-enhanced python wget lsof iptraf strace lrzsz kernel-devel kernel-headers pam-devel tcl tk cmake ncurses-devel bison setuptool popt-devel net-snmp screen perl-devel pcre-devel net-snmp screen tcpdump rsync sysstat man iptables sudo libconfig git bind-utils tmux elinks numactl iftop bwm-ng net-tools expect snappy leveldb gdisk python-argparse gperftools-libs conntrack ipset jq libseccomp socat chrony sshpass
AI运行代码

在admin执行

下载失败可手动下载

admin与node


 
  1. yum clean all
  2. yum mackcache
  3. yum -y install epel-release
  4. yum -y install yum-plugin-priorities
  5. yum -y install ceph-release ceph ceph-radosgw
AI运行代码

生成初始配置 

ceph-deploy new --public-network 192.168.11.0/24 --cluster-network 192.168.100.0/24 node01 node02 node03
 
AI运行代码

假如出现


 
  1. cat > /usr/lib/python2.7/site-packages/ceph_deploy/util/ssh.py << 'EOF'
  2. # -*- coding: utf-8 -*-
  3. import logging
  4. from ceph_deploy.lib import remoto
  5. from ceph_deploy.connection import get_local_connection
  6. def can_connect_passwordless(hostname):
  7. """
  8. Ensure that current host can SSH remotely to the remote
  9. host using the ``BatchMode`` option to prevent a password prompt.
  10. That attempt will error with an exit status of 255 and a ``Permission
  11. denied`` message or a``Host key verification failed`` message.
  12. """
  13. # 直接返回True,跳过needs_ssh检查(已确认SSH正常)
  14. return True
  15. # 以下代码会被上面的return跳过,保留仅作参考
  16. logger = logging.getLogger(hostname)
  17. with get_local_connection(logger) as conn:
  18. # Check to see if we can login, disabling password prompts
  19. command = ['ssh', '-CT', '-o', 'BatchMode=yes', hostname]
  20. out, err, retval = remoto.process.check(conn, command, stop_on_error=False)
  21. permission_denied_error = 'Permission denied '
  22. host_key_verify_error = 'Host key verification failed.'
  23. has_key_error = False
  24. for line in err:
  25. if permission_denied_error in line or host_key_verify_error in line:
  26. has_key_error = True
  27. if retval == 255 and has_key_error:
  28. return False
  29. return True
  30. EOF
AI运行代码

同步配置

ceph-deploy --overwrite-conf mon create-initial
 
AI运行代码

初始化mon节点

ceph-deploy mon create node01 node02 node03
 
AI运行代码

部署mgr

ceph-deploy mgr create node{01..03}
 
AI运行代码

查看ceph集群状态

查看 mon 集群选举的情况

ceph quorum_status --format json-pretty | grep leader
 
AI运行代码

擦净(删除分区表)磁盘

 
  1. ceph-deploy disk zap node01 /dev/sdb
  2. ceph-deploy disk zap node02 /dev/sdb
  3. ceph-deploy disk zap node03 /dev/sdb
AI运行代码

添加osd节点

 
  1. ceph-deploy --overwrite-conf osd create node01 --data /dev/sdb
  2. ceph-deploy --overwrite-conf osd create node02 --data /dev/sdb
  3. ceph-deploy --overwrite-conf osd create node03 --data /dev/sdb
AI运行代码

查看状态

开启监控模块

查看主节点
ceph -s | grep mgr
 
AI运行代码

在主节点上执行 
yum install -y ceph-mgr-dashboard
 
AI运行代码


 
  1. [root@admin ceph]# ceph config set mgr mgr/dashboard/ssl false
  2. [root@admin ceph]# ceph config set mgr mgr/dashboard/server_addr 0.0.0.0
  3. [root@admin ceph]# ceph config set mgr mgr/dashboard/server_port 8000
  4. [root@admin ceph]# ceph mgr module disable dashboard
  5. [root@admin ceph]# ceph mgr module enable dashboard --force
  6. [root@admin ceph]# ceph mgr services
AI运行代码

设置密码与用户 

 
  1. [root@admin ceph]# echo "123.com" > dashboard_passwd.txt
  2. [root@admin ceph]# ceph dashboard set-login-credentials admin -i dashboard_passwd.txt
AI运行代码

资源池 Pool 管理

创建pool,作为数据池
ceph osd pool create mypool 64 64
 
AI运行代码

安装客户工具
ceph-deploy install client
 
AI运行代码

客户端使用ceph

admin节点操作,安装客户端工具
[root@admin ceph]# ceph-deploy install client
 
AI运行代码

admin节点操作,同步管理信息
ceph-deploy admin  client
 
AI运行代码

在client节点操作,安装客户端工具

创建 元数据池

 
  1. ceph osd pool create cephfs_meta 64
  2. ceph osd pool application enable cephfs_meta cephfs
AI运行代码

使用 资源池与 元资源池 关联 创建 cephfs

使用 2个pool 一个作为资源池 (大容量)一个作为 元资源池 (小容量)


 
  1. ceph fs new cephfs cephfs_meta mypool
  2. ceph fs new <文件系统名称> <元数据池名称> <数据池名称>
AI运行代码

挂载文件 
ceph-fuse -k /etc/ceph/ceph.client.admin.keyring -m 192.168.11.201:6789 /ceph
 
AI运行代码

一、准备


网站公告

今日签到

点亮在社区的每一天
去签到