昨天跟大家分享PackStack部署模式,今天跟大家分享Kolla部署方式。 【环境需求】 大家如果没有硬件实验环境,可以使用虚拟机,推荐大家使用Oracle VM VirtualBox,大家可以自行去官网下载!如果使用这种方法安装则需要注意: 由于Kolla的安装,要求目标机器是两块网卡,所以被安装的虚拟机就需要两块网卡: eth1:NAT网络模式,Horizon访问就是通过这个网卡的IP地址。 eth2:桥接网卡模式,ip其实是dhcp分配,这个其实是让neutron的br-ex 绑定使用,虚拟机是通过这块网卡访问外网。 1.本次环境使用的是CentOS7,操作系选择最小化安装; 2.配置为8cpu,16GB,200GB,2块网卡; 【基础配置】 1.由于操作系统是最小化安装,需要配置和激活网卡 yum install -y net-tools 2.关闭Firewalld 由于是开发测试环境,需要开启大量的服务端口,为了今后简化配置,所以关闭防火墙,但是如果是生产环境或者暴露公网IP的服务器,强烈建议不要关闭防火墙 systemctlstatusfirewalld systemctlstopfirewalld systemctldisablefirewalld systemctlstatusfirewalld firewall-cmd--state 3.安装Epel源 yum install epel-release 配置hostname vi /etc/hostname kolla vi /etc/hosts 127.0.0.1 localhostlocalhost.localdomain localhost4 localhost4.localdomain4 ::1 localhostlocalhost.localdomain localhost6 localhost6.localdomain6 192.168.11.54 kolla.jackchen.com kolla 4.检查配置是否正确 #hostname -F /etc/hostname #hostname kolla #hostname -f kolla.jackchen.com 5.安装NTP # CentOS 7 yum install ntp systemctl enable ntpd.service systemctl start ntpd.service 6.手工同步时间 ntpdate 0.centos.pool.ntp.org 单节点安装Ocata 7.安装依赖包 yum install python-devel libffi-develgccopenssl-devel git python-pip 【安装Docker】 1.设置repo 目前最新版本的Docker是1.13.1,Kolla目前支持的Docker是1.12.x,所以我们要指定Docker的版本来安装,并且一定要采用Docker官方的源,不能使用红帽的源,红帽的源的Docker是有bug。 vi /etc/yum.repos.d/docker.repo [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg 2.安装docker yum installdocker-engine-1.12.5docker-engine-selinux-1.12.5 3.创建docker为服务并修改docker加速 mkdir -p /etc/systemd/system/docker.service.d 修改加速器: tee /etc/docker/daemon.json <<-'EOF'{ "registry-mirrors": ["https://a5aghnme.mirror.aliyuncs.com"]}EOF 4.创建配置文件 tee/etc/systemd/system/docker.service.d/kolla.conf<<-'EOF' [Service] MountFlags=shared EOF 5.重启docker服务 systemctl daemon-reload systemctl enable docker systemctl restart docker 6.设置允许访问私有仓库 编辑/usr/lib/systemd/system/docker.service #ExecStart=/usr/bin/dockerd ExecStart=/usr/bin/dockerd --insecure-registry 192.168.11.54:4000 7.重启Docker服务 systemctl daemon-reload systemctl restart docker 8.默认docker的registry是使用5000端口,对于OpenStack来说,有端口冲突,所以需要改成4000。Pull并启动registry镜像 sudo mkdir /opt/registry docker run -d -v/opt/registry:/var/lib/registry-p 4000:5000 --restart=always --name registryregistry:2 【下载官方kolla镜像】 tar zxvf centos-source-registry-ocata.tar.gz-C/opt/registry/ 【安装ansible】 yum install ansible 【安装pip】 sudo yum install python-pipsudo pip install --upgrade pip 【安装kolla-ansible】 Install Kolla for development cd kolla-ansible pip install . 【复制相关文件】 cp -r etc/kolla /etc/kolla/ cp ansible/inventory/* /root/ 如果是在虚拟机里装kolla,希望可以启动再启动虚拟机,那么你需要把virt_type=qemu,默认是kvm,物理机安装可以跳过此步骤。 【嵌套虚拟化配置】 如果是在虚拟机里安装kolla,希望可以在OpenStack平台上创建虚拟机,那么你需要把virt_type=qemu,默认是kvm。 mkdir -p /etc/kolla/config/nova cat << EOF >/etc/kolla/config/nova/nova-compute.conf [libvirt] virt_type=qemu cpu_mode = none EOF 【生成密码文件】 kolla-genpwd 编辑/etc/kolla/passwords.yml keystone_admin_password: chenhao 这是登录Dashboard,admin使用的密码,你可以根据自己需要进行修改。 编辑/etc/kolla/globals.yml文件 kolla_install_type: "source" openstack_release: "4.0.2" kolla_internal_vip_address:"10.0.2.10" docker_registry: "192.168.11.54:4000" docker_namespace: "lokolla" network_interface: "eth1" neutron_external_interface: "eth2" 上述配置中注意kolla_install_type需要与之前下载的Kolla官方镜像包的类型一致,openstack_release也需要与Kolla官方镜像包中实际的镜像包tag一致,否则ansible会报错找不到镜像。 10.0.2.10,这个ip是一个没有使用的的ip地址,他是给haproxy使用,单节点其实压根没有意义。 【安装OpenStack】 kolla-ansible deploy -i /root/all-in-one 验证部署 kolla-ansible post-deploy这样就创建/etc/kolla/admin-openrc.sh文件 安装OpenStack client端 pip install python-openstackclient 编辑/usr/share/kolla-ansible/init-runonce, 网络需要根据实际情况修改 EXT_NET_CIDR='192.168.12.0/24' EXT_NET_RANGE='start=192.168.12.30,end=192.168.12.40' EXT_NET_GATEWAY='192.168.12.1' 192.168.12.0的网络,就是我上面eth2接的网络,这个网络是通过路由器访问互联网,需要根据大家的实际情况配置,装完虚拟机就可以直接ping通。 运行如下命令: source /etc/kolla/admin-openrc.sh cd /usr/share/kolla-ansible ./init-runonce 最后你可以创建一个虚拟机来玩玩,根据最后的命令提示 openstack server create \ --image cirros \ --flavor m1.tiny \ --key-name mykey \ --nicnet-id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \ demo1 这个时候,你可以登录Dashboard,给虚拟机分配一个floating ip,如果顺利,你应该就可以直接ping通floating ip的地址。 更多学习技巧敬请关注:誉天教育 QQ:3200569443
|