Docker Swarm 使用ceph存储客户端配置脚本

该脚本需要在每个节点上执行,ceph版本对应了上一篇文章ceph的版本,如果有需要自行变更yum的版本配置。默认使用pool为docker1,需要自行创建。
/etc/ceph/ceph.client.admin.keyring及/etc/ceph/ceph.conf的内容需要从ceph集群的master节点上拷贝到该配置脚本里面,更新对应内容。

# create ceph config directory
mkdir -p /etc/ceph/

# touch ceph config 
tee /etc/ceph/ceph.client.admin.keyring <<-'EOF'
[client.admin]
        key = AQCvmNRbYU1MNxAA6BZR/ORV+kK3e8O7p1dAuQ==
EOF

tee /etc/ceph/ceph.conf <<-'EOF'
[global]
fsid = 81c49ab9-048a-4c95-b075-1259eb5a2c6d
mon_initial_members = ceph-1, ceph-2, ceph-3
mon_host = 10.255.255.141,10.255.255.142,10.255.255.143
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx

public_network=10.255.255.0/24


EOF


# install ceph-common

yum clean all
yum install wget -y
rm -rf /etc/yum.repos.d/*.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed -i '/aliyuncs/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/aliyuncs/d' /etc/yum.repos.d/epel.repo


#配置ceph非本地源
#在每个节点执行:vim /etc/yum.repos.d/ceph.repo,并将以下内容放入ceph.repo
cat <<EOT >> /etc/yum.repos.d/ceph.repo
[ceph]
name=ceph
baseurl=http://mirrors.aliyun.com/ceph/rpm-luminous/el7/x86_64/
gpgcheck=0
[ceph-noarch]
name=cephnoarch
baseurl=http://mirrors.aliyun.com/ceph/rpm-luminous/el7/noarch/
gpgcheck=0
EOT

yum makecache

yum -y install ceph-common


# install rexray
curl -sSL https://rexray.io/install | sh

tee /etc/rexray/config.yml <<-'EOF'
rexray:
  logLevel:        debug
libstorage:
  logging:
    level:         debug
    httpRequests:  true
    httpResponses: true
libstorage:
  service: rbd
rbd:
  defaultPool: rbd
EOF


systemctl start rexray
systemctl enable rexray
systemctl status rexray

# install rexray/rbd docker plugin
docker plugin install rexray/rbd RBD_DEFAULTPOOL=rbd LINUX_VOLUME_FILEMODE=0777

Leave a Comment

电子邮件地址不会被公开。 必填项已用*标注