虛擬機器的封裝 rhel6.5
阿新 • • 發佈:2019-02-13
首先需要安裝rhel6.5的映象,我這是從伺服器上直接安裝的,可以先下載一個映象到本地
URL : //172.25.254.250/rhel6.5
RAM : 512
安裝是注意取掉IPV6選項
(1)gentenforce 獲取selinux狀態
iptables -L 獲取防火牆策略
(2)vi /etc/sysconfig/selinux
SELINUX=disabled ##關閉selinx
(3)cd /etc/init.d
ls
/etc/init.d/iptablesstop ##關閉防火牆
(4)chkconfig --list iptables ##檢視iptables的執行等級
runlevel ##檢視當前執行等級
chkconfig iptablesoff ##將所有等級都關閉,不自啟動
(5)cd ~
rm -f *
cd /etc/udev/rhles.d/
ls
60-raw.rules 70-persistent-net.rules
rm -fr70-persistent-net.rules ##必須刪除,否則一次建立的虛擬機器沒有網絡卡
(6)cd /etc/sysconfig/network
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
#IPADDR=172.25.6.1
#PREFIX=24
(7)cd /etc/yum.repo.d
vi rhel-source
[rhel-source]
name=Red HatEnterprise Linux $releasever - $hasearch - Sorce
baseurl=//172.25.254.6/rhel6.5
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
(8)yum repolist ##檢視yum源是否配置好
yum install -y vim lftpopenssh-clients
vi rhel-source
[rhel-source]
name=Red HatEnterprise Linux $releasever - $hasearch - Sorce
baseurl=//172.25.6.250/rhel6.5
##172.25.6.250主機上需要掛在6.5的映象
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
(9)cd /etc/ssh
ls
rm -fr ssh_host_*
(10)service sshd start
(11)hostname server1.example.com
vim/etc/syscomfig/network
HOSTNAME=server1.example.com
(12)vim /etc/hosts
172.25.6.1 server1.example.com
172.25.6.2 server2.example.com
172.25.6.3 server3.example.com
172.25.6.4 server4.example.com
172.25.6.5 server5.example.com
172.25.6.6 server6.example.com
(13)reboot
(14)刪除
(15)cd /var/lib/libvirt
cdimages
qemu-imgcreate -f qcow2 -b rhel6.5.qcow2 server1
qemu-imgcreate -f qcow2 -b rhel6.5.qcow2server2 ##快照
(16)安裝虛擬機器時選擇import existing disk image
安裝完成後
cd /etc/sysconfig/network-scripts
DEVICE="eth0"
BOOTPROTO="none"
ONBOOT="yes"
IPADDR=172.25.6.1
PREFIX=24
cd /etc/hosts
HOSTNAME=server1.example.com
(17)如果用ssh連線時,顯示key錯誤,只需
vim.ssh/known_hosts
刪除含有0.1的那一行
URL : //172.25.254.250/rhel6.5
RAM : 512
安裝是注意取掉IPV6選項
(1)gentenforce 獲取selinux狀態
iptables -L 獲取防火牆策略
(2)vi /etc/sysconfig/selinux
SELINUX=disabled ##關閉selinx
(3)cd /etc/init.d
ls
/etc/init.d/iptablesstop ##關閉防火牆
(4)chkconfig --list iptables ##檢視iptables的執行等級
runlevel ##檢視當前執行等級
chkconfig iptablesoff ##將所有等級都關閉,不自啟動
(5)cd ~
rm -f *
cd /etc/udev/rhles.d/
ls
60-raw.rules 70-persistent-net.rules
rm -fr70-persistent-net.rules ##必須刪除,否則一次建立的虛擬機器沒有網絡卡
(6)cd /etc/sysconfig/network
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
#IPADDR=172.25.6.1
#PREFIX=24
(7)cd /etc/yum.repo.d
vi rhel-source
[rhel-source]
name=Red HatEnterprise Linux $releasever - $hasearch - Sorce
baseurl=//172.25.254.6/rhel6.5
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
(8)yum repolist ##檢視yum源是否配置好
yum install -y vim lftpopenssh-clients
vi rhel-source
[rhel-source]
name=Red HatEnterprise Linux $releasever - $hasearch - Sorce
baseurl=//172.25.6.250/rhel6.5
##172.25.6.250主機上需要掛在6.5的映象
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
(9)cd /etc/ssh
ls
rm -fr ssh_host_*
(10)service sshd start
(11)hostname server1.example.com
vim/etc/syscomfig/network
HOSTNAME=server1.example.com
(12)vim /etc/hosts
172.25.6.1 server1.example.com
172.25.6.2 server2.example.com
172.25.6.3 server3.example.com
172.25.6.4 server4.example.com
172.25.6.5 server5.example.com
172.25.6.6 server6.example.com
(13)reboot
(14)刪除
(15)cd /var/lib/libvirt
cdimages
qemu-imgcreate -f qcow2 -b rhel6.5.qcow2 server1
qemu-imgcreate -f qcow2 -b rhel6.5.qcow2server2 ##快照
(16)安裝虛擬機器時選擇import existing disk image
安裝完成後
cd /etc/sysconfig/network-scripts
DEVICE="eth0"
BOOTPROTO="none"
ONBOOT="yes"
IPADDR=172.25.6.1
PREFIX=24
cd /etc/hosts
HOSTNAME=server1.example.com
(17)如果用ssh連線時,顯示key錯誤,只需
vim.ssh/known_hosts
刪除含有0.1的那一行