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"
修改仅主机网卡
xxxxxxxxxx
ONBOOT="yes"
BOOTPROTO="static"
IPADDR=10.10.42.198
NETMASK=255.255.255.0
DNS1=114.114.114.114
修改主机名
xxxxxxxxxx
hostnamectl set-hostname controller
bash
关闭控制节点的防火墙,设置开机不启动
xxxxxxxxxx
systemctl stop firewalld && systemctl disable firewalld
设置SELinux为Permissive 模式
xxxxxxxxxx
sed -i 's/enforcing/disabled/g' /etc/selinux/config
setenforce 0
getenforce
写入/etc/hosts
xxxxxxxxxx
echo 172.16.1.198 controller >> /etc/hosts
echo 10.10.42.198 controller >> /etc/hosts
echo 172.16.1.199 compute >> /etc/hosts
echo 10.10.42.199 compute >> /etc/hosts
cat /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
>
> EOF
cat /etc/yum.repos.d/http.repo
yum clean all && yum repolist && yum list
配置时间同步
xxxxxxxxxx
yum install -y chrony
vi /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 iburst
server controller iburst
allow 10.10.42.0/24
local stratum 10
systemctl restart chronyd && systemctl enable chronyd
创建4h-8g-100g-50g的compute节点
修改外部网卡
xxxxxxxxxx
ONBOOT="yes"
BOOTPROTO="static"
IPADDR="172.16.1.199"
NETMASK="255.255.255.0"
GATEWAY="172.16.1.1"
DNS1="114.114.114.114"
修改仅主机网卡
xxxxxxxxxx
ONBOOT="yes"
BOOTPROTO="static"
IPADDR=10.10.42.199
NETMASK=255.255.255.0
DNS1=114.114.114.114
修改主机名
xxxxxxxxxx
hostnamectl set-hostname compute
bash
关闭控制节点的防火墙,设置开机不启动
xxxxxxxxxx
systemctl stop firewalld && systemctl disable firewalld
设置SELinux为Permissive 模式
xxxxxxxxxx
sed -i 's/enforcing/disabled/g' /etc/selinux/config
setenforce 0
getenforce
写入/etc/hosts
xxxxxxxxxx
echo 172.16.1.198 controller >> /etc/hosts
echo 10.10.42.198 controller >> /etc/hosts
echo 172.16.1.199 compute >> /etc/hosts
echo 10.10.42.199 compute >> /etc/hosts
cat /etc/hosts
配置yum源
xxxxxxxxxx
mv /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
>
> EOF
cat /etc/yum.repos.d/http.repo
yum clean all && yum repolist && yum list
配置时间同步
xxxxxxxxxx
yum install -y chrony
vi /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 iburst
server controller iburst
systemctl restart chronyd && systemctl enable chronyd
利用空白硬盘分区
xxxxxxxxxx
[root@compute ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sr0 11:0 1 4.2G 0 rom
vda 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 /home
vdb 252:16 0 50G 0 disk
[root@compute ~]# parted /dev/vdb
GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: 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 swift
File system type? [ext2]?
Start? 0
End? 20Gib
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) mkpart swift1
File system type? [ext2]?
Start? 20Gib
End? 40Gib
(parted) q
Information: You may need to update /etc/fstab.
[root@compute ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sr0 11:0 1 4.2G 0 rom
vda 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 /home
vdb 252:16 0 50G 0 disk
├─vdb1 252:17 0 20G 0 part
└─vdb2 252:18 0 20G 0 part
mkfs.xfs /dev/vdb1
mkfs.xfs /dev/vdb2
2.openstack搭建
1.安装iaas软件包并且修改配置
xxxxxxxxxx
yum install -y iaas-xiandian
vim /etc/xiandian/openrc.sh
controller
xxxxxxxxxx
[root@controller ~]# cat /etc/xiandian/openrc.sh | egrep -v '(^#|^$)'
HOST_IP=172.16.1.198
HOST_PASS=000000
HOST_NAME=controller
HOST_IP_NODE=172.16.1.199
HOST_PASS_NODE=000000
HOST_NAME_NODE=compute
network_segment_IP=172.16.1.0/24
RABBIT_USER=openstack
RABBIT_PASS=000000
DB_PASS=000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000
KEYSTONE_DBPASS=000000
GLANCE_DBPASS=000000
GLANCE_PASS=000000
NOVA_DBPASS=000000
NOVA_PASS=000000
NEUTRON_DBPASS=000000
NEUTRON_PASS=000000
METADATA_SECRET=000000
INTERFACE_IP=172.16.1.198
INTERFACE_NAME=eth0
Physical_NAME=provider
minvlan=101
maxvlan=200
CINDER_DBPASS=000000
CINDER_PASS=000000
BLOCK_DISK=vdb1
SWIFT_PASS=000000
OBJECT_DISK=vdb2
STORAGE_LOCAL_NET_IP=172.16.1.199
HEAT_DBPASS=000000
HEAT_PASS=000000
ZUN_DBPASS=000000
ZUN_PASS=000000
KURYR_DBPASS=000000
KURYR_PASS=000000
CEILOMETER_DBPASS=000000
CEILOMETER_PASS=000000
AODH_DBPASS=000000
AODH_PASS=000000
BARBICAN_DBPASS=000000
BARBICAN_PASS=000000
compute
xxxxxxxxxx
[root@compute ~]# cat /etc/xiandian/openrc.sh | egrep -v '(^#|^$)'
HOST_IP=172.16.1.198
HOST_PASS=000000
HOST_NAME=controller
HOST_IP_NODE=172.16.1.199
HOST_PASS_NODE=000000
HOST_NAME_NODE=compute
network_segment_IP=172.16.1.0/24
RABBIT_USER=openstack
RABBIT_PASS=000000
DB_PASS=000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000
KEYSTONE_DBPASS=000000
GLANCE_DBPASS=000000
GLANCE_PASS=000000
NOVA_DBPASS=000000
NOVA_PASS=000000
NEUTRON_DBPASS=000000
NEUTRON_PASS=000000
METADATA_SECRET=000000
INTERFACE_IP=172.16.1.199
INTERFACE_NAME=eth0
Physical_NAME=provider
minvlan=101
maxvlan=200
CINDER_DBPASS=000000
CINDER_PASS=000000
BLOCK_DISK=vdb1
SWIFT_PASS=000000
OBJECT_DISK=vdb2
STORAGE_LOCAL_NET_IP=172.16.1.199
HEAT_DBPASS=000000
HEAT_PASS=000000
ZUN_DBPASS=000000
ZUN_PASS=000000
KURYR_DBPASS=000000
KURYR_PASS=000000
CEILOMETER_DBPASS=000000
CEILOMETER_PASS=000000
AODH_DBPASS=000000
AODH_PASS=000000
BARBICAN_DBPASS=000000
BARBICAN_PASS=000000
controller和compute安装重启
xxxxxxxxxx
iaas-pre-host.sh
reboot
2.数据库安装
controller
在运行脚本
xxxxxxxxxx
iaas-install-mysql.sh
安装完后登入数据库中创建chinaskilldb库,在chinaskilldb库中创建表testable (id int not null primary key,Teamname varchar(50), remarks varchar(255)),在表中插入记录(1,“cloud”,“chinaskill”)
xxxxxxxxxx
mysql -u root -p000000
create 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
xxxxxxxxxx
sed -i 's/64/256/g' /etc/sysconfig/memcached
使用rabbitmq命令 创建用户,并设置Administrators限权
xxxxxxxxxx
rabbitmqctl set_permissions chinaskill ".*" ".*" ".*"
3.安装keystone
controller
运行脚本安装
xxxxxxxxxx
iaas-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
运行脚本安装
xxxxxxxxxx
iaas-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
xxxxxxxxxx
iaas-install-nova-controller.sh
compute
xxxxxxxxxx
iaas-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
xxxxxxxxxx
iaas-install-neutron-controller.sh
compute
xxxxxxxxxx
iaas-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
xxxxxxxxxx
iaas-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
xxxxxxxxxx
iaas-install-cinder-controller.sh
compute
xxxxxxxxxx
iaas-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
xxxxxxxxxx
iaas-install-swift-controller.sh
compute
xxxxxxxxxx
iaas-install-swift-compute.sh
10.安装Heat编配服务
controller
xxxxxxxxxx
iaas-install-heat.sh
11.安装Zun服务
controller
xxxxxxxxxx
iaas-install-zun-controller.sh
compute
xxxxxxxxxx
iaas-install-zun-compute.sh
上传docker镜像CentOS7_1804.tar到glance,并且通过docker镜像启动容器
xxxxxxxxxx
[root@controller images]# ls
CentOS_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
xxxxxxxxxx
iaas-install-ceilometer-controller.sh
compute
xxxxxxxxxx
iaas-install-ceilometer-compute.sh
13.安装Aodh监控服务
controller
xxxxxxxxxx
iaas-install-aodh.sh
14.添加控制节点资源到云平台
controller
修改openrc.sh
xxxxxxxxxx
旧
HOST_IP_NODE=172.16.1.199
HOST_NAME_NODE=compute
新
HOST_IP_NODE=172.16.1.198
HOST_NAME_NODE=controller
xxxxxxxxxx
iaas-install-nova-compute.sh
执行过程中需要确认登录controller节点和输入controller节点root用户密码
评论 (0)