【失败】制作CentOS镜像
1.在vmware上安装centos虚拟机,安装过程中设置CPU时,点选 虚拟化Intel VT-x~ 和 虚拟化CPU性能计数器,网络使用NAT模式
2.#mkdir /opt/iso,上传镜像(用VMwareTool)
3.安装软件:
#yum groupinstall Virtualization "Virtualization Client"
#yum install libvirt -y
#yum -y install tigervnc
4.设置虚拟网络支持
启动libvirtd服务:#service libvirtd restart
允许ip路由转发:编辑/etc/sysctl.conf文件,修改net.ipv4.ip_forward = 1
使修改生效:#sysctl -p
5.创建镜像文件
#mkdir /opt/image
#cd /opt/image
#qemu-img create -f qcow2 CentOS6.6_try.img 10G
#chown qemu. /opt/image -R
注意:10G表示创建的镜像大小,因为bcec支持根分区扩展,因此,对于普通的linux,windows镜像来说,10G足够,如果填写过大,反而会无法创建小模板的虚拟机,将linux所有的包都装上需要配置30G
切换到图形界面
#virt-install -n CentOSimg -r 1024 --cpu host -c /opt/iso/CentOS-6.6-x86_64-bin-DVD1.iso --disk path=/opt/image/CentOS6.6_try.img,device=disk,bus=virtio,size=10,format=qcow2 --vnc --vncport=5900 --vnclisten=0.0.0.0 -v
注意:1024 代表内存1024M,10 代表硬盘大小为10G
使用上述命令会自动启动一个安装界面,但建议改为使用vncview访问安装界面:vncviewer 127.0.0.1
图形安装过程中,选择磁盘分区时,需要选择手动分区,而且不要使用lvm,不要分配swap分区:
1.选择Create Custom Layout
2.只留下dev/hda(vda),删除其它分区
3.双击此分区,设置挂载点为/,类型为ext3,size填1,选中fill to maximum allowable size和force to be a primary partition。
wget http://10.254.3.75/images/configdrive/disk.config,下载disk.config,开始配置:
更换iso
#virsh dumpxml CentOSimg >centos2.xml
vim centos2.xml,修改device='cdrom'的iso路径 <source file='/opt/iso/disk.config'/>
#virsh undefine CentOSimg
#virsh define centos2.xml
启动镜像:
#virsh start CentOSimg
注意:这一次重新启动和上一次启动的区别在于,将安装光盘去掉,将disk.config加入
以下在创建的虚机CentOSimg中操作(vncviewer 127.0.0.1)
1、关闭防火墙
[root@localhost ~]# chkconfig iptables off
2、关闭Avahi
[root@localhost ~]# chkconfig avahi-daemon off
3、关闭Selinux
[root@localhost ~]# vi /etc/selinux/config
SELINUX=disabled
4、配置SSH
[root@localhost ~]# vi /etc/ssh/sshd_config
UseDNS=no(是否开启DNS域名查找)
GSSAPIAuthentication=no(是否允许使用基于GSSAPI的用户认证)
PermitRootLogin=yes(是否允许Root登陆)
PasswordAuthentication=yes(是否开启密码认证)
[root@localhost ~]# vi /etc/nsswitch.conf
hosts:files dns(解析主机名的顺序,如果不希望DNS解析,则删除dns)
5、查看网络状态
先在VMware里查看之前安装的libvirtd是否运行:/etc/init.d/libvirtd status
libvirtd (pid 2787) is running...
在CentOSimg里配置网络:vi /etc/sysconfig/network-scripts/ifcfg-eth0
修改ONBOOT=yes
重启网络: /etc/init.d/network restart
之后ping一下baidu试试通否
6、电源配置
安装电源模块
[root@localhost ~]# yum install acpid -y #-y的作用是自动在安装过程中输入yes#
设置电源模块开机启动
[root@localhost ~]# chkconfig acpid on
修改配置文件
[root@localhost ~]# vi /etc/acpi/events/power.conf
event=button/power.*
# action=/etc/acpi/actions/power.sh(注释此行,并增加下面一行)
action=/sbin/shutdown –h now
7、安装cloud-init
[root@localhost ~]# yum install http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@localhost ~]# yum install cloud-init
8、安装文件系统扩容工具linux-rootfs-resize
[root@localhost ~]# cd /opt
[root@localhost~]# rpm -ivh http://ftp-stud.hs-esslingen.de/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[root@localhost ~]# yum install git parted cloud-utils
[root@localhost ~]# git clone https://github.com/flegmatik/linux-rootfs-resize.git
[root@localhost ~]# cd linux-rootfs-resize/distro/centos-6
[root@localhost ~]# vi mod
删掉 resize2fs -p /dev/${root_dev}${part_num} 这一行
[root@localhost ~]# cd ../..
[root@localhost ~]# ./install
9、修改grub.conf,使启动日志能够在dashboard上显示
[root@localhost ~]# vi /boot/grub/grub.conf
在kernel /boot/vmlinuz-2.6.32-431.el6.x86_64-mod ro后面加console=tty0 console=ttyS0,
即变为:kernel /boot/vmlinuz-2.6.32-431.el6.x86_64-mod ro console=tty0 console=ttyS0 root=UUID=82574b46-8e40-4c73-b2ac-9f06f5a805b7
10、安装ovirt-guest-agent
# yum install ovirt-guest-agent -y
11、修改文件/etc/udev/rules.d/55-ovirt-guest-agent.rules
在SYMLINK=="virtio-ports/com.redhat.rhevm.vdsm", OWNER="ovirtagent", GROUP="ovirtagent"后添加:
SYMLINK=="virtio-ports/com.redhat.rhevm.vdsm.0", OWNER="ovirtagent", GROUP="ovirtagent"
12、配置cloud-init
编辑/etc/cloud/cloud.cfg,内容如下:
users:
- default
disable_root: 0
ssh_pwauth: 1
datasource_list: ['ConfigDrive']
locale_configfile: /etc/sysconfig/i18n
mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']
resize_rootfs_tmp: /dev
ssh_deletekeys: 0
ssh_genkeytypes: ~
syslog_fix_perms: ~
cloud_init_modules:
- bootcmd
- write-files
- resizefs
- set_hostname
- update_hostname
- update_etc_hosts
- rsyslog
- users-groups
- ssh
cloud_config_modules:
- mounts
- locale
- set-passwords
- timezone
- puppet
- chef
- salt-minion
- mcollective
- disable-ec2-metadata
- runcmd
cloud_final_modules:
- rightscale_userdata
- scripts-per-once
- scripts-per-boot
- scripts-per-instance
- scripts-user
- ssh-authkey-fingerprints
- keys-to-console
- phone-home
- final-message
system_info:
distro: rhel
default_user:
name: root
paths:
cloud_dir: /var/lib/cloud
templates_dir: /etc/cloud/templates
ssh_svcname: sshd
# vim:syntax=yaml
13、上述配置完成后,关机
二次配置
Vmware里启动这个镜像
#virsh start CentOSimg
以下在虚机中操作(vncviewer 127.0.0.1)
没有以下了,因为:
promote login: root
Password:
Login incorrect
无法登陆,放弃。。。
【失败】制作CentOS镜像的更多相关文章
- Docker自制CentOS镜像
系统环境:CentOS 7.3 将yum源切换到阿里源 可以直接写成一个脚本 #!/bin/sh mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos ...
- OpenStack镜像制作-CentOS
云平台中镜像还是很重要的,提供各种定制化的镜像使得用户体验更好. 最开始玩OpenStack的时候用的是安装文档中提到的cirros,其密码cubswin:) 刚开始感觉很怪,现在已经可以随手打出.p ...
- OpenStack手动制作CentOS 7 KVM镜像
在前面讲解KVM的时候,我们已经学习了如何制作KVM镜像,那么制作OpenStack使用的镜像和KVM是有一些区别的. 1. 下载CentOS 7官方ISO安装镜像这里使用国内阿里云的镜像源进行 ...
- 使用kvm制作Eucalyptus镜像(CentOS 6.5为例)
1.前言 Elastic Utility Computing Architecture for Linking Your Programs To Useful Systems (Eucalyptus) ...
- Docker 从零开始制作基础镜像[centos]
http://www.oschina.net/news/62897/docker-hub-contains-high-risk-vulnerabilities 这里有个统计,docker官方和个人发布 ...
- 关于Docker官方CentOS镜像无法启动mysqld的总结
很多童鞋反映,在Docker官方CentOS镜像中安装了Mysql server后,无法正常启动. 无法正常启动表现为两种情况: 1> 初始完数据库后,mysqld启动报错 2> syst ...
- Docker之dockerfile制作jdk镜像
目的: Dockerfile简介 Dockerfile制作jdk镜像 Dockerfile简介 了解dockerfile之前要先了解Docker基本概念和使用可参考:https://www.cnblo ...
- 7.8、如何制作openstack镜像
1.创建openstack-linux镜像: 下载已经做好的的镜像:https://docs.openstack.org/image-guide/obtain-images.html#centos ( ...
- Dockerfile自动制作Docker镜像(二)—— 其它常用命令
Dockerfile自动制作Docker镜像(二)-- 其它常用命令 前言 a. 本文主要为 Docker的视频教程 笔记. b. 环境为 CentOS 7.0 云服务器 c. 上一篇:Dockerf ...
随机推荐
- JavaScript性能优化:度量、监控与可视化1
HTTP事务所需要的步骤: 接下来,浏览器与远程Web服务器通过TCP三次握手协商来建立一个TCP/IP连接,类似对讲机的Over(完毕) Roger(明白) TCP/IP模型 TCP即传输控制协议( ...
- jsp简易文件上传(common.fileupload)
昨天开始重新架构我的V&View(维视),之前写文章使用的是一个kindediter的插件,挺好用的.最近不知道咋了,出现了些小问题.早在写V&View的时候就想用以下两种方法实现文章 ...
- storm的特性
storm的特性 Storm 是一个开源的分布式实时计算系统,可以简单.可靠地处理大量的数据流. Storm支持水平扩展,具有高容错性,保证每个消息都会得到处理,而且处理速度很快(在一个小集群中,每个 ...
- nyoj 915 +-字符串
+-字符串 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 Shiva得到了两个只有加号和减号的字符串,字串长度相同.Shiva一次可以把一个加号和它相邻的减号交换. ...
- PHP 判断用户是否手机访问
$agent = check_wap(); if( $agent ) { header('Location: http://www.lewanau.com'); exit; } // check if ...
- 算法之旅,直奔<algorithm>之十四 fill_n
fill_n(vs2010) 引言 这是我学习总结<algorithm>的第十四篇,作为fill的亲兄弟,fill_n也会助你一把的. 作用 fill_n 的作用是给一段指定长度的数据向量 ...
- Selenium 进行web自动化测试
1.安装火狐版本时注意,如果无法正常安装,应该点击右键---以管理员身份运行 2.安装成功后,选择工具--选项--高级--更新,停止其自动化更新 3.maven里面加载应有的selenium的组件
- servlet三大作用域:request,session,application
javaweb开发中Servlet三大域对象的应用(request.session.application(ServletContext)). 1. request request是表示一个请求,只要 ...
- iOS从生成证书到打包上架-02(详细2016-10最新)
由于篇幅的限制,这篇接着上一篇(关于证书)写的,有需要的小伙伴可以先阅读上一篇 2.在App Store创建应用 1.回到Account,点击iTunes Connect 2.点击我的App 3.点击 ...
- 更改cmd语言(chcp)
chcp 437 更改为英文 chcp 936 更改为简体中文 mode con cp select=437 mode con cp /status chcp cmd /c "chcp 43 ...