为什么80%的码农都做不了架构师?>>>
环境
角色 | 操作系统 | 主机名 | 公用地址 | 集群地址 | 数据裸盘 | ceph 版本 |
---|---|---|---|---|---|---|
部署机 | CentOS7.4 | deploy | 192.168.1.190 | 无 | 无 | jewel |
节点 | CentOS7.4 | ceph191 | 192.168.1.191 | 192.168.2.191 | /dev/vdb | jewel |
节点 | CentOS7.4 | ceph192 | 192.168.1.192 | 192.168.2.192 | /dev/vdb | jewel |
节点 | CentOS7.4 | ceph193 | 192.168.1.193 | 192.168.2.193 | /dev/vdb | jewel |
准备
- 在全部服务器上添加 yum 源
[Ceph] name=Ceph packages for $basearch baseurl=https://mirrors.aliyun.com/ceph/rpm-jewel/el7/$basearch enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc priority=1 [Ceph-noarch] name=Ceph noarch packages baseurl=https://mirrors.aliyun.com/ceph/rpm-jewel/el7/noarch enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc priority=1 [ceph-source] name=Ceph source packages baseurl=https://mirrors.aliyun.com/ceph/rpm-jewel/el7/SRPMS enabled=1 gpgcheck=1 type=rpm-md gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc priority=1
- 在全部服务器上关闭 firewalld、NetworkManager 和 SELinux
systemctl stop firewalld systemctl disable firewalld systemctl stop NetworkManager systemctl disable NetworkManager sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config # 重启操作系统生效
- 为全部服务器配置相同的时间同步服务器
# 修改 /etc/chrony.conf,重启 chronyd 服务
- 在全部服务器上创建 cephdeploy 用户,并配置免密 sudo
useradd -m cephdeploy passwd cephdeploy echo "cephdeploy ALL = (root) NOPASSWD:ALL" | tee /etc/sudoers.d/cephdeploy chmod 0440 /etc/sudoers.d/cephdeploy
- 在部署机上配置各节点主机名解析
echo "192.168.1.191 ceph191" >> /etc/hosts echo "192.168.1.192 ceph192" >> /etc/hosts echo "192.168.1.193 ceph193" >> /etc/hosts
- 在部署机上配置 cephdeploy 用户免密 ssh 到各节点的 cephdeploy 用户
su - cephdeploy ssh-keygen for host in $(seq -f 'ceph%g' 191 193); dossh-copy-id $host done
安装集群
- 在部署机上执行以下命令,初始化集群
yum install ceph-deploy su - cephdeploy mkdir $HOME/my-cluster cd $HOME/my-cluster ceph-deploy new ceph191
- 在部署机上编辑上一步生成的 $HOME/my-cluster/ceph.conf,追加如下三行
public network = 192.168.1.0/24 cluster network = 192.168.2.0/24 rgw_override_bucket_index_max_shards = 100
- 在部署机上执行以下命令,安装集群基本组件
ceph-deploy install ceph191 ceph-deploy install ceph192 ceph-deploy install ceph193 ceph-deploy mon create-initial ceph-deploy admin ceph191 ceph192 ceph193 ceph-deploy osd create ceph191:/dev/vdb ceph192:/dev/vdb ceph193:/dev/vdb ceph-deploy mon add ceph192 ceph-deploy mon add ceph193
- 在集群中任一节点上执行以下命令,查看集群状态
ceph -s
创建对象存储网关
- 在部署机上执行以下命令,安装对象存储网关服务
su - cephdeploy ceph-deploy rgw create ceph191 ceph-deploy rgw create ceph192 ceph-deploy rgw create ceph193
- 在集群中的任一节点上执行以下命令,修改默认 pool 的默认 pg 和 pgs
- 实际 pg 和 pgp 数量参考这里
ceph osd pool set default.rgw.buckets.data pg_num 128 ceph osd pool set default.rgw.buckets.data pgp_num 128
- 在集群中的任一节点上执行以下命令,创建 swift 用户
radosgw-admin user create --subuser="admin:swift_user" --uid="swift_id" --display-name="swift_name" --key-type=swift --secret="swift_password" --access=full # admin:swift_user: swift接口使用的"用户名:子用户名" # swift_id: swfit用户id # swift_name: swift用户名 # swift_password: swift密码
- 在部署机上执行以下命令,安装 swift 客户端
yum install python2-pip pip install python-swiftclient
- 在 ceph 集群中创建 swift 容器
swift -A http://192.168.1.191/auth/v1 -Uadmin:swift_user -Kswift_password post container_name # container_name: 容器名