Manual production OpenStack mirror
## manual production OpenStack mirror ## host operating # First create a qcow2 image file format for virtual machine's root disk size 10G enough. mkdir -p / the Data / KVMS / ImagesRF Royalty Free / cd / the Data / KVMS / ImagesRF Royalty Free / QEMU -IMG the Create - f qcow2 centos.qcow2 10G # created using the following script and start the virtual machine: ### to download the iso image ### wget HTTP: // vault.centos.org/centos/6.9/isos/x86_64/CentOS-6.9-x86_64-minimal.iso wget HTTP: // vault.centos.org/centos/7.4.1708/isos/x86_64/CentOS- Minimal---the x86_64. 7 1708.iso NAME = CentOS ROOT_DISK = centos.qcow2 the CDROM = / Data / KVMS / Images / CentOS- . 7 -x86_64-Minimal-1708.iso virt-install --virt-type kvm --name $NAME --ram 1024 --disk $ROOT_DISK,format=qcow2 --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole --os-type=linux --os-variant=rhel7 --location=$CDROM #virt-install --name $NAME --ram 1024 --disk $ROOT_DISK,format=qcow2 --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole --os-type=linux --os-variant=rhel7 --cdrom=$CDROM ##查看vnc端口 virsh vncdisplay centos #####:0 0 for 5900 is greater than 0 after the increase from 5900. For example, show: 1 , 5901 represents ## virtual machines operating ## If it does not succeed, you can do virsh reboot centos command at the server end. ## reconnection, ACPI installation. acpid service is used to allow hypervisior can restart or shut down the virtual machine yum install - the y-acpid chkconfig acpid ON ## installation Cloud -init. Used to start the virtual machine when nova- meatdata key injection services to the virtual machine. yum the install -Y epel- release.noarch yum the install -Y cloud- the init ## modified Cloud -init boot module loads resolv- the conf. ### in /etc/cloud/cloud.cfg file, adding a line under cloud_init_modules attributes: - resolv- the conf Sed -i ' / cloud_init_modules: / A - the resolv the conf-' / Etc / Cloud / cloud.cfg grep -A2 ' cloud_init_modules ' / etc / Cloud / cloud.cfg ## mounted Cloud -utils- growpart. The course is supported between virtual machine disk expansion. yum the install -Y-Cloud utils- growpart ##### If the above steps do not install Cloud -init, the /etc/rc.d/rc.local file can, in Touch / var / Lock / subsys / local this the following script was added forward [$ (RPM -aq | grep -C ' Cloud-utils-growpart ' ) -eq 0 ] && Sed ' / Touch / var / Lock / subsys / local / A IF ! [-d / the root / . SSH ]; the then mkdir -p /root/.ssh chmod 700 /root/.ssh fi # Fetch public key using HTTP ATTEMPTS=30 FAILED=0 while [ ! -f /root/.ssh/authorized_keys ]; do curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key \ > /tmp/metadata-key 2>/dev/null if [ \$? -eq 0 ]; then cat /tmp/metadata-key >> /root/.ssh/authorized_keys chmod 0600 /root/.ssh/authorized_keys restorecon /root/.ssh/authorized_keys rm -f /tmp/metadata-key echo "Successfully retrieved public key from instance metadata" echo "*****************" echo "AUTHORIZED KEYS" echo "*****************" cat /root/.ssh/authorized_keys echo "*****************" fi done ' /etc/rc.d/rc.local ############# ## Close route Zeroconf echo " NOZEROCONF = Yes " >> / etc / sysconfig / Network tail / etc / sysconfig / Network #### Sed -i ' S / PasswordAuthentication ^. * / PasswordAuthentication Yes / G ' / etc / SSH / sshd_config systemctl reload sshd ### configuration console, in order to ensure that the information appears in the dashboard console log tab, and console Nova - log output. CentOS ## 7 modify / etc / default / grub configuration options GRUB_CMDLINE_LINUX Remove Add rhgb quiet tty0 Console = = Console ttyS0,115200n8. ### Examples: #GRUB_CMDLINE_LINUX = "= = Auto Console, tty0 crashkernel Console = ttyS0,115200n8 Sed -i ' S # GRUB_CMDLINE_LINUX = "Auto rd.lvm.lv = CentOS crashkernel = / = the root rd.lvm.lv CentOS / rhgb the swap quiet" # GRUB_CMDLINE_LINUX = "crashkernel = rd.lvm.lv CentOS = Auto / CentOS the root rd.lvm.lv = / =, tty0 the swap Console Console = ttyS0,115200n8 "#G ' / etc / default / GRUB grep GRUB_CMDLINE_LINUX / etc / default / GRUB #### update grub configuration grub2 -mkconfig -o / Boot / grub2 / the grub.cfg ### VM off the shutdown - H now ## operating the host ## running on the host following nomenclature, removable host information, such as address mac . yum install -y libguestfs- Tools virt -sysprep -CentOS d ## to delete the virtual machine, mirror finished. undefine CentOS virsh Source / the root / ADMIN-OpenRC. SH Glance Image -create - File /data/kvms/images/centos.qcow2 --disk the format-the format qcow2 --container-Bare --name CentOS- 7.4 --progress
/CentOS-7-x86_64-Minimal-1708.iso