1.基础配置
除非硬盘够自信,不要分var分区
创建4h-12g-100G的controller节点
修改外部网卡
ONBOOT="yes"BOOTPROTO="static"IPADDR="172.16.1.198"NETMASK="255.255.255.0"GATEWAY="172.16.1.1"DNS1="114.114.114.114"
修改仅主机网卡
xxxxxxxxxxONBOOT="yes"BOOTPROTO="static"IPADDR=10.10.42.198NETMASK=255.255.255.0DNS1=114.114.114.114
修改主机名
xxxxxxxxxxhostnamectl set-hostname controllerbash
关闭控制节点的防火墙,设置开机不启动
xxxxxxxxxxsystemctl stop firewalld && systemctl disable firewalld
设置SELinux为Permissive 模式
xxxxxxxxxxsed -i 's/enforcing/disabled/g' /etc/selinux/configsetenforce 0getenforce
写入/etc/hosts
xxxxxxxxxxecho 172.16.1.198 controller >> /etc/hostsecho 10.10.42.198 controller >> /etc/hostsecho 172.16.1.199 compute >> /etc/hostsecho 10.10.42.199 compute >> /etc/hostscat /etc/hosts
配置yum源
- x
mv /etc/yum.repos.d/* /var[root@controller ~]# cat > /etc/yum.repos.d/http.repo << EOF> [centos]> name=centos> baseurl=ftp://172.16.1.252/centos/> gpgcheck=0> enable=1>> [iaas]> name=iaas> baseurl=ftp://172.16.1.252/iaas/iaas-repo/> gpgcheck=0> enable=1>> EOFcat /etc/yum.repos.d/http.repoyum clean all && yum repolist && yum list
配置时间同步
xxxxxxxxxxyum install -y chronyvi /etc/chrony.conf#server 0.centos.pool.ntp.org iburst#server 1.centos.pool.ntp.org iburst#server 2.centos.pool.ntp.org iburst#server 3.centos.pool.ntp.org iburstserver controller iburstallow 10.10.42.0/24local stratum 10systemctl restart chronyd && systemctl enable chronyd
创建4h-8g-100g-50g的compute节点
修改外部网卡
xxxxxxxxxxONBOOT="yes"BOOTPROTO="static"IPADDR="172.16.1.199"NETMASK="255.255.255.0"GATEWAY="172.16.1.1"DNS1="114.114.114.114"
修改仅主机网卡
xxxxxxxxxxONBOOT="yes"BOOTPROTO="static"IPADDR=10.10.42.199NETMASK=255.255.255.0DNS1=114.114.114.114
修改主机名
xxxxxxxxxxhostnamectl set-hostname computebash
关闭控制节点的防火墙,设置开机不启动
xxxxxxxxxxsystemctl stop firewalld && systemctl disable firewalld
设置SELinux为Permissive 模式
xxxxxxxxxxsed -i 's/enforcing/disabled/g' /etc/selinux/configsetenforce 0getenforce
写入/etc/hosts
xxxxxxxxxxecho 172.16.1.198 controller >> /etc/hostsecho 10.10.42.198 controller >> /etc/hostsecho 172.16.1.199 compute >> /etc/hostsecho 10.10.42.199 compute >> /etc/hostscat /etc/hosts
配置yum源
xxxxxxxxxxmv /etc/yum.repos.d/* /var[root@compute ~]# cat > /etc/yum.repos.d/http.repo << EOF> [centos]> name=centos> baseurl=ftp://172.16.1.252/centos/> gpgcheck=0> enable=1>> [iaas]> name=iaas> baseurl=ftp://172.16.1.252/iaas/iaas-repo/> gpgcheck=0> enable=1>> EOFcat /etc/yum.repos.d/http.repoyum clean all && yum repolist && yum list
配置时间同步
xxxxxxxxxxyum install -y chronyvi /etc/chrony.conf#server 0.centos.pool.ntp.org iburst#server 1.centos.pool.ntp.org iburst#server 2.centos.pool.ntp.org iburst#server 3.centos.pool.ntp.org iburstserver controller iburstsystemctl restart chronyd && systemctl enable chronyd
利用空白硬盘分区
xxxxxxxxxx[root@compute ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTfd0 2:0 1 4K 0 disksr0 11:0 1 4.2G 0 romvda 252:0 0 100G 0 disk├─vda1 252:1 0 1G 0 part /boot└─vda2 252:2 0 99G 0 part├─centos-root 253:0 0 92G 0 lvm /├─centos-swap 253:1 0 1G 0 lvm [SWAP]├─centos-var 253:2 0 5G 0 lvm /var└─centos-home 253:3 0 1G 0 lvm /homevdb 252:16 0 50G 0 disk[root@compute ~]# parted /dev/vdbGNU Parted 3.1Using /dev/vdbWelcome to GNU Parted! Type 'help' to view a list of commands.(parted) mklabel gptWarning: The existing disk label on /dev/vdb will be destroyed and all data on this disk will be lost.Do you want to continue?Yes/No? yes(parted) mkpart swiftFile system type? [ext2]?Start? 0End? 20GibWarning: The resulting partition is not properly aligned for best performance.Ignore/Cancel? I(parted) mkpart swift1File system type? [ext2]?Start? 20GibEnd? 40Gib(parted) qInformation: You may need to update /etc/fstab.[root@compute ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTfd0 2:0 1 4K 0 disksr0 11:0 1 4.2G 0 romvda 252:0 0 100G 0 disk├─vda1 252:1 0 1G 0 part /boot└─vda2 252:2 0 99G 0 part├─centos-root 253:0 0 92G 0 lvm /├─centos-swap 253:1 0 1G 0 lvm [SWAP]├─centos-var 253:2 0 5G 0 lvm /var└─centos-home 253:3 0 1G 0 lvm /homevdb 252:16 0 50G 0 disk├─vdb1 252:17 0 20G 0 part└─vdb2 252:18 0 20G 0 partmkfs.xfs /dev/vdb1mkfs.xfs /dev/vdb2
2.openstack搭建
1.安装iaas软件包并且修改配置
xxxxxxxxxxyum install -y iaas-xiandianvim /etc/xiandian/openrc.shcontroller
xxxxxxxxxx[root@controller ~]# cat /etc/xiandian/openrc.sh | egrep -v '(^#|^$)'HOST_IP=172.16.1.198HOST_PASS=000000HOST_NAME=controllerHOST_IP_NODE=172.16.1.199HOST_PASS_NODE=000000HOST_NAME_NODE=computenetwork_segment_IP=172.16.1.0/24RABBIT_USER=openstackRABBIT_PASS=000000DB_PASS=000000DOMAIN_NAME=demoADMIN_PASS=000000DEMO_PASS=000000KEYSTONE_DBPASS=000000GLANCE_DBPASS=000000GLANCE_PASS=000000NOVA_DBPASS=000000NOVA_PASS=000000NEUTRON_DBPASS=000000NEUTRON_PASS=000000METADATA_SECRET=000000INTERFACE_IP=172.16.1.198INTERFACE_NAME=eth0Physical_NAME=providerminvlan=101maxvlan=200CINDER_DBPASS=000000CINDER_PASS=000000BLOCK_DISK=vdb1SWIFT_PASS=000000OBJECT_DISK=vdb2STORAGE_LOCAL_NET_IP=172.16.1.199HEAT_DBPASS=000000HEAT_PASS=000000ZUN_DBPASS=000000ZUN_PASS=000000KURYR_DBPASS=000000KURYR_PASS=000000CEILOMETER_DBPASS=000000CEILOMETER_PASS=000000AODH_DBPASS=000000AODH_PASS=000000BARBICAN_DBPASS=000000BARBICAN_PASS=000000
compute
xxxxxxxxxx[root@compute ~]# cat /etc/xiandian/openrc.sh | egrep -v '(^#|^$)'HOST_IP=172.16.1.198HOST_PASS=000000HOST_NAME=controllerHOST_IP_NODE=172.16.1.199HOST_PASS_NODE=000000HOST_NAME_NODE=computenetwork_segment_IP=172.16.1.0/24RABBIT_USER=openstackRABBIT_PASS=000000DB_PASS=000000DOMAIN_NAME=demoADMIN_PASS=000000DEMO_PASS=000000KEYSTONE_DBPASS=000000GLANCE_DBPASS=000000GLANCE_PASS=000000NOVA_DBPASS=000000NOVA_PASS=000000NEUTRON_DBPASS=000000NEUTRON_PASS=000000METADATA_SECRET=000000INTERFACE_IP=172.16.1.199INTERFACE_NAME=eth0Physical_NAME=providerminvlan=101maxvlan=200CINDER_DBPASS=000000CINDER_PASS=000000BLOCK_DISK=vdb1SWIFT_PASS=000000OBJECT_DISK=vdb2STORAGE_LOCAL_NET_IP=172.16.1.199HEAT_DBPASS=000000HEAT_PASS=000000ZUN_DBPASS=000000ZUN_PASS=000000KURYR_DBPASS=000000KURYR_PASS=000000CEILOMETER_DBPASS=000000CEILOMETER_PASS=000000AODH_DBPASS=000000AODH_PASS=000000BARBICAN_DBPASS=000000BARBICAN_PASS=000000
controller和compute安装重启
xxxxxxxxxxiaas-pre-host.shreboot
2.数据库安装
controller
在运行脚本
xxxxxxxxxxiaas-install-mysql.sh
安装完后登入数据库中创建chinaskilldb库,在chinaskilldb库中创建表testable (id int not null primary key,Teamname varchar(50), remarks varchar(255)),在表中插入记录(1,“cloud”,“chinaskill”)
xxxxxxxxxxmysql -u root -p000000create database chinaskilldb;use chinaskilldb;create table testable (id int not null primary key,Teamname varchar(50), remarks varchar(255));insert into testable values(1,'cloud','chinaskill')
将memcached的缓存大小从64Mib改成256Mib
xxxxxxxxxxsed -i 's/64/256/g' /etc/sysconfig/memcached
使用rabbitmq命令 创建用户,并设置Administrators限权
xxxxxxxxxxrabbitmqctl set_permissions chinaskill ".*" ".*" ".*"
3.安装keystone
controller
运行脚本安装
xxxxxxxxxxiaas-install-keystone.sh
创建一个用户
xxxxxxxxxx[root@controller images]# source /etc/keystone/admin-openrc.sh[root@controller images]# openstack user create --domain demo --password 000000 china+---------------------+----------------------------------+| Field | Value |+---------------------+----------------------------------+| domain_id | 226029b5aac74ce795fca3dd48e8e10c || enabled | True || id | e2db6597ae2c463185035d4a4bb2ab29 || name | china || options | {} || password_expires_at | None |+---------------------+----------------------------------+
4.安装Glance
controller
运行脚本安装
xxxxxxxxxxiaas-install-glance.sh
上传镜像
xxxxxxxxxx[root@controller images]# source /etc/keystone/admin-openrc.sh[root@controller images]# glance image-create --name cirros --disk-format qcow2 --container bare --progress < CentOS_7.5_x86_64_XD.qcow2[=============================>] 100%+------------------+--------------------------------------+| Property | Value |+------------------+--------------------------------------+| checksum | 3d3e9c954351a4b6953fd156f0c29f5c || container_format | bare || created_at | 2021-11-29T11:02:21Z || disk_format | qcow2 || id | 2c659c04-6463-4888-ab21-e052f48d90e1 || min_disk | 0 || min_ram | 0 || name | cirros || owner | 6ed09fd59a174bb5a019b2434b7b3fc2 || protected | False || size | 510459904 || status | active || tags | [] || updated_at | 2021-11-29T11:02:23Z || virtual_size | None || visibility | shared |+------------------+--------------------------------------+
5.安装nova
controller
xxxxxxxxxxiaas-install-nova-controller.sh
compute
xxxxxxxxxxiaas-install-nova-compute.sh
创建一个实例
xxxxxxxxxx[root@controller ~]# source /etc/keystone/admin-openrc.sh[root@controller ~]# openstack flavor create --id 1 --disk 20 --ram 1024 test+----------------------------+-------+| Field | Value |+----------------------------+-------+| OS-FLV-DISABLED:disabled | False || OS-FLV-EXT-DATA:ephemeral | 0 || disk | 20 || id | 1 || name | test || os-flavor-access:is_public | True || properties | || ram | 1024 || rxtx_factor | 1.0 || swap | || vcpus | 1 |+----------------------------+-------+
6.安装Neutron
controller
xxxxxxxxxxiaas-install-neutron-controller.sh
compute
xxxxxxxxxxiaas-install-neutron-compute.sh
创建云主机网络extnet,子网extsubnet,虚拟机网段为192.168.y.0/24(其中y是vlan号), 网关为192.168.y.1。
xxxxxxxxxx[root@controller ~]# source /etc/keystone/admin-openrc.sh[root@controller ~]# openstack network create --share --external --provider-physical-network provider --provider-network-type vlan extnet+---------------------------+--------------------------------------+| Field | Value |+---------------------------+--------------------------------------+| admin_state_up | UP || availability_zone_hints | || availability_zones | || created_at | 2021-11-29T11:17:41Z || description | || dns_domain | None || id | 97806bba-23b3-420f-ad98-05e800bd3e54 || ipv4_address_scope | None || ipv6_address_scope | None || is_default | False || is_vlan_transparent | None || mtu | 1500 || name | extnet || port_security_enabled | True || project_id | 6ed09fd59a174bb5a019b2434b7b3fc2 || provider:network_type | vlan || provider:physical_network | provider || provider:segmentation_id | 116 || qos_policy_id | None || revision_number | 5 || router:external | External || segments | None || shared | True || status | ACTIVE || subnets | || tags | || updated_at | 2021-11-29T11:17:41Z |+---------------------------+--------------------------------------+[root@controller ~]# openstack subnet create --network extnet --gateway=10.10.42.1 --subnet-range 10.10.42.0/24 extsubnet+-------------------+--------------------------------------+| Field | Value |+-------------------+--------------------------------------+| allocation_pools | 10.10.42.2-10.10.42.254 || cidr | 10.10.42.0/24 || created_at | 2021-11-29T11:20:18Z || description | || dns_nameservers | || enable_dhcp | True || gateway_ip | 10.10.42.1 || host_routes | || id | 03e202b2-f35b-4db5-aac8-06e27107ff65 || ip_version | 4 || ipv6_address_mode | None || ipv6_ra_mode | None || name | extsubnet || network_id | 97806bba-23b3-420f-ad98-05e800bd3e54 || project_id | 6ed09fd59a174bb5a019b2434b7b3fc2 || revision_number | 0 || segment_id | None || service_types | || subnetpool_id | None || tags | || updated_at | 2021-11-29T11:20:18Z |+-------------------+--------------------------------------+
7.安装Dashboard
controller
xxxxxxxxxxiaas-install-dashboard.sh
打开网页访问
Domain:demo
用户名:admin
密码:000000
创建云主机
xxxxxxxxxx[root@controller ~]# source /etc/keystone/admin-openrc.sh[root@controller ~]# openstack image create --disk-format qcow2 --file /opt/images/CentOS_7.5_x86_64_XD.qcow2 centos7+------------------+------------------------------------------------------+| Field | Value |+------------------+------------------------------------------------------+| checksum | 3d3e9c954351a4b6953fd156f0c29f5c || container_format | bare || created_at | 2021-11-29T11:41:29Z || disk_format | qcow2 || file | /v2/images/89e6e0b5-b4a3-4307-ad39-2a3db3a486c7/file || id | 89e6e0b5-b4a3-4307-ad39-2a3db3a486c7 || min_disk | 0 || min_ram | 0 || name | centos7 || owner | 6ed09fd59a174bb5a019b2434b7b3fc2 || protected | False || schema | /v2/schemas/image || size | 510459904 || status | active || tags | || updated_at | 2021-11-29T11:41:31Z || virtual_size | None || visibility | shared |+------------------+------------------------------------------------------+[root@controller ~]# openstack flavor create --disk 20 --ram 1024 --vcpus 1 centos+----------------------------+--------------------------------------+| Field | Value |+----------------------------+--------------------------------------+| OS-FLV-DISABLED:disabled | False || OS-FLV-EXT-DATA:ephemeral | 0 || disk | 20 || id | 4d8699e5-69ce-4469-803c-caf1d6331d96 || name | centos || os-flavor-access:is_public | True || properties | || ram | 1024 || rxtx_factor | 1.0 || swap | || vcpus | 1 |+----------------------------+--------------------------------------+
8.安装Cinder
controller
xxxxxxxxxxiaas-install-cinder-controller.sh
compute
xxxxxxxxxxiaas-install-cinder-compute.sh
创建一个新的卷
xxxxxxxxxx[root@controller nova]# source /etc/keystone/admin-openrc.sh[root@controller nova]# cinder create --display-name myVolume 1+--------------------------------+--------------------------------------+| Property | Value |+--------------------------------+--------------------------------------+| attachments | [] || availability_zone | nova || bootable | false || consistencygroup_id | None || created_at | 2021-11-30T06:34:47.000000 || description | None || encrypted | False || id | f9f53265-6359-4cd6-91c2-83fb3f37c3ac || metadata | {} || migration_status | None || multiattach | False || name | myVolume || os-vol-host-attr:host | None || os-vol-mig-status-attr:migstat | None || os-vol-mig-status-attr:name_id | None || os-vol-tenant-attr:tenant_id | db2a714c481643e5ad18a30967c243aa || replication_status | None || size | 1 || snapshot_id | None || source_volid | None || status | creating || updated_at | None || user_id | 6f8df1b85e2140d58fc80693720f6e95 || volume_type | None |+--------------------------------+--------------------------------------+[root@controller nova]# cinder list+--------------------------------------+-----------+----------+------+-------------+----------+-------------+| ID | Status | Name | Size | Volume Type | Bootable | Attached to |+--------------------------------------+-----------+----------+------+-------------+----------+-------------+| f9f53265-6359-4cd6-91c2-83fb3f37c3ac | available | myVolume | 1 | - | false | |+--------------------------------------+-----------+----------+------+-------------+----------+-------------+
9.安装swift
controller
xxxxxxxxxxiaas-install-swift-controller.sh
compute
xxxxxxxxxxiaas-install-swift-compute.sh
10.安装Heat编配服务
controller
xxxxxxxxxxiaas-install-heat.sh
11.安装Zun服务
controller
xxxxxxxxxxiaas-install-zun-controller.sh
compute
xxxxxxxxxxiaas-install-zun-compute.sh
上传docker镜像CentOS7_1804.tar到glance,并且通过docker镜像启动容器
xxxxxxxxxx[root@controller images]# lsCentOS_6.5_x86_64_XD.qcow2 CentOS7_1804.tar CentOS_7.2_x86_64_XD.qcow2 CentOS_7.5_x86_64_XD.qcow2[root@controller images]# source /etc/keystone/admin-openrc.sh[root@controller images]# openstack image create --file ./CentOS7_1804.tar --disk-format raw --public --container-format docker "centos_docker"+------------------+------------------------------------------------------+| Field | Value |+------------------+------------------------------------------------------+| checksum | 438e76cdb677a3ab1156e284f58aa366 || container_format | docker || created_at | 2021-11-30T07:02:14Z || disk_format | raw || file | /v2/images/522259d3-20de-4f58-87ec-1422c87e6fe6/file || id | 522259d3-20de-4f58-87ec-1422c87e6fe6 || min_disk | 0 || min_ram | 0 || name | centos_docker || owner | db2a714c481643e5ad18a30967c243aa || protected | False || schema | /v2/schemas/image || size | 381696512 || status | active || tags | || updated_at | 2021-11-30T07:02:16Z || virtual_size | None || visibility | public |+------------------+------------------------------------------------------+[root@controller images]# zun run --image-driver glance centos_docker[root@controller images]# zun list+--------------------------------------+--------------------+---------------+---------+------------+----------------+-------+| uuid | name | image | status | task_state | addresses | ports |+--------------------------------------+--------------------+---------------+---------+------------+----------------+-------+| ed1334ce-448b-4645-9d27-05e24259c171 | sigma-23-container | centos_docker | Running | None | 192.168.100.22 | [22] |+--------------------------------------+--------------------+---------------+---------+------------+----------------+-------+
12.安装Ceilometer 监控服务
controller
xxxxxxxxxxiaas-install-ceilometer-controller.sh
compute
xxxxxxxxxxiaas-install-ceilometer-compute.sh
13.安装Aodh监控服务
controller
xxxxxxxxxxiaas-install-aodh.sh
14.添加控制节点资源到云平台
controller
修改openrc.sh
xxxxxxxxxx旧HOST_IP_NODE=172.16.1.199HOST_NAME_NODE=compute新HOST_IP_NODE=172.16.1.198HOST_NAME_NODE=controllerxxxxxxxxxxiaas-install-nova-compute.sh执行过程中需要确认登录controller节点和输入controller节点root用户密码
评论 (0)