CEPH生产环境集群搭建及参数优化

一、ceph集群搭建准备

  1. 生产搭建使用了九台物理机,其中三台作为管理机,其余六台作为数据机,每台数据机上使用12块磁盘(磁盘暂时使用机械硬盘)
  2. 管理机与各个节点机在同一网络区域

二、ceph搭建步骤

  1. 管理机与各个主机做免密登录(ceph同步各节点数据时免去输入密码操作)
  2. 检查各个数据机上的磁盘状态,如果已经挂载了,需要清除数据,并且卸载
  3. 各节点安装ceph软件 ps:此处使用离线安装方式较为繁琐,如果能使用在线安装最好
  4. 创建集群
  5. 修改配置文件 ceph.conf 此处配置为基础配置,后续优化
  6. 将密钥和配置文件分发至各个节点机,并且做权限644
  7. 创建集群mgr
  8. 将数据机磁盘挂载至ceph的osd 》 ps:此处挂载注意磁盘格式为xfs
  9. 检查集群状态及mon信息是否准确
  10. 优化osd+mon+mgr,增加osd节点和mon节点

三、ceph搭建命令

  1. 管理机至各个节点的免密操作
    1.1 修改.ssh/config配置文件为

    Host ceph-001
    Hostname ceph-001
    User cephuser
    1.2配置文件赋值
    chmod 644 ~/.ssh/config
    1.3管理节点上生成key
    ssh-keygen
    1.4将公钥分发至各个节点
    此处有多种方式分发
    第一种:使用ssh-copy-id命令远程拷贝 ssh-copy-id ceph-002
    第二种:scp远程拷贝authorized_keys文件,如果没有该文件就将.ssh/id_rsa.pub的内容复制到该文件中,注意拷贝之后修改目标机器上的该文件权限 chmod 600 authorized_keys

  2. 卸载磁盘 umount /data1 ps:卸载12块磁盘并检查type为xfs

  3. 创建ceph安装目录,用于存放配置文件

  4. 安装ceph,此处使用离线安装

    -rw-r–r-- 1 cephuser cephuser 255648 Aug 7 22:05 audit-2.8.4-4.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 102448 Aug 7 22:05 audit-libs-2.8.4-4.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 78216 Aug 7 22:05 audit-libs-python-2.8.4-4.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 3024 Aug 7 22:05 ceph-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 5156908 Aug 7 22:05 ceph-base-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 14729668 Aug 7 22:05 ceph-common-13.2.6-0.el7.x86_64.rpm
    -rw-rw-r-- 1 cephuser cephuser 3076 Aug 10 15:10 ceph-deploy-ceph.log
    -rw-r----- 1 cephuser cephuser 1800352 Aug 7 22:05 ceph-mds-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 3669328 Aug 7 22:05 ceph-mgr-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 4096528 Aug 7 22:05 ceph-mon-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 13698080 Aug 7 22:05 ceph-osd-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 4729640 Aug 7 22:05 ceph-radosgw-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 20788 Aug 7 22:05 ceph-selinux-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 302068 Aug 7 22:05 checkpolicy-2.5-8.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 278636 Aug 7 22:05 gperftools-libs-2.6.1-1.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 165208 Aug 7 22:05 leveldb-1.12.0-11.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 150356 Aug 7 22:05 libbabeltrace-1.2.4-3.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 444056 Aug 7 22:05 libcephfs2-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 36108 Aug 7 22:05 liboath-2.4.1-9.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 3040120 Aug 7 22:05 librados2-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 336692 Aug 7 22:05 libradosstriper1-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 1299164 Aug 7 22:05 librbd1-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 2087612 Aug 7 22:05 librgw2-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 165932 Aug 7 22:05 libselinux-2.5-14.1.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 241132 Aug 7 22:05 libselinux-python-2.5-14.1.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 155092 Aug 7 22:05 libselinux-utils-2.5-14.1.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 154244 Aug 7 22:05 libsemanage-2.5-14.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 115284 Aug 7 22:05 libsemanage-python-2.5-14.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 304196 Aug 7 22:05 libsepol-2.5-10.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 180520 Aug 7 22:05 lttng-ust-2.4.1-4.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 100668 Aug 7 22:05 lz4-1.7.5-2.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 31264 Aug 7 22:05 mailcap-2.1.41-2.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 504412 Aug 7 22:05 openssl-1.0.2k-16.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 1251072 Aug 7 22:05 openssl-libs-1.0.2k-16.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 938004 Aug 7 22:05 policycoreutils-2.5-29.el7_6.1.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 466748 Aug 7 22:05 policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 137912 Aug 7 22:05 pyOpenSSL-0.13.1-4.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 38985 Aug 7 22:05 python2-bcrypt-3.1.4-4.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 2980 Aug 7 22:05 python2-six-1.9.0-0.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 1426348 Aug 7 22:05 python-babel-0.9.6-8.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 5932 Aug 7 22:05 python-backports-1.0-8.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 12896 Aug 7 22:05 python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 81940 Aug 7 22:05 python-beaker-1.5.4-10.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 88408 Aug 7 22:05 python-cephfs-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 223012 Aug 7 22:05 python-cffi-1.6.0-5.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 432476 Aug 7 22:05 python-cherrypy-3.2.2-4.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 35176 Aug 7 22:05 python-ipaddress-1.0.16-2.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 32880 Aug 7 22:05 python-IPy-0.75-6.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 530920 Aug 7 22:05 python-jinja2-2.7.2-3.el7_6.noarch.rpm
    -rw-r----- 1 cephuser cephuser 313924 Aug 7 22:05 python-mako-0.8.1-2.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 25792 Aug 7 22:05 python-markupsafe-0.11-10.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 886880 Aug 7 22:05 python-paste-1.7.5.1-9.20111221hg1498.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 260768 Aug 7 22:05 python-pecan-0.4.5-2.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 125732 Aug 7 22:05 python-ply-3.4-11.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 38000 Aug 7 22:05 python-prettytable-0.7.2-3.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 106984 Aug 7 22:05 python-pycparser-2.14-1.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 193596 Aug 7 22:05 python-rados-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 135252 Aug 7 22:05 python-rbd-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 13028 Aug 7 22:05 python-repoze-lru-0.4-3.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 95804 Aug 7 22:05 python-requests-2.6.0-1.el7_1.noarch.rpm
    -rw-r----- 1 cephuser cephuser 77296 Aug 7 22:05 python-rgw-13.2.6-0.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 655332 Aug 7 22:05 python-routes-1.13-2.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 406404 Aug 7 22:05 python-setuptools-0.9.8-7.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 12592 Aug 7 22:05 python-simplegeneric-0.8-7.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 17932 Aug 7 22:05 python-singledispatch-3.4.0.2-2.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 33284 Aug 7 22:05 python-tempita-0.5.1-6.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 104036 Aug 7 22:05 python-urllib3-1.10.2-5.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 206524 Aug 7 22:05 python-webob-1.2.3-7.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 104260 Aug 7 22:05 python-webtest-1.3.4-6.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 575384 Aug 7 22:05 python-werkzeug-0.9.1-2.el7.noarch.rpm
    -rw-r----- 1 cephuser cephuser 495512 Aug 7 22:05 selinux-policy-3.13.1-229.el7_6.12.noarch.rpm
    -rw-r----- 1 cephuser cephuser 7248624 Aug 7 22:05 selinux-policy-minimum-3.13.1-229.el7_6.12.noarch.rpm
    -rw-r----- 1 cephuser cephuser 635184 Aug 7 22:05 setools-libs-3.3.8-4.el7.x86_64.rpm
    -rw-r----- 1 cephuser cephuser 74732 Aug 7 22:05 userspace-rcu-0.7.16-1.el7.x86_64.rpm

以上为需要安装的rpm,安装是如遇到一下错误
File “/bin/ceph-deploy”, line 18, in
from ceph_deploy.cli import main
File “/usr/lib/python2.7/site-packages/ceph_deploy/cli.py”, line 1, in
import pkg_resources
ImportError: No module named pkg_resources
请执行下面脚本,作用是安装python的包
sudo yum install python-pkg-resources python-setuptools -y
安装过程中可能会遇到很多缺失包和依赖包的错误,切记不可删除系统文件

  1. 初始化集群节点 ceph-deploy new ceph-001

  2. 修改ceph.conf 此处需要配置网段掩码,否则会造成添加osd节点时错误

    public network = xx.xx.xx.x/22 #网段掩码
    osd pool default size = 2 #osd副本数量

  3. 创建集群 ceph-deploy mon create-initial

  4. 将配置同步给各个节点机器 ceph-deploy admin ceph-001 ceph-002

  5. 在各个节点上修改权限 sudo chmod 644 /etc/ceph/ceph.client.admin.keyring

  6. 创建mgr ceph-deploy mgr create ceph-001

  7. 给osd挂载磁盘 ceph-deploy osd create --data /dev/sdb ceph-003

  8. 增加2个mon节点,一般要有奇数monitor,但不是必须的。
    ceph-deploy mon add ceph-002
    ceph-deploy mon add ceph-003

  9. 创建对象网关 ceph-deploy rgw create ceph-001

  10. 创建账户 sudo radosgw-admin user create --uid=admin --display-name=admin --access_key=admin --secret=123456

  11. 创建access秘钥sudo radosgw-admin key create --uid=admin --key-type=s3 --gen-access-key --gen-secret

四、参数及集群节点优化
未完待续

你可能感兴趣的:(CEPH生产环境集群搭建及参数优化)