配置IP
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
----
BOOTPROTO=static
----
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=5b0d1aff-6182-482a-8701-41a6dd29183a
DEVICE=ens33
---
ONBOOT=yes
IPADDR=192.168.0.61
GATEWAY=192.168.0.1
---
主机名 公网IP 集群IP
centos01 192.168.0.61 192.168.1.61 s1
centos02 192.168.0.62 192.168.1.62 s2
centos03 192.168.0.63 192.168.1.63 s3
防火墙
systemctl stop firewalld
systemctl disable firewalld
修改主机名
[root@localhost ~]# cat /etc/hostname
s1
DNS设置上网
[root@sa0 ~]# cat /etc/resolv.conf
nameserver 114.114.114.114
DNS映射
[root@s1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.61 s1
192.168.0.62 s2
192.168.0.63 s3
更换阿里云
# yum install -y wget
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#清除缓存
yum clean all
#生成缓存
yum makecache
时间同步
# yum install ntp -y
---
批量安装ntp
for i in `seq 1 3`; do ssh z${i} 'yum install ntp -y';done
---
# vim /etc/ntp.conf
---
# 允许内网其他机器同步时间
restrict 10.142.0.0 mask 255.255.0.0 nomodify notrap
server 10.142.246.2
# 外部时间服务器不可用时,以本地时间作为时间服务
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
---
# systemctl restart ntpd.service
# ntpstat
# ntpq -p
# 把配置文件分发到其他几个节点
# systemctl restart ntpd.service
ssh免密码登陆
# ssh-keygen
# ssh-copy-id root@s1
# ssh-copy-id root@s2
# ssh-copy-id root@s3
批量免秘钥登录
for i in `seq 1 3`; do ssh-copy-id root@z${i};done
关闭selinux
# sed -i 's/enforcing/disabled/g' /etc/selinux/config
批量关闭selinux
for i in `seq 1 3`; do ssh z${i} 'sed -i 's/enforcing/disabled/g' /etc/selinux/config';done
设置国内yum源
# cat /etc/yum.repos.d/ceph.repo
[Ceph]
name=Ceph packages for $basearch
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/$basearch
enabled=1
gpgcheck=0
type=rpm-md
gpgkey=http://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
[Ceph-noarch]
name=Ceph noarch packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/noarch
enabled=1
gpgcheck=0
type=rpm-md
gpgkey=http://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
[ceph-source]
name=Ceph source packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/SRPMS
enabled=1
gpgcheck=0
type=rpm-md
gpgkey=http://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
创建ceph用户
分别这三个节点上存储创建用户且赋予它root权限(本人这里用 ytcwd)
执行
# sudo useradd -d /home/ceph -m ceph
# sudo passwd ceph( 输入密码这里建议三台服务器密码设为一致)
//授予无密码sudo权限
#echo "ceph ALL = (root) NOPASSWD:ALL" >> /etc/sudoers.d/ceph
#sudo chmod 0440 /etc/sudoers.d/ceph
安装ceph-deploy
# yum install ceph-deploy
# ceph-deploy --version
# ceph -v
创建部署目录并部署集群
# mkdir cluster
# cd cluster
# ceph-deploy new s1 s2 s3 #创建集群
# vi ceph.conf
osd pool default size = 2
# 如果有多块网卡,可以配置数据交互使用万兆网卡,测试暂时不具备 相应条件
# mon_clock_drift_allowed=5 # 单位是ms
# osd_pool_default_crush_rule=0
# osd_crush_chooseleaf_type=1
# public network=192.168.0.0/24 # 公网IP地址
# cluster network=192.168.1.0/24 # 内网IP地址
#rgw_override_bucket_index_max_shards = 100
安装ceph
# ceph-deploy install s1 s2 s3
部署mon服务
ceph-deploy mon create s1 s2 s3
ceph-deploy mon create-initial
增加OSD
每个节点
# mkdir -p /data/ceph
# chown -R ceph:ceph /data/ceph
# 准备
# ceph-deploy osd prepare s1:/data/ceph s2:/data/ceph s3:/data/ceph
#激活
# # ceph-deploy osd activate s1:/data/ceph s2:/data/ceph s3:/data/ceph
新增osd
1.
ceph-deploy osd prepare s1:sdb:sdc
2.
ceph-deploy osd activate s1:/dev/sdb1:/dev/sdc1
拷贝密钥
# 用 ceph-deploy 把配置文件和 admin 密钥拷贝到管理节点和 Ceph 节点,这样你每次执行 Ceph 命令行时就无需指定 monitor 地址和 ceph.client.admin.keyring 了
# ceph-deploy admin s1 s2 s3
# chmod +r /etc/ceph/ceph.client.admin.keyring
#确保你对 ceph.client.admin.keyring 有正确的操作权限
检查集群状态
ceph health
ceph -s
配置双网卡
[root@s1 ceph]# cat ceph.conf
[global]
fsid = e94bc890-61c6-4a27-8cf4-84b648447d41
mon_initial_members = s1, s2, s3
mon_host = 192.168.0.61,192.168.0.62,192.168.0.63
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
mon_clock_drift_allowed = 2
osd pool default size = 2
--
public network = 192.168.0.0/24
cluster network = 192.168.1.0/24
-- osd.0
# 同步其他节点的配置
# ceph-deploy --overwrite-conf config push s2
# ceph-deploy --overwrite-conf config push s3
#重启osd,mon
#systemctl restart ceph-osd@*
#systemctl restart ceph-mon@*
创建对象网关
安装rgw软件包
# ceph-deploy install --rgw s1 s2 s3
安装rgw 实例
# ceph-deploy --overwrite rgw create s1 s2 s3
配置各节点网关
在c4执行:ceph auth get client.rgw.c4 > /etc/ceph/ceph.client.radosgw.keyring
在c5执行:ceph auth get client.rgw.c5 > /etc/ceph/ceph.client.radosgw.keyring
在c6执行:ceph auth get client.rgw.c6 > /etc/ceph/ceph.client.radosgw.keyring
for i in `seq 1 3`; do ssh z${i} 'ceph auth get client.rgw.z${i} > /etc/ceph/ceph.client.radosgw.keyring'; done
创建用户
[root@s1 ceph]# radosgw-admin user create --uid="admin" --display-name="admin"
{
"user_id": "admin",
"display_name": "admin",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [],
"keys": [
{
"user": "admin",
"access_key": "VOZFOOA73B7JP31PZHE0",
"secret_key": "gdiCnlVmgBY4ja4aDB3HOGqSUL4VMNlOlnfuaEj9"
}
],
"swift_keys": [],
"caps": [],
"op_mask": "read, write, delete",
"default_placement": "",
"placement_tags": [],
"bucket_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"user_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"temp_url_keys": []
}
如果配置错误了,清空数据重新开始
标题
#ceph-deploy purge c4 c5 c6
#ceph-deploy purgedata c4 c5 c6
#ceph-deploy forgetkeys
全部重做:
rm -rf /etc/ceph/*
rm -rf /var/lib/ceph/*/*
rm -rf /var/log/ceph/*
rm -rf /var/run/ceph/*
对bucket分片
radosgw-admin bucket reshard add --bucket=qxfile --num-shards=100
配置pg的数量检查rbd这个pool里已存在的PG和PGP数量
ceph osd pool get default.rgw.buckets.data pg_num
ceph osd pool get default.rgw.buckets.data pgp_num
ceph osd pool set default.rgw.buckets.data pg_num 32
ceph osd pool set default.rgw.buckets.data pgp_num 32
客户端对接
S3cmd客户端
步骤1:安装s3cmd
[root@node1 ~]# yum -y install s3cmd
步骤2:配置s3cmd
[root@node1 ~]# s3cmd —configure
附录:
测试块读写速度
1.测试Linux磁盘读写速度
# 测试写速度
[root@s1 cluster]# time dd if=/dev/zero of=/test.dbf bs=8k count=300000
记录了300000+0 的读入
记录了300000+0 的写出
2457600000字节(2.5 GB)已复制,9.57264 秒,257 MB/秒
real 0m9.585s
user 0m0.188s
sys 0m9.060s
# 测试读速度
[root@s1 cluster]# time dd if=/test.dbf of=/dev/null bs=8k count=300000
记录了300000+0 的读入
记录了300000+0 的写出
2457600000字节(2.5 GB)已复制,4.20992 秒,584 MB/秒
real 0m4.218s
user 0m0.185s
sys 0m4.012s
2.测试挂载的/data数据盘读写速度
# 测试写速度
[root@s1 cluster]# time dd if=/dev/zero of=/data/test.dbf bs=8k count=300000
记录了300000+0 的读入
记录了300000+0 的写出
2457600000字节(2.5 GB)已复制,5.3515 秒,459 MB/秒
real 0m5.359s
user 0m0.236s
sys 0m4.950s
# 测试读速度
[root@s1 cluster]# time dd if=/data/test.dbf of=/dev/null bs=8k count=300000
记录了300000+0 的读入
记录了300000+0 的写出
2457600000字节(2.5 GB)已复制,4.00616 秒,613 MB/秒
real 0m4.013s
user 0m0.116s
sys 0m3.880s
关闭所有的debug信息
问题1
出现时钟偏差
Ceph 时钟偏移问题 clock skew detected 解决方案--- 部署内网NTP服务
Monitor clock skew detected
问题2
出现ERROR错误
health HEALTH_ERR
64 pgs are stuck inactive for more than 300 seconds