14.KVM安装之脚本和镜像目录树准备
1.php脚本需要先安装PHP环境,Apache服务器必须支持PHP
centos65_kvm.cfg
[c6-media]
name=CentOS-$releasever -Media
baseurl=http://192.168.10.10/centos/6/os/x86_64
gpgcheck=0
enabled=1
install
url --url="http://172.29.1.4/centos/6/os/x86_64/"
rootpw --iscrypted $1$J2XgJk6a$roQYKKcP7NzFfhvfb74XD.
auth --useshadow --passalgo=sha512
text
keyboard us
lang en_US
firewall --disabled
selinux --disabled
skipx
logging --level=info
reboot
timezone Asia/Shanghai
network --bootproto=dhcp --device=em1 --onboot=on
bootloader --location=mbr
zerombr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4"--size=512
part swap --fstype="swap"--size=16384
part /--fstype="ext4"--size=51200
part /opt --fstype="ext4"--grow --size=1
%post
repoip=172.29.1.4
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*repo /etc/yum.repos.d/bak/
cat >/etc/yum.repos.d/centos65.repo <<EOF
[Base]
name=centos65_x86_64 -Base
baseurl=http://$repoip/centos/6/os/x86_64
enable=1
gpgcheck=0
EOF
yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2
hwclock --set--date="`date +%D\ %T`"
hwclock --hctosys
sed -i 's/1024/102400/'/etc/security/limits.d/90-nproc.conf
sed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#'/etc/init/control-alt-delete.conf
>/etc/sysconfig/i18n
cat >>/etc/sysconfig/i18n << EOF
LANG="en_US.UTF-8"
EOF
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/'/etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/'/etc/ssh/sshd_config
service sshd restart
%packages
@base
%end
<?php
if($_GET){
header("Content-Type: text/plain");
define(HTTP_URL_BASE,"http://172.29.1.4");
$os_base = HTTP_URL_BASE ."/centos/6/os/x86_64";
$src_base = HTTP_URL_BASE ."/src";
$os_hostname = $_GET["hostname"];
if(!$os_hostname ){
$os_hostname ="localhost.localdomain";
}
$os_password = $_GET["pw"];
if(!$os_password ){
$os_password ="zgtx123.com";
}
#$os_version = $_GET["ver"];
#if( !$os_version ){
# $os_version = "6.5";
#}
$net_ipaddr_eth0 = $_GET["ip1"];
$net_ipaddr_eth1 = $_GET["ip2"];
if(!$net_ipaddr_eth1 ){
$remark="#";
}
$net_netmask = $_GET["mask"];
if(!$net_netmask ){
$net_netmask ="255.255.255.0";
}
$net_gateway = $_GET["gw"];
if(!$net_gateway){
$net_gateway ="172.29.1.254";
}
$net_gateway2 = $_GET["gw2"];
if(!$net_gateway2){
$net_gateway2 ="172.29.1.254";
}
$net_nameservers = $_GET["ns"];
if(!$net_nameservers){
$net_nameservers ="1.2.4.8,114.114.114.114";
}
$fs_type = $_GET["fs-type"];
$fs_auto_detect = false;
if(!$fs_type ){
$fs_type ="ext4";
$fs_auto_detect = true;
}
$disk_name = $_GET["disk"];
if(!$disk_name ){
$disk_name ="vda";
}
$boot_size = $_GET["boot-size"];
if(!$boot_size ){
$boot_size =512;
}
$swap_size = $_GET["swap-size"];
if(!$swap_size ){
$swap_size =1024*4;
}
?>
install
text
skipx
firewall --disabled
selinux --disabled
timezone Asia/Shanghai
key --skip
url --url=<?php echo $os_base ."\n";?>
rootpw <?php echo $os_password ."\n";?>
authconfig --enableshadow --enablemd5
keyboard us
lang en_US
logging --level=info
network --bootproto=static --device=eth0 --gateway=<?php echo $net_gateway;?>--ip=<?php echo $net_ipaddr_eth0;?>--nameserver=<?php echo $net_nameservers;?>--netmask=<?php echo $net_netmask;?>--hostname=<?php echo $os_hostname;?>--onboot=on
#<?php echo $remark;?>network --bootproto=static --device=eth1 --ip=<?php echo $net_ipaddr_eth1;?> --netmask=<?php echo $net_netmask;?> --onboot=on
bootloader --location=mbr <?php echo $disk_name ."\n";?>
zerombr
clearpart --all --initlabel --drives=<?php echo $disk_name ."\n";?>
part /boot --asprimary --fstype="<?php echo $fs_type; ?>"--size="<?php echo $boot_size; ?>"--ondisk=<?php echo $disk_name ."\n";?>
part swap --fstype="swap"--size="<?php echo $swap_size; ?>"--ondisk=<?php echo $disk_name ."\n";?>
part /--fstype="<?php echo $fs_type; ?>"--grow --size=1--ondisk=<?php echo $disk_name ."\n";?>
reboot
%post
#!/bin/bash
############################# disable ipv6 and iptables ######################################
rm -f /etc/sysconfig/iptables
rm -f /etc/sysconfig/ip6tables
echo "NETWORKING_IPV6=no">>/etc/sysconfig/network
echo "alias net-pf-10 off">>/etc/modprobe.d/dist.conf
echo "alias ipv6 off">>/etc/modprobe.d/dist.conf
chkconfig iptables off
chkconfig ip6tables off
############################# config yum #######################################################
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*repo /etc/yum.repos.d/bak/
cat >/etc/yum.repos.d/centos6-init.repo<<EOF
[base]
name=centos6
baseurl=http://172.29.1.4/centos/6/os/x86_64/
enable=1
gpgcheck=0
EOF
yum -y install openssh-clients openssl openssl-d* vim wget gcc gcc-c++ make autoconf nfs-utils ntpdate zip unzip lsof
yum clean all
###############################/etc/rc.local################################
cat >>/etc/rc.local<<EOF
mount 172.29.1.4:/opt/mirrors/src /opt/share_dir
EOF
mkdir -p /opt/share_dir
mount 172.29.1.4:/opt/mirrors/src /opt/share_dir
echo "* soft nofile 4096">>/etc/security/limits.conf
echo "* hard nofile 4096">>/etc/security/limits.conf
################################ ntp ###############################
#echo "1 * * * * /usr/sbin/ntpdate time.nist.gov" >/var/spool/cron/root
hwclock --set--date="`date +%D\ %T`"
hwclock --hctosys
############################### turnoff the control-alt-delete ####################
sed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#'/etc/init/control-alt-delete.conf
############################### set ssh ########################################
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/'/etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/'/etc/ssh/sshd_config
mkdir -p /root/.ssh/
################################ config zabbix ############################################################
#
#cat >/usr/local/etc/zabbix_agentd.conf<<EOF
#<?php echo 'SourceIP='.$net_ipaddr_eth0;echo "\n";?>
#Server=127.0.0.1,172.29.1.4
#ListenPort=10050
#ServerActive=172.29.1.4:10051
#<?php echo 'Hostname='.$os_hostname;echo "\n"?>
#UnsafeUserParameters=1
#EOF
#
#cp /opt/share_dir/ks/zabbix_agentd /bin/
#chmod +x /bin/zabbix_agentd
############################### config init(/etc/profile /etc/sysctl.conf) ##########################
cat /opt/share_dir/ks/profile >/etc/profile
cat /opt/share_dir/ks/sysctl.conf >/etc/sysctl.conf
################################ deploy app ##########################################################
#!/bin/bash
mkdir -p /opt/server/logs
tar zxf /opt/share_dir/ks/jdk18.tar.gz -C /usr/local/
tar zxf /opt/share_dir/ks/tomcat.tar.gz -C /opt/server/
source /etc/profile
cd /opt/
tar zxf /opt/share_dir/ks/apr-1.4.5.tar.gz -C /opt/
cd /opt/apr-1.4.5
./configure --prefix=/usr/local/apr
make
make install
rm -rf /opt/apr-1.4.5
cd /opt/
tar zxf /opt/share_dir/ks/apr-iconv-1.2.1.tar.gz -C /opt/
cd /opt/apr-iconv-1.2.1
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr
make
make install
rm -rf /opt/apr-iconv-1.2.1
cd /opt/
tar zxf /opt/share_dir/ks/apr-util-1.3.12.tar.gz -C /opt/
cd /opt/apr-util-1.3.12
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr
make
make install
rm -rf /opt/apr-util-1.3.12
cd /opt/server/tomcat/bin/tomcat-native-1.1.27-src/jni/native
./configure --with-apr=/usr/local/apr --with-java-home=/usr/local/jdk/
make
make install
%packages --nobase
@core
%end
<?php
}else{
?>
Usage:http://172.29.1.4/ks/ks.php?hostname=VM-XX-XX&pw=123456&ip1=x.x.x.x&ip2=x.x.x.x&mask=x.x.x.x&gw=x.x.x.x&ns=x.x.x.x,x.x.x.x&fs-type=ext4&disk=vda&boot-size=500&swap-size=4096
<?php
}
?>
14.KVM安装之脚本和镜像目录树准备的更多相关文章
- 17.KVM安装之虚拟磁盘,安装脚本
1.创建磁盘 vm.list 指定虚拟磁盘名称和主机名 create_vm.sh #创建vm.list中的虚拟磁盘,并指定大小100G #!/bin/bash VM_DIR="/opt ...
- CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-总目录
CentOS7+CDH5.14.0安装全流程记录,图文详解全程实测-总目录: 0.Windows 10本机下载Xshell,以方便往Linux主机上上传大文件 1.CentOS7+CDH5.14.0安 ...
- KVM安装、镜像创建(一)
环境准备 VMware Workstation Pro启动虚拟化 查看启动的系统是否支持vmx或svm grep -E '(vmx|svm)' /proc/cpuinfo 备注:操作系统centos ...
- ubuntu 14.04安装 DevStack的脚本配置文件——localrc
本文ubuntu 14.04安装 DevStack的脚本配置文件——localrc,本文件名已经逐渐被取代,但是出于后向兼容性,使用该文件仍然可以为stack.sh安装脚本指定安装DevStack时的 ...
- 定制属于自己的自动化安装的linux系统镜像
使用软件和平台 1.基于平台: Vmware workstation 8.0 2.基于系统镜像: rhel-server-5.8-i386 ...
- kubespray-2.14.2安装kubernetes-1.18.10(ubuntu-20.04.1)
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- KVM安装部署
KVM安装部署 公司开始部署KVM,KVM的全称是kernel base virtual machine,对KVM虚拟化技术研究了一段时间, KVM是基于硬件的完全虚拟化,跟vmware.xen.hy ...
- 烂泥:虚拟化KVM安装与配置
本文由秀依林枫提供友情赞助,首发于烂泥行天下. 最近打算把公司的服务器全部做成虚拟化,一是跟有效的利用了服务器,二也是对自己是一个学习的机会. KVM的安装与配置步骤如下: 1. 查看是否支持虚拟化 ...
- Ubuntu 14.04 安装 DevStack与遇到的的问题记录
本文总结Ubuntu 14.04下部署DevStack的过程以及一些可能遇到的问题. 一.安装 以下的操作最好在普通用户下进行,至少在git clone devstack的时候使用普通用户,这样可以避 ...
随机推荐
- where过滤字句
无条件为真 为假 别名不能直接用来当做查询来用 只能如此 下面这些语句是可以使用的,使用的是排序规则
- 【iCore3 双核心板】iCore3封装库及使用说明V1.0
iCore3封装库及使用说明下载链接: http://pan.baidu.com/s/1pLq23Qb iCore3 购买链接: https://item.taobao.com/item.htm?id ...
- A trip through the Graphics Pipeline 2011_08_Pixel processing – “fork phase”
In this part, I’ll be dealing with the first half of pixel processing: dispatch and actual pixel sha ...
- Java - Collection 高效的找出两个List中的不同元素
如题:有List<String> list1和List<String> list2,两个集合各有上万个元素,怎样取出两个集合中不同的元素? 方法1:遍历两个集合 public ...
- grep中正则匹配的使用
如要匹配Computer或computer两个单词,可做如下操作: [Cc]mputer “.”允许匹配ASCII集中任意字符,或为字母,或为数字. 使用\{\}匹配模式结果出现的次数 匹配字母A出现 ...
- 线性探测再散列 建立HASH表
根据数据元素的关键字和哈希函数建立哈希表并初始化哈希表,用开放定址法处理冲突,按屏幕输出的功能表选择所需的功能实现用哈希表对数据元素的插入,显示,查找,删除. 初始化哈希表时把elem[MAXSIZE ...
- 最长公共子序列PK最长公共子串
1.先科普下最长公共子序列 & 最长公共子串的区别: 找两个字符串的最长公共子串,这个子串要求在原字符串中是连续的.而最长公共子序列则并不要求连续. (1)递归方法求最长公共子序列的长度 1) ...
- CSS水平居中
三种情况:1.行内元素(文本.图片等) 给父元素设置text-align:center;来实现 2.定宽块状元素 <style> div{ border:1px solid blue; w ...
- [BS-27] 创建NSURL的几个方法的区别
创建NSURL的几个方法的区别 URL的基本格式 = 协议://主机地址/路径 URL和Path的区别 * URL:统一资源定位符,格式 “协议+主机名称+路径” 例如:[NSURL UR ...
- 求文件的m至n行
#!/usr/bin/env python def read_file(file_name,start,stop): start_line = 0 try: with open(file_name) ...