neutron源码分析(一)OpenStack环境搭建
一、OpenStack安装
安装一个初始化的Mitaka版本的OpenStack环境用于分析,neutron源码
序号 | 角色 | IP地址 | 版本 |
1 | controller | 172.16.15.161 | mitaka |
2 | compute01 | 172.16.15.162 | mitaka |
3 | compute02 | 172.16.15.163 | mitaka |
开始安装吧
# 所有节点全部执行
使用本次安装教程,会安装ceilometer+gnocchi集成、heat、FWAAS、VPNAAS、LBAASv1等 # 所有节点全部执行 mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/*repo /etc/yum.repos.d/bak cat >> /etc/yum.repos.d/openstack-mitaka.repo << EOF [base] name=CentOS-$releasever - Base baseurl=http://172.20.2.44/base enabled=1 gpgcheck=0 [mitaka] name=mitaka baseurl=http://172.20.2.44/openstack-mitaka enabled=1 gpgcheck=0 [epel] name=epel baseurl=http://172.20.2.44/epel enabled=1 gpgcheck=0 EOF yum clean all yum install python-cheetah python-gnocchi python-nova libvirt libvirt-devel libvirt-client -y
# 控制节点执行
# 控制节点执行 yum install -y openstack-packstack packstack --gen-answer-file=openstack.txt # 这里第一行修改compute节点对应的IP地址,这里测试compute节点IP地址是172.16.15.162,172.16.15.163,IP地址之间用逗号(,)隔开 sed -i \ -e 's@CONFIG_COMPUTE_HOSTS=.*@CONFIG_COMPUTE_HOSTS=172.16.15.162,172.16.15.163@g' \ -e 's@CONFIG_CEILOMETER_METERING_BACKEND=.*@CONFIG_CEILOMETER_METERING_BACKEND=gnocchi@g' \ -e 's@CONFIG_NAGIOS_INSTALL=.*@CONFIG_NAGIOS_INSTALL=n@g' \ -e 's@CONFIG_SWIFT_INSTALL=.*@CONFIG_SWIFT_INSTALL=n@g' \ -e 's@CONFIG_HEAT_INSTALL=.*@CONFIG_HEAT_INSTALL=y@g' \ -e 's@CONFIG_HEAT_CLOUDWATCH_INSTALL=.*@CONFIG_HEAT_CLOUDWATCH_INSTALL=y@g' \ -e 's@CONFIG_HEAT_CFN_INSTALL=.*@CONFIG_HEAT_CFN_INSTALL=y@g' \ -e 's@CONFIG_NEUTRON_FWAAS=.*@CONFIG_NEUTRON_FWAAS=y@g' \ -e 's@CONFIG_NEUTRON_VPNAAS=.*@CONFIG_NEUTRON_VPNAAS=y@g' \ -e 's@CONFIG_LBAAS_INSTALL=.*@CONFIG_LBAAS_INSTALL=y@g' \ -e 's@CONFIG_MARIADB_PW=.*@CONFIG_MARIADB_PW=root1234@g' \ -e 's@CONFIG_KEYSTONE_ADMIN_PW=.*@CONFIG_KEYSTONE_ADMIN_PW=admin@g' \ -e 's@CONFIG_KEYSTONE_API_VERSION=.*@CONFIG_KEYSTONE_API_VERSION=v3@g' openstack.txt
# 在控制节点上执行
# 控制节点执行 packstack --answer-file=openstack.txt # 安装过程会修改yum源。这里需要执行如下指令,修改过来 sed -i 's@enabled=.*@enabled=1@g' /etc/yum.repos.d/openstack-mitaka.repo # 漫长的等待之后,如果不报错,进行下面操作 sed -i \ -e 's@type_drivers =.*@type_drivers = flat,vxlan@g' \ -e 's@#flat_networks =.*@flat_networks = *@g' /etc/neutron/plugins/ml2/ml2_conf.ini openstack-service disable ceilometer openstack-service stop ceilometer
# 在计算节点上修改
# 在计算节点1上执行ssh互信 sed -i \ -e 's@nova.*@nova:x:162:162:OpenStack Nova Daemons:/var/lib/nova:/bin/bash@g' /etc/passwd echo nova | passwd --stdin nova su - nova ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' ssh-copy-id -i .ssh/id_rsa.pub nova@172.16.15.163 # 在计算节点2上执行ssh互信 sed -i \ -e 's@nova.*@nova:x:162:162:OpenStack Nova Daemons:/var/lib/nova:/bin/bash@g' /etc/passwd # 修改成自己的计算节点IP地址 echo nova | passwd --stdin nova su - nova ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' ssh-copy-id -i .ssh/id_rsa.pub nova@172.16.15.162
# 在控制节点上加上共享存储吧
# 分区 fdisk /dev/vdc <<EOF n p 1 w EOF # 格式化 mkfs.xfs /dev/vdc1 # 挂载 mount /dev/vdc1 /opt/nova/instances/ # NFS共享 yum -y install nfs-utils rpcbind -y mkdir -p /opt/nova/instances echo "/opt/nova/instances 172.16.0.0/16(rw,no_root_squash,no_all_squash,sync)" > /etc/exports exportfs -r chmod -R 777 /opt/nova/instances/ systemctl enable rpcbind.service systemctl start rpcbind.service systemctl enable nfs-server.service systemctl start nfs-server.service
# 在计算节点上用NFS共享吧
showmount -e 172.16.15.161 mount -t nfs 172.16.15.161:/opt/nova/instances /var/lib/nova/instances/ chown -R nova.nova /var/lib/nova
生活不会突变,你要做的只是耐心和积累。人这一辈子没法做太多的事情,所以每一件都要做得精彩绝伦。你的时间有限,做喜欢的事情会令人愉悦,所以跟随自己的本心。