openstack私有云搭建(2023年私有云)

一、修改主机名(所有节点)
[root@controller ~]# hostnamectl set-hostname controller
[root@controller ~]# hostname
controller 
[root@compute ~]# hostnamectl set-hostname compute
[root@compute ~]# hostname
compute
[root@compute ~]# 
二、配置主机名映射(所有节点)
[root@controller ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.4 controller
192.168.200.89 compute
[root@compute ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.4 controller
192.168.200.89 compute
三、配置YUM源(所有节点)
[root@controller ~]# rm -rf /etc/yum.repos.d/*
[root@controller ~]# cat /etc/yum.repos.d/local.repo 
[centos]
name=centos
baseurl=http://192.168.200.159/centos/
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=http://192.168.200.159/iaas/iaas-repo
gpgcheck=0
enabled=1
[root@compute ~]# rm -rf /etc/yum.repos.d/*
[root@compute ~]# cat /etc/yum.repos.d/local.repo 
[centos]
name=centos
baseurl=http://192.168.200.159/centos/
gpgcheck=0
enabled=1
[iaas]
name=iaas
baseurl=http://192.168.200.159/iaas/iaas-repo
gpgcheck=0
enabled=1
四、配置免密登录(controller节点)
[root@controller ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:K36rKn8ounJCrhgnbilv2bJuC0H7iMznOGYMCgbM79M root@controller
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|o.               |
|oo.              |
|o..     S        |
|*+o.     .       |
|&++=... .        |
|B&%ooE...        |
|%%*O+ooo..       |
+----[SHA256]-----+
[root@controller ~]# 
[root@controller ~]# ssh-copy-id controller
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'controller (192.168.200.4)' can't be established.
ECDSA key fingerprint is SHA256:molES9e8Fjgg1JSWMT5bRTg2l5A56dR4ReinDM2o4Ls.
ECDSA key fingerprint is MD5:56:ce:b3:a6:84:b0:d1:d0:b9:01:20:b3:4d:5e:e5:13.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@controller's password: 
​
Number of key(s) added: 1
​
Now try logging into the machine, with:   "ssh 'controller'"
and check to make sure that only the key(s) you wanted were added.
​
[root@controller ~]# 
[root@controller ~]# ssh-copy-id compute
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@compute's password: 
​
Number of key(s) added: 1
​
Now try logging into the machine, with:   "ssh 'compute'"
and check to make sure that only the key(s) you wanted were added.
​
[root@controller ~]# 
五、安装openstack(所有节点)
[root@controller ~]# yum -y install openstack-iaas
Loaded plugins: fastestmirror
Determining fastest mirrors
centos                                                                                                                                                               | 3.6 kB  00:00:00     
iaas                                                                                                                                                                 | 2.9 kB  00:00:00     
(1/3): centos/group_gz                                                                                                                                               | 153 kB  00:00:00     
(2/3): iaas/primary_db                                                                                                                                               | 597 kB  00:00:00     
(3/3): centos/primary_db                                                                                                                                             | 3.3 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package openstack-iaas.noarch 0:2.0.1-2 will be installed
--> Finished Dependency Resolution
​
Dependencies Resolved
​
============================================================================================================================================================================================
 Package                                            Arch                                       Version                                       Repository                                Size
============================================================================================================================================================================================
Installing:
 openstack-iaas                                     noarch                                     2.0.1-2                                       iaas                                      27 k
​
Transaction Summary
============================================================================================================================================================================================
Install  1 Package
​
Total download size: 27 k
Installed size: 133 k
Downloading packages:
openstack-iaas-2.0.1-2.noarch.rpm                                                                                                                                    |  27 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : openstack-iaas-2.0.1-2.noarch                                                                                                                                            1/1 
  Verifying  : openstack-iaas-2.0.1-2.noarch                                                                                                                                            1/1 
​
Installed:
  openstack-iaas.noarch 0:2.0.1-2                                                                                                                                                           
​
Complete!
[root@compute ~]# yum -y install openstack-iaas
Loaded plugins: fastestmirror
Determining fastest mirrors
centos                                                                                                                                                               | 3.6 kB  00:00:00     
iaas                                                                                                                                                                 | 2.9 kB  00:00:00     
(1/3): centos/group_gz                                                                                                                                               | 153 kB  00:00:00     
(2/3): iaas/primary_db                                                                                                                                               | 597 kB  00:00:00     
(3/3): centos/primary_db                                                                                                                                             | 3.3 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package openstack-iaas.noarch 0:2.0.1-2 will be installed
--> Finished Dependency Resolution
​
Dependencies Resolved
​
============================================================================================================================================================================================
 Package                                            Arch                                       Version                                       Repository                                Size
============================================================================================================================================================================================
Installing:
 openstack-iaas                                     noarch                                     2.0.1-2                                       iaas                                      27 k
​
Transaction Summary
============================================================================================================================================================================================
Install  1 Package
​
Total download size: 27 k
Installed size: 133 k
Downloading packages:
openstack-iaas-2.0.1-2.noarch.rpm                                                                                                                                    |  27 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : openstack-iaas-2.0.1-2.noarch                                                                                                                                            1/1 
  Verifying  : openstack-iaas-2.0.1-2.noarch                                                                                                                                            1/1 
​
Installed:
  openstack-iaas.noarch 0:2.0.1-2                                                                                                                                                           
​
Complete!
[root@compute ~]# 
六、磁盘分区(compute节点)
[root@compute ~]# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0  100G  0 disk 
└─vda1 253:1    0  100G  0 part /
vdb    253:16   0   50G  0 disk 
[root@compute ~]# fdisk /dev/vdb 
Welcome to fdisk (util-linux 2.23.2).
​
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
​
​
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-104857599, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +20G
Partition 1 of type Linux and of size 20 GiB is set
​
Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 
First sector (41945088-104857599, default 41945088): 
Using default value 41945088
Last sector, +sectors or +size{K,M,G} (41945088-104857599, default 104857599): +20G
Partition 2 of type Linux and of size 20 GiB is set
​
Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 
First sector (83888128-104857599, default 83888128): 
Using default value 83888128
Last sector, +sectors or +size{K,M,G} (83888128-104857599, default 104857599): +5G
Partition 3 of type Linux and of size 5 GiB is set
​
Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): p
Selected partition 4
First sector (94373888-104857599, default 94373888): 
Using default value 94373888
Last sector, +sectors or +size{K,M,G} (94373888-104857599, default 104857599): 
Using default value 104857599
Partition 4 of type Linux and of size 5 GiB is set
​
Command (m for help): w
The partition table has been altered!
​
Calling ioctl() to re-read partition table.
Syncing disks.
[root@compute ~]# 
[root@compute ~]# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0  100G  0 disk 
└─vda1 253:1    0  100G  0 part /
vdb    253:16   0   50G  0 disk 
├─vdb1 253:17   0   20G  0 part 
├─vdb2 253:18   0   20G  0 part 
├─vdb3 253:19   0    5G  0 part 
└─vdb4 253:20   0    5G  0 part 
七、修改openstack配置文件(所有节点)
[root@controller ~]# cd /etc/openstack/
[root@controller openstack]# ls
octavia  openrc.sh
[root@controller openstack]# sed -i -e"s/PASS=/PASS=000000/" -e 's/^#//g' openrc.sh
[root@controller openstack]# cat openrc.sh 
#--------------------system Config--------------------##
#Controller Server Manager IP. example:x.x.x.x
HOST_IP=192.168.200.4
​
#Controller HOST Password. example:000000 
HOST_PASS=000000
​
#Controller Server hostname. example:controller
HOST_NAME=controller
​
#Compute Node Manager IP. example:x.x.x.x
HOST_IP_NODE=192.168.200.89
​
#Compute HOST Password. example:000000 
HOST_PASS_NODE=000000
​
#Compute Node hostname. example:compute
HOST_NAME_NODE=compute
​
#--------------------Chrony Config-------------------##
#Controller network segment IP.  example:x.x.0.0/16(x.x.x.0/24)
network_segment_IP=192.168.200.0/24
​
#--------------------Rabbit Config ------------------##
#user for rabbit. example:openstack
RABBIT_USER=openstack
​
#Password for rabbit user .example:000000
RABBIT_PASS=000000
​
#--------------------MySQL Config---------------------##
#Password for MySQL root user . exmaple:000000
DB_PASS=000000
​
#--------------------Keystone Config------------------##
#Password for Keystore admin user. exmaple:000000
DOMAIN_NAME=demo
ADMIN_PASS=000000
DEMO_PASS=000000
​
#Password for Mysql keystore user. exmaple:000000
KEYSTONE_DBPASS=000000
​
#--------------------Glance Config--------------------##
#Password for Mysql glance user. exmaple:000000
GLANCE_DBPASS=000000
​
#Password for Keystore glance user. exmaple:000000
GLANCE_PASS=000000
​
#--------------------Placement Config----------------------##
#Password for Mysql placement user. exmaple:000000
PLACEMENT_DBPASS=000000
​
#Password for Keystore placement user. exmaple:000000
PLACEMENT_PASS=000000
​
#--------------------Nova Config----------------------##
#Password for Mysql nova user. exmaple:000000
NOVA_DBPASS=000000
​
#Password for Keystore nova user. exmaple:000000
NOVA_PASS=000000
​
#--------------------Neutron Config-------------------##
#Password for Mysql neutron user. exmaple:000000
NEUTRON_DBPASS=000000
​
#Password for Keystore neutron user. exmaple:000000
NEUTRON_PASS=000000
​
#metadata secret for neutron. exmaple:000000
METADATA_SECRET=000000
​
#External Network Interface. example:eth1
INTERFACE_NAME=eth1
​
#External Network The Physical Adapter. example:provider
Physical_NAME=provider
​
#First Vlan ID in VLAN RANGE for VLAN Network. exmaple:101
minvlan=1
​
#Last Vlan ID in VLAN RANGE for VLAN Network. example:200
maxvlan=1000
​
#--------------------Cinder Config--------------------##
#Password for Mysql cinder user. exmaple:000000
CINDER_DBPASS=000000
​
#Password for Keystore cinder user. exmaple:000000
CINDER_PASS=000000
​
#Cinder Block Disk. example:md126p3
BLOCK_DISK=vdb1
​
#--------------------Swift Config---------------------##
#Password for Keystore swift user. exmaple:000000
SWIFT_PASS=000000
​
#The NODE Object Disk for Swift. example:md126p4.
OBJECT_DISK=vdb2
​
#The NODE IP for Swift Storage Network. example:x.x.x.x.
STORAGE_LOCAL_NET_IP=192.168.200.89
​
#--------------------Trove Config----------------------##
#Password for Mysql trove user. exmaple:000000
TROVE_DBPASS=000000
​
#Password for Keystore trove user. exmaple:000000
TROVE_PASS=000000
​
#--------------------Heat Config----------------------##
#Password for Mysql heat user. exmaple:000000
HEAT_DBPASS=000000
​
#Password for Keystore heat user. exmaple:000000
HEAT_PASS=000000
​
#--------------------Ceilometer Config----------------##
#Password for Gnocchi ceilometer user. exmaple:000000
CEILOMETER_DBPASS=000000
​
#Password for Keystore ceilometer user. exmaple:000000
CEILOMETER_PASS=000000
​
#--------------------AODH Config----------------##
#Password for Mysql AODH user. exmaple:000000
AODH_DBPASS=000000
​
#Password for Keystore AODH user. exmaple:000000
AODH_PASS=000000
​
#--------------------ZUN Config----------------##
#Password for Mysql ZUN user. exmaple:000000
ZUN_DBPASS=000000
​
#Password for Keystore ZUN user. exmaple:000000
ZUN_PASS=000000
​
#Password for Keystore KURYR user. exmaple:000000
KURYR_PASS=000000
​
#--------------------OCTAVIA Config----------------##
#Password for Mysql OCTAVIA user. exmaple:000000
OCTAVIA_DBPASS=000000
​
#Password for Keystore OCTAVIA user. exmaple:000000
OCTAVIA_PASS=000000
​
#--------------------Manila Config----------------##
#Password for Mysql Manila user. exmaple:000000
MANILA_DBPASS=000000
​
#Password for Keystore Manila user. exmaple:000000
MANILA_PASS=000000
​
#The NODE Object Disk for Manila. example:md126p5.
SHARE_DISK=vdb3
​
#--------------------Cloudkitty Config----------------##
#Password for Mysql Cloudkitty user. exmaple:000000
CLOUDKITTY_DBPASS=000000
​
#Password for Keystore Cloudkitty user. exmaple:000000
CLOUDKITTY_PASS=000000
​
#--------------------Barbican Config----------------##
#Password for Mysql Barbican user. exmaple:000000
BARBICAN_DBPASS=000000
​
#Password for Keystore Barbican user. exmaple:000000
BARBICAN_PASS=000000
###############################################################
#####在vi编辑器中执行:%s/^.\{1\}//  删除每行前1个字符(#号)#####
###############################################################
[root@controller openstack]# scp openrc.sh root@compute:/etc/openstack/
openrc.sh                                                                                                                                                 100% 4962     2.5MB/s   00:00 
八、执行脚本(所有节点)
#执行完这两个脚本重启一下这两台机子
[root@controller openstack]# iaas-pre-host.sh 
[root@compute ~]# iaas-pre-host.sh 

重启完之后,继续执行脚本(controller节点)

#等controller节点的这些脚本成功执行完了之后,在执行compute节点的脚本
iaas-install-mysql.sh && iaas-install-keystone.sh && iaas-install-glance.sh \
&& iaas-install-placement.sh && iaas-install-nova-controller.sh \
&& iaas-install-neutron-controller.sh && iaas-install-dashboard.sh \
&& iaas-install-cinder-controller.sh && iaas-install-swift-controller.sh  \
&& iaas-install-heat.sh && iaas-install-manila-controller.sh \
&& iaas-install-cloudkitty.sh && iaas-install-barbican.sh

(上面这些脚本执行完,compute节点执行脚本)

iaas-install-nova-compute.sh  && iaas-install-neutron-compute.sh \
&& iaas-install-cinder-compute.sh && iaas-install-swift-compute.sh \
&& iaas-install-manila-compute.sh 

(openstack搭建完成!)

你可能感兴趣的:(云计算,openstack,云计算)