ubuntu20部署ceph17

时间:2024-04-28 10:16:33

# 配置3个节点ubuntu 20操作系统源
cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

# 配置3个节点的hosts
/etc/hosts
192.168.1.196   u196
192.168.1.197   u197
192.168.1.198   u198

# 配置3个节点时间同步,196节点配置,拷贝到197和198节点
vi /etc/chrony/chrony.conf
pool u196        iburst maxsources 4

scp chrony.conf u197:/etc/chrony/
scp chrony.conf u198:/etc/chrony/

systemctl restart chrony
systemctl restart chronyd
chronyc sources


# 部署docker
apt install ca-certificates curl gnupg lsb-release

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt install docker-ce docker-ce-cli containerd.io apt-transport-https software-properties-common -y


# 启动docker
systemctl status docker
systemctl restart docker

# 添加 ceph 源证书
wget -q -O- 'https://download.ceph.com/keys/release.asc' | sudo apt-key add -

# 添加ceph apt 源
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ceph/debian-quincy/ focal main' > /etc/apt/sources.list.d/ceph.list


# 更新本地apt源
apt update

# 安装ceph-common和cephadm
apt install ceph-common cephadm -y

# 拉取ceph 17镜像
docker pull quay.io/ceph/ceph:v17.2
docker pull quay.io/ceph/ceph-grafana:9.4.12
docker pull quay.io/prometheus/node-exporter:latest
docker pull quay.io/prometheus/alertmanager:latest
docker pull quay.io/prometheus/prometheus:latest

# 196节点部署mon
cephadm --image quay.io/ceph/ceph:v17.2 bootstrap --mon-ip 192.168.1.196 --initial-dashboard-user admin --initial-dashboard-password liuy5277 --allow-mismatched-release


# 添加mon/mgr节点host
ssh-copy-id -f -i /etc/ceph/ceph.pub u197
ssh-copy-id -f -i /etc/ceph/ceph.pub u198

ceph orch host add u197 192.168.1.197 --labels=_admin
ceph orch host add u198 192.168.1.198 --labels=_admin

# 添加osd
ceph orch apply osd --all-available-devices --unmanaged=true

ceph orch daemon add osd u196:/dev/vdb
ceph orch daemon add osd u197:/dev/vdb
ceph orch daemon add osd u198:/dev/vdb

# 部署mds
ceph orch apply mds cephfs --placement='3 u196 u197 u198'

ceph osd pool create cephfs_data 128
ceph osd pool create cephfs_metadata 64
ceph fs new cephfs01 cephfs_data cephfs_metadata

# 部署nfs
ceph nfs cluster create d449eb1e-eb79-11ee-a6d1-8bc03479c953 "u196,u197,u198" --port 2049
mount -t ceph u201:6789:/ /cephfs -o name=admin,secret=AQAV1gJmalYIKBAAEzizP5sY1aeCRs2/grhB0w==,_netdev
mkdir /cephfs/data

创建别名为nfs01的共享,存储数据在cephfs的/data里面
ceph nfs export create cephfs --cluster-id d449eb1e-eb79-11ee-a6d1-8bc03479c953 --pseudo-path /nfs01 --fsname=cephfs01 --path=/data
{
    "bind": "/nfs01",
    "fs": "cephfs01",
    "path": "/data",
    "cluster": "4101504e-e364-11ee-a68e-99388f3ce351",
    "mode": "RW"
}
root@u196:~#