练习软件:VMware WorkStation
主机 | CPU | 内存 | 双网卡 | 操作系统 |
---|---|---|---|---|
控制节点-ct | 双核双线程-开启虚拟化 | 8G 硬盘 300G + 1024G |
NAT:192.168.126.21 VMnet1:192.168.100.11 |
CentOS 7-9 最小化安装 |
计算节点-c1 | 双核双线程-开启虚拟化 | 8G 硬盘 300G + 1024G |
NAT:192.168.126.22 VMnet1:192.168.100.12 |
CentOS 7-9 最小化安装 |
计算节点-c1 | 双核双线程-开启虚拟化 | 8G 硬盘 300G + 1024G |
NAT:192.168.126.23 VMnet1:192.168.100.13 |
CentOS 7-9 最小化安装 |
注:以下三台节点同步配置
1.相关配置不再复述,因为过于简单,这里直接说思路
2.两块网卡,ens33为主网卡,配置为NAT,第二块网卡配置为VMnet1,配置完毕后重启生效
3.在线源不需要感情去挂载使用,它只有一个老婆,那就是网卡配置文件,网关及DNS一定要配置完善!
4.以下给贴处在线源配置的代码
----
cd /etc/yum.repos.d
mv *.repo repos.bak/
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#建议在线源多下载两次,有时可能不是最新状态
yum clean all && yum makecache fast
#fast:这个选项将软件包信息提前在本地缓存一份,用来提高搜索安装软件的速度
hostnamectl set-hostname ct //c1/c2
su
--
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
vim /etc/sysconfig/selinux
SELINUX=disabled
多下载安装几次,一直到看到出现软件包已安装并且是最新版本为止,因为有时可能会漏装!
yum -y install net-tools bash-completion vim gcc gcc-c++ make pcre pcre-devel expat-devel cmake bzip2 lrzsz
#EXPAT是C语言发开库
yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils
#OpenStack的train版本仓库源安装包、OpenStack客户端及openstack-selinux安装包
1.修改主网卡(NAT)
IPV4_ROUTE_METRIC=90 #增加此配置,调优优先级,NAT网卡优先
--
2.修改第二块网卡(VMnet1)
#GATEWAY=192.168.100.2 #注释掉网关
vim /etc/hosts
192.168.100.11 ct
192.168.100.12 c1
192.168.100.13 c2
#以上为局域网内的IP
使用非对称密钥,即有公钥和私钥的一种保密方法
ssh-keygen -t rsa //空格确认即可
ssh-copy-id ct
ssh-copy-id c1
ssh-copy-id c2
--
#参数 -t rsa 表示使用rsa算法进行加密,执行后,会在/home/当前用户/.ssh目录下找到id_rsa(私钥)和id_rsa.pub(公钥)
#将本机的公钥复制到远程机器中
--
vim /etc/resolv.conf
nameserver 8.8.8.8
nameserver 114.114.114.114
#一般网卡配置后这里会自动生成
操作步骤:
ct -> 同步阿里云时钟服务器
c1/c2 -> 同步ct
----
ct(192.168.100.11):
yum install chrony -y
vim /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 ntp6.aliyun.com iburst //配置阿里云时钟服务器源,iburst表示尽快同步
allow 192.168.100.0/24 //允许192.168.100.0/24网段的主机来同步时钟服务
--
#这里为什么是ntp6呢,阿里云时钟服务器源不止一个
#不加数字6即为默认,使用人数最多,所以会有一定时延影响
--
chronyc sources //查询时间同步信息
----
c1/c2(192.168.100.12/13):
vim /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 ct iburst //指向ct
----
systemctl enable chronyd.service
systemctl restart chronyd.service
chronyc sources
crontab -e
*/5 * * * * /usr/bin/chronyc sources >>/var/log/chronyc.log
crontab -l
ct(192.168.100.11):
yum -y install mariadb mariadb-server python2-PyMySQL
#此包用于openstack的控制端连接mysql所需要的模块,如果不安装,则无法连接数据库
yum -y install libibverbs
--
vim /etc/my.cnf.d/openstack.cnf
#添加MySQL子配置文件,增加如下内容
[mysqld]
bind-address = 192.168.100.11
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
#详解:
[mysqld]
bind-address = 192.168.100.11 //控制节点局域网地址
default-storage-engine = innodb //默认存储引擎
innodb_file_per_table = on //每张表独立表空间文件
max_connections = 4096 //最大连接数
collation-server = utf8_general_ci //默认字符集
character-set-server = utf8 //字符集类型,避免乱码
--
systemctl enable mariadb
systemctl start mariadb
--
mysql_secure_installation
#执行MariaDB安全配置脚本
Enter current password for root (enter for none): //回车
OK, successfully used password, moving on...
Set root password? [Y/n] Y //设置root密码?
Remove anonymous users? [Y/n] Y //删除匿名用户?
... Success!
Disallow root login remotely? [Y/n] N //是否不允许root用户远程登陆?
... skipping.
Remove test database and access to it? [Y/n] Y //是否删除test测试库?
Reload privilege tables now? [Y/n] Y //现在重新加载特权表?
- 所有创建虚拟机的指令,控制端都会发送到 rabbitmq
- node 节点监听 rabbitmq
yum -y install rabbitmq-server
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
--
rabbitmqctl add_user openstack RABBIT_PASS
#创建消息队列用户,用于controler和计算节点连接rabbitmq的认证(关联)
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
#配置openstack用户的操作权限(正则,配置读写权限)
--
netstat -natp | grep 25672
#567是Rabbitmq默认端口
netstat -natp | grep 5672
#25672是Rabbit的测试工具CLI的端口
--
rabbitmq-plugins list
#查看rabbitmq插件列表
rabbitmq-plugins enable
#开启rabbitmq的web管理界面的插件,端口为15672
--
ss -natp | grep 5672
#检查端口
1.浏览器访问"192.168.126.21:15672"
2.账号密码默认均为"guest"
- 安装 memcached 是用于存储 session 信息
- 服务身份验证机制(keystone)使用 Memcached 来缓存令牌
- 在登录 openstack 的 dashboard 时,会产生一些 session 信息,这些 session 信息会存放到 memcached 中
yum install -y memcached python-memcached
#python-*模块在OpenStack中起到连接数据库的作用
cat /etc/sysconfig/memcached
#查看Memcached配置文件
--
systemctl enable memcached
systemctl start memcached
netstat -nautp | grep 11211
yum -y install etcd
#安装etcd
cd /etc/etcd/
vim etcd.conf
#修改etcd配置文件,可全部删除后加入以下配置
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.100.11:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.100.11:2379"
ETCD_NAME="ct"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.100.11:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.100.11:2379"
ETCD_INITIAL_CLUSTER="ct=http://192.168.100.11:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"
--
#详解如下:
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
#数据目录位置
ETCD_LISTEN_PEER_URLS="http://192.168.100.11:2380"
#监听其他etcd member的url(2380端口,集群之间通讯,域名为无效值)
ETCD_LISTEN_CLIENT_URLS="http://192.168.100.11:2379"
#对外提供服务的地址(2379端口,集群内部的通讯端口)
ETCD_NAME="ct"
#集群中节点标识(名称)
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.100.11:2380"
#该节点成员的URL地址,2380端口:用于集群之间通讯
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.100.11:2379"
#对外公告的该节点客户端监听地址
ETCD_INITIAL_CLUSTER="ct=http://192.168.100.11:2380"
#
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
#集群唯一标识
ETCD_INITIAL_CLUSTER_STATE="new"
#初始集群状态,new为静态,若为existing,则表示此ETCD服务将尝试加入已有的集群若为DNS,则表示此集群将作为被加入的对象
systemctl enable etcd.service
systemctl start etcd.service
netstat -anutp | grep 2379
netstat -anutp | grep 2380
#2379为对外提供服务的端口,2380为集群内部之间的通讯端口
yum -y install centos-release-openstack-train python-openstackclient openstack-selinux openstack-utils