Kvm+webvirtmgr deployment on the CENTOS7

Source: Internet
Author: User

#!/bin/bash#+++++++++++++++++++++++++++++++++++++++++++++++++++++++ Install and configure KVM and create virtual machines +++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++#验证cpu是否支持kvmEgrep '(VMX|SVM)'/proc/cpuinfo #然后需要在bios设置中打开cpu Virtual technology!!!!!!!#关闭selinuxVI/etc/sysconfig/Selinuxselinux=disabled# shut down the firewall systemctl stop firewalldsystemctl disable firewalld# replace the Yum source (optional, usually do not change)MV/etc/Yum. repos.d/centos-base.repo/etc/Yum. repos.d/centos-Base.repo.backupwget-o/etc/Yum. Repos.d/centos-base.repo http://Mirrors.aliyun.com/repo/centos-7.repoYummakecache# Installation Dependent environmentYum InstallEpel-release Net-tools VimUnzip Zip wget FTP-y# Installing KVM and its dependenciesYum InstallQEMU-KVM Libvirt virt-InstallBridge-utils-y# Verifying installation resultsLsmod|grepKVM #开启kvm服务 and set it on automatically start Systemctl start Libvirtdsystemctl enable libvirtd# Configure network bridging mode # Manually modify the configuration bridge mode to first/etc/sysconfig/network-scripts/a copy of the NIC configuration file in the directory (not in the current directory and subdirectories, other directories are optional) #a. Create Ifcfg-br0 file with the following contents: Bootproto=Staticdevice=Br0type=bridgenm_controlled=noipaddr=192.168.1.95NETMASK=255.255.255.0GATEWAY=192.168.1.1DNS1=61.177.7.1DNS2=8.8.8.8#b. Remove the original ifcfg-ENP0S25, recreate the file with the following contents: Bootproto=Nonedevice=enp0s25nm_controlled=Noonboot=Yesbridge=br0#c. Restart the Network Service systemctl Restart network# Install the virtual machine #准备虚拟机镜像文件, put the file in/home/ISO (no can create) directory # Create virtual machinemkdir-p/home/kvm-Bakvirt-Install-N Xiaocanan_media-r4096--vcpus=4--os-type=linux--accelerate-c/home/iso/centos-7-x86_64-minimal-1611. ISO--disk path=/home/vmdisk_pool/xiaocanan_media.img,format=qcow2,bus=ide--network bridge=br0--vnc--vncport=5993--vnclisten=0.0.0.0--force--autostart# shut down the firewall systemctl stop firewalldsystemctl disable firewalld# off SELinuxVI/etc/sysconfig/Selinuxselinux=disabled# connecting a virtual machine with VNC, installing the virtual machine operating system # Manually start the virtual machine Virsh list--Allvirsh start Virt-centos#++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Installation Configuration webvirtmgr+++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++#yum源的配置及所需软件包Yum-YInstallhttp//dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm #repo源, optionalYum-YInstallgit python-pip libvirt-python libxml2-python python-websockify Supervisor NginxYum-YInstall GCCpython-devel# replacing the PIP sourceVI~/.pip/Pip.conf[global]index-url = https://Pypi.douban.com/simple#安装numpypipInstallnumpy# download webvirtmgr source from gitmkdir/application/CD/application/git clone git://Github.com/retspen/webvirtmgr.git#sqlite3数据库安装 CD/application/wgethttp//www.sqlite.org/sqlite-3.5.6.tar.gzCD sqlite-3.5.6/./configure--disable-Tcl Make Make Install#webvirtmgr安装cd/application/WebvirtmgrpipInstall-R requirements.txt./manage.py syncdb./manage.py collectstatic./manage.py createsuperuser #创建super用户 Optional #webvirtmgr configurationmkdir-pv/var/wwwCP-rv/application/webvirtmgr/var/www/Webvirtmgrvim/etc/nginx/conf.d/Webvirtmgr.confserver {Listen theDefault_server;server_name $hostname; #access_log/var/log/nginx/webvirtmgr_access_log;location/static/{root/var/www/webvirtmgr/webvirtmgr; # or/srv instead of/varexpires Max;} Location/{proxy_pass http://127.0.0.1:8000;Proxy_set_header x-real-IP $remote _addr;proxy_set_header X-forwarded- for$proxy _add_x_forwarded_for;proxy_set_header Host $host: $server _port;proxy_set_header x-forwarded-Proto $remote _addr;proxy_connect_timeout -;p roxy_read_timeout -;p roxy_send_timeout -; client_max_body_size 1024M; # Set higher depending on your needs}} #确保bind绑定的端口是本机的8000端口grep '^bind ='/var/www/webvirtmgr/conf/gunicorn.conf.py# Comment out/etc/nginx/nginx.conf server content systemctl Restart Nginx.servicesystemctl enable Nginx.service*/9-/*#kvm被管理端配置vi/ETC/SYSCONFIG/LIBVIRTD #取消以下字段的注释LLIBVIRTD_CONFIG =/etc/libvirt/libvirtd.conflibvirtd_args= "-- Listen "vi/etc/libvirt/libvirtd.conf #取消以下字段的注释并修改listen_tls = 0listen_tcp = 1tcp_port =" 16509 "listen_addr =" 0.0.0.0 "a Uth_tcp = "None" systemctl restart Libvirtd.service #设置ssh免密登录 1. Vi/etc/ssh/sshd_config rsaauthentication Yes #新版本ssh可能不需要配置此项 pubkeyauthentication Yes authorizedkeysfile. SS H/authorized_keys 2. Restart sshd service: Systemctl restart sshd 3. Generate certificate Public private key Ssh-keygen-t Dsa-p "-F ~/.SSH/ID_DSA Cat ~/.ssh/id _dsa.pub >> ~/.ssh/authorized_keys 4.chmod ~/.ssh/authorized_keys #免密登录远程服务器 cat ~/.ssh/id_rsa.pub | SSH remote User name @ Remote server IP ' cat->> ~/.ssh/authorized_keys ' #启动webvirtmgr servernohup/var/www/webvirtmgr/manage.py Runserver 0:8000nohup/var/www/webvirtmgr/console/webvirtmgr-console# setup webvirtmgr and webvirtmgr-console boot scripts nohup /var/www/webvirtmgr/manage.py runserver 0:8000 &nohup/var/www/webvirtmgr/console/webvirtmgr-console & #切记!!!! Webvirtmgr must be run manually for the first time, otherwise it will prompt for password verification FAILURE # REMEMBER!!!! When you create a Windows virtual machine using Webvirtmgr, you cannot choose Virtio because the hard disk and the network card will not recognize the #webvirtmgr Web address http./Native Ip:8000#windows server R2 Activating www.xpgod.com/soft/12388.html

Kvm+webvirtmgr deployment on the CENTOS7

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.