雲計算OpenStack學習筆記二:基本環境搭建

1.Centos7系統安裝

系統版本:CentOS-7-x86_64-DVD-1511.iso 虛擬機配置:2C-4G-20G-NAT 系統安裝注意事項:python

  • 網卡名稱:eth0
  • 時區:亞洲上海
  • 安全組策略(防火牆):關閉
  • 最小化安裝

1.1 網卡名稱修改

1.1.1 方法一

在安裝時使用內核命令net.ifnames=0 biosdevname=0可將網卡名稱改成傳統ethx的命名規則linux

1.1.2 方法二

如下內容引自 RHEL7/centos7修改網卡名稱爲eth0ios

根據紅帽官方文檔介紹,設備重命名的過程以下:vim

A rule in /usr/lib/udev/rules.d/60-net.rules instructs the udev helper utility,/lib/udev/rename_device,to look into all /etc/sysconfig/networkscripts/ifcfg-suffix files.If it finds an ifcfg file with a HWADDR entry matching the MAC address of an interface it renames the interface to the name given in the ifcfg file by the DEVICE directive.centos

/usr/lib/udev/rules.d/60-net.rules文件中的規則會讓udev幫助工具/lib/udev/renamedevice查看全部/etc/sysconfig/networkscripts/ifcfg-suffix文件。若是發現包含HWADDR條目的ifcfg文件與某個接口的MAC地址匹配,它會將該接口重命名爲ifcfg文件中由DEVICE指令給出的名稱。安全

根據以上介紹,進行網卡重命名:bash

1.ifconfig命令查看網卡配置網絡

[root@test01 ~]# ifconfig 
enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 192.168.56.101  netmask 255.255.255.0  broadcast 192.168.56.255
inet6 fe80::a00:27ff:fea5:4fd  prefixlen 64  scopeid 0x20<link>
ether 08:00:27:a5:04:fd  txqueuelen 1000  (Ethernet)
RX packets 1213  bytes 131145 (128.0 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 771  bytes 86683 (84.6 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
inet 127.0.0.1  netmask 255.0.0.0
inet6 ::1  prefixlen 128  scopeid 0x10<host>
loop  txqueuelen 0  (Local Loopback)
RX packets 1220  bytes 105112 (102.6 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 1220  bytes 105112 (102.6 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
複製代碼

由此可知,網卡MAC地址爲:08:00:27:a5:04:fd編輯器

2.重命名網卡配置文件工具

# 若是沒有網卡配置文件,能夠使用如下命令添加(命令行工具NetworkManager) 
[root@test01 network-scripts]# nmcli connection add type ethernet ifname enp0s9 con-name enp0s9 autoconnect yes 
複製代碼

[root@test01 network-scripts]# mv ifcfg-enp0s9 ifcfg-eth0

3.修改網卡配置文件

向配置文件中添加HWADDR,DEVICE,NAME參數。

4.拷貝配置文件60-net.rules並重啓

[root@test01 network-scripts]# cp /usr/lib/udev/rules.d/60-net.rules /etc/udev/rules.d/
[root@test01 network-scripts]# shutdown -r 0
複製代碼

1.2 手動分區

實際工做中無需boot和swap分區,只需一個分區便可。

分區

1.3 設置靜態IP

在ifcfg-eth0網卡配置文件中加入GATEWAY,IPADDR,DNS1,NETMASK,依照VMware中的虛擬網絡編輯器配置。

發現沒有vim編輯器,參考https://www.jianshu.com/p/96dbc05d3df1裝了

1.4 開啓網卡IPV6功能

在/etc/sysctl.conf文件中增長以下參數

net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
複製代碼

生效:sysctl -p

2.安裝基礎軟件源

安裝基本軟件

yum install -y wget yum-plugin-priorities

安裝軟件源

  • 備份和刪除自帶源
[root@controller ~]# mkdir -p /data/backup/repo
[root@controller ~]# mv /etc/yum.repos.d/* /data/backup/repo
複製代碼
  • 安裝阿里雲yum源
wget -O CentOS-Base-ali.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
複製代碼
  • 檢查
yum repolist
yum clean all && yum makecache fast && yum update -y
yum install tree lrzsz vim telnet net-tools bash-completion yum-utils -y
複製代碼
  • 禁止升級內核
# vim/etc/yum.conf
[main]
...
exclude=kernel*
exclude=centos-release*
複製代碼

3.網絡配置

關閉NetworkManager服務

systemctl stop NetworkManager
systemctl disable NetworkManager
複製代碼

網卡配置修改

加入NM_CONTROLLED="no"禁止NM管理網絡,加入IPV6設置

開啓網卡混雜模式(讓多種數據都能傳輸)

[root@controller network-scripts]# ifconfig eth0 promisc

將該命令設爲開機自動運行

[root@controller network-scripts]# echo 'ifconfig eth0 promisc' >> /etc/profile

消息服務

systemctl start messagebus
systemctl enable messagebus
複製代碼

防火牆

systemctl stop firewalld
systemctl disable firewalld
複製代碼

selinux

vim /etc/selinux/config

將enforcing改成disabled

修改hosts

將主機名映射寫入文件

4.OpenStack環境搭建

  • 軟件源配置

修改OpenStack源地址爲阿里雲的地址

wget -O /etc/yum.repos.d/Ali-pike.repo http://elven.vip/ks/openstack/Ali-queens.repo

  • 檢查
yum repolist
yum makecache fast
複製代碼
  • 安裝OpenStack客戶端

[root@controller yum.repos.d]# yum install -y python-openstackclient openstack-selinux yum-plugin-priorities openstack-utils

  • 時間同步
yum install ntpdate
ntpdate -u time1.aliyun.com
複製代碼

編輯自動運行腳本

crontab -e

添加內容:*/5 * * * * /usr/sbin/ntpdate -u time1.aliyun.com >> /dev/null 2>&1 &

  • 拍攝快照並基於快照建立計算節點computer

修改ip地址

修改主機名:hostnamectl set-hostname computer

  • 安裝計算節點基本軟件

yum install -y qemu-kvm libvirt bridge-utils

  • 將qemu鏈接到/ust/bin/qemu

ln -sv /usr/libexec/qemu-kvm /usr/bin/qemu

相關文章
相關標籤/搜索