date: '2019-10-27 18:27:11'
updated: '2019-10-31 20:23:10'
tags: openstack, Linux
permalink: /articles/2019/10/27/1572172031071.html
yum install epel-release -y
[root@kolla ~]# cat /etc/hostname
kolla
[root@kolla ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.51.208 kolla.cn kolla
yum install ntp -y && systemctl enable ntpd.service && systemctl start ntpd.service
mkdir ~/.pip
vim ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
物理机,两张网卡,一张是管理网卡,另一张是桥接网卡(外网网卡);
IP 地址 | 网卡类型 | 网卡 | 在 openstack 网络中的作用 |
---|---|---|---|
192.168.51.208 | bridge | enp61s0f0 | openstack 内部管理网络 (managment nework) 以后 Horizon Web 界面访问,就是通过这个 IP 地址 |
无 IP(不配置 ip) | bridge | enp61s0f3 | 外部网络 (external network) ,让 neutron 的 br-ex 绑定使用,openstack 中的虚拟机是通过这块网卡和外网通信的 |
enp61s0f3 中的配置
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
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=enp61s0f3
UUID=1abc4bd5-0df3-483e-9110-55f905c4d428
DEVICE=enp61s0f3
ONBOOT=yes
yum install python-devel libffi-devel gcc openssl-devel git python-pip -y
pip install -U pip
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
rpm --import https://mirrors.aliyun.com/docker-ce/linux/centos/gpg #导入rpm包密钥,检查后期在线安装的rpm是否安全
安装 docker 社区版本
yum -y install docker-ce
systemctl start docker && systemctl enable docker && systemctl status docker
设置 docker volume 卷挂载方式
mkdir /etc/systemd/system/docker.service.d
tee /etc/systemd/system/docker.service.d/kolla.conf << 'EOF'
[Service]
MountFlags=shared
EOF
注:加上 MountFlags=shared 后,当 docker 宿主机新增分区时,docker 服务不用重启。添加这个参考后,后期在 openstack 中使用 cinder 存储服务时,新加磁盘比较方便。
在此我建议部署 stein 版本镜像加速器选择 daocloud,阿里、网易等加速器可能会出现 pull docker 出现问题。
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
重启相关服务
systemctl daemon-reload
systemctl restart docker && systemctl status docker
yum install ansible -y
pip install kolla-ansible
报错:已经安装 PyYAML 3.10,但是我们需要 PyYAML
解决:
pip install PyYAML --ignore-installed PyYAML
cp -r /usr/share/kolla-ansible/etc_examples/kolla /etc/
cp /usr/share/kolla-ansible/ansible/inventory/* /etc/kolla/
pip install -U decorator
pip install --upgrade decorate
kolla-genpwd
修改/etc/kolla/passwords.yml
keystone_admin_password: 598941324
注:这是登录 Dashboard,admin 使用的密码,你可以根据自己需要自行修改。
kolla_base_distro: "centos"
kolla_install_type: "binary"
openstack_release: "stein"
kolla_internal_vip_address: "192.168.51.208"
network_interface: "enp61s0f0"
neutron_external_interface: "enp61s0f3"
enable_haproxy: "no"
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub root@kolla
[root@kolla ~]# vim /etc/kolla/all-in-one
# These initial groups are the only groups required to be modified. The
# additional groups are for more control of the environment.
[control]
kolla
[network]
kolla
[compute]
kolla
[storage]
kolla
[monitoring]
kolla
[deployment]
kolla
kolla-ansible -i /etc/kolla/all-in-one prechecks
kolla-ansible -i /etc/kolla/all-in-one pull
[root@kolla ~]# docker images | wc -l
32
大概会下载 32 个镜像文件
kolla-ansible -i /etc/kolla/all-in-one deploy
部署完成后验证部署
kolla-ansible -i /etc/kolla/all-in-one post-deploy
这样就创建 /etc/kolla/admin-openrc.sh 文件
[root@kolla ~]# cat /etc/kolla/admin-openrc.sh
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=598941324
export OS_AUTH_URL=http://192.168.51.208:35357/v3
export OS_INTERFACE=internal
export OS_IDENTITY_API_VERSION=3
export OS_REGION_NAME=RegionOne
export OS_AUTH_PLUGIN=password
访问 192.168.51.208 即可进去 openstack 页面
pip install python-openstackclient
报错:ERROR: Package 'more-itertools' requires a different Python: 2.7.5 not in '>=3.4'
解决:
pip install more-itertools==5.0.0
pip install python-openstackclient
再次安装。
pip install python-neutronclient
安装 openstack 网络相关的命令
init-runonce 是在 openstack 中快速创建一个云项目例子的脚本。浮劢 IP 就是云主机的公网 IP。
vim /usr/share/kolla-ansible/init-runonce
EXT_NET_CIDR='192.168.50.0/24'
EXT_NET_RANGE='start=192.168.50.150,end=192.168.50.199'
EXT_NET_GATEWAY='192.168.50.1'
source /etc/kolla/admin-openrc.sh
cd /usr/share/kolla-ansible
./init-runonce
运行完毕之后出现如下:
To deploy a demo instance, run:
openstack server create \
--image cirros \
--flavor m1.tiny \
--key-name mykey \
--network demo-net \
demo1
运行即可安装
[root@kolla kolla-ansible]# openstack server create \
> --image cirros \
> --flavor m1.tiny \
> --key-name mykey \
> --network demo-net \
> demo1
+-------------------------------------+-----------------------------------------------+
| Field | Value |
+-------------------------------------+-----------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | |
| OS-EXT-STS:power_state | NOSTATE |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | 7MxdJvxUhSop |
| config_drive | |
| created | 2019-10-27T02:49:06Z |
| flavor | m1.tiny (1) |
| hostId | |
| id | 43d6a986-3f92-4cdd-a21c-22ad7dcb4c3a |
| image | cirros (c912e610-4038-4a7f-8eea-670b44ac197b) |
| key_name | mykey |
| name | demo1 |
| progress | 0 |
| project_id | 8370a6827e874b768c4f9778068cb4bc |
| properties | |
| security_groups | name='default' |
| status | BUILD |
| updated | 2019-10-27T02:49:06Z |
| user_id | 7b5055a3536c415ca67f4a97752b3b5a |
| volumes_attached | |
+-------------------------------------+-----------------------------------------------+
标题:kolla部署openstack(stein)部署
作者:cuijianzhe