本文采用1台monitor,3台controller,3台computer,1台做docker镜像仓库,均安装centos7 minimal 系统,3T 硬盘*4,3块作为ceph存储使用,2张万兆网卡。
hostname | 网卡1 | 网卡2 |
---|---|---|
monitor | 172.29.55.229 | 无ip |
controller01 | 172.29.55.230 | 无ip |
controller02 | 172.29.55.231 | 无ip |
compute03 | 172.29.55.232 | 无ip |
compute01 | 172.29.55.233 | 无ip |
compute02 | 172.29.55.234 | 无ip |
compute03 | 172.29.55.235 | 无ip |
!#/bin/bash
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cd /etc/yum.repos.d/
curl -o /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
yum update -y
systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld
sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config
OpenStack,RabbitMQ和Ceph要求所有主机具有匹配的时间,以确保正确的消息传递。对于Ceph,如果主机相差超过0.05秒,它将抱怨。默认情况下,某些OpenStack服务的计时器低至2秒。由于这些原因,强烈建议您设置某种NTP服务。而ntpd如果NTP服务器在本地部署环境中运行将实现部署更准确的时间,chrony同步通过WAN连接的时候更准确。ntpd由于时间紧迫,建议在运行Ceph时设置为本地同步时间。
添加ntp服务器指向
centos7 系统安装已有chronyd服务
可直接修改配置文件启动服务
cp /etc/chrony.conf /etc/chrony.conf_back
vi /etc/chrony.conf
#注释掉服务器初始的ntp服务指向,添加国内或自建ntp server
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
systemctl start chronyd && systemctl status chronyd && systemctl enable chornyd
chronyc sources -V #查看ntp状态
或者安装ntp服务
yum install ntp ntpdate -y
cp /etc/ntp.conf /etc/ntp.conf.backup
vi /etc/ntp.conf
#注释掉服务器初始的ntp服务指向,添加国内或自建ntp server
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
systemctl enable ntpd.service && systemctl start ntpd.service && systemctl status ntpd.service
ntpq –p #查看ntp状态
echo "monitor" > /etc/hostname
hostname monitor
hostnamectl set-hostname monitor
echo "controller01" > /etc/hostname
hostname controller01
hostnamectl set-hostname controller01
echo "computer01" > /etc/hostname
hostname computer01
hostnamectl set-hostname computer01
在monitor上编辑/etc/hosts文件
127.0.0.1 localhost
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.29.55.229 monitor
172.29.55.231 controller01
172.29.55.232 controller02
172.29.55.233 controller03
172.29.55.234 computer01
172.29.55.235 computer02
172.29.55.236 computer03
ssh-keygen //生成ssh密钥
将密钥copy到controller和computer节点
ssh-copy-id root@monitor
ssh-copy-id root@controller01
ssh-copy-id root@controller02
ssh-copy-id root@controller03
ssh-copy-id root@computer01
ssh-copy-id root@computer02
配置后,可以通过命令测试,是否可以免密访问
scp /etc/hosts root@controller01:/etc/hosts //controller01-03
scp /etc/hosts root@computer01:/etc/hosts //computer01-03
创建的虚机没有libvirtd服务,但是物理机服务器会有,这个必须要关闭
# systemctl stop libvirtd.service && systemctl disable libvirtd.service && systemctl status libvirtd.service
# systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld
# sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config
或是直接修改:
# vim /etc/selinux/config
设置SELINUX=disabled ,reboot之后生效。
# getenforce //查看selinux当前状态
reboot
ceph用户指导Filestore
Filestore 打标格式KOLLA_CEPH_OSD_BOOTSTRAP (queens 默认使用)
parted /dev/sdb -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP 1 -1
parted /dev/sdc -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP 1 -1
ceph用户指导Bluestore
Bluestore 打标格式KOLLA_CEPH_OSD_BOOTSTRAP_BS (rocky以上两种格式均可使用,FOO1为编号)
parted /dev/sdb -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP_BS_FOO1 1 -1
parted /dev/sdc -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP_BS_FOO2 1 -1
parted /dev/sdb -s -- mklabel gpt mkpart KOLLA_CEPH_OSD_BOOTSTRAP 1 -1
Ceph_RGW需要一个健康的集群才能成功部署。在初次启动时,RGW将创建几个池。第一个池应处于运行状态以继续第二个池,依此类推。因此,在进行一体化部署的情况下,必须在部署之前更改池的默认副本数。按照需求,本示例部署选用三个池副本。
本次部署针对monitor机器和所有存储节点,修改/etc/kolla/config/ceph.conf并添加内容:
mkdir -pv /etc/kolla/config/ && vim /etc/kolla/config/ceph.conf
[global]
osd pool default size = 3
osd pool default min size = 3
wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce
yum install epel-release
yum install python-pip
pip install -U pip
pip install docker
yum install python-devel libffi-devel gcc openssl-devel libselinux-python
mkdir ~/.pip
vim ~/.pip/pip.conf
[global]
trusted-host=mirrors.aliyun.com
阿里源或者豆瓣源
[global]
trusted-host = pypi.douban.com
index-url = http://pypi.douban.com/simple
mkdir -p /etc/docker
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://7g5a4z30.mirror.aliyuncs.com"]
}
如果不设置此项,kolla-ansible 部署neutron-dhcp-agent 容器的时候会失败,并抛APIError/HTTPError
When running with systemd, setup docker-engine with the appropriate information in the Docker daemon to launch with. This means setting up the following information in the docker.service file. If you do not set the MountFlags option correctly then kolla-ansible will fail to deploy the neutron-dhcp-agent container and throws APIError/HTTPError. After adding the drop-in unit file as follows, reload and restart the Docker service:
mkdir -p /etc/systemd/system/docker.service.d
vim /etc/systemd/system/docker.service.d/kolla.conf
[Service]
MountFlags=shared
tee /etc/systemd/system/docker.service.d/kolla.conf << 'EOF'
[Service]
MountFlags=shared
EOF
systemctl daemon-reload && systemctl enable docker && systemctl restart docker && systemctl status docker
测试成功正常导入如下
python
>>> import docker;
>>> exit();
如果出现 import error
查看 pip/docker 版本,更新pip后重新安装docker,若不能解决,根据报错查看解决办法
pip show docker
pip --version
pip remove docker
pip install –U pip
pi install docker
注意:
ocata 版本根据官网指南 使用指定docker版本安装docker-py或者python-docker-py
Node
The old docker-python is obsoleted by python-docker-py.
yum install python-docker-py
Or using pip to install the latest version:
pip install -U docker-py
# vim /usr/lib/systemd/system/docker.service
修改如下:
172.16.50.31:4000 为source主机的docker私有仓库地址和端口号
ExecStart=/usr/bin/dockerd --insecure-registry 172.16.50.31:4000
重启Docker服务:
# systemctl daemon-reload && systemctl restart docker && systemctl status docker
9、测试Registry服务是否正常(这一步为制作本地私有仓库后再测试)
# curl -X GET http://172.16.50.31:4000/v2/_catalog
正常如下返回数据即可:
{"repositories":["kolla/centos-source-aodh-api","kolla/centos-source-aodh-base","kolla/centos-source-aodh-evalua……}