【生意多】-免费发布分类信息
当前位置: 首页 » 新闻 » 教程 » 正文

kvm虚拟化

放大字体  缩小字体 发布日期:2022-01-02 01:06:24    浏览次数:8
导读

  kvm虚拟化 kvm部署  环境:   主机IP地址server1192.168.244.143node3192.168.244.142 在server1上操作  关闭防火墙 

  kvm虚拟化 kvm部署

  环境:

   主机IP地址server1192.168.244.143node3192.168.244.142 在server1上操作

  关闭防火墙

   [[email protected] ~]# systemctl disable --now firewalld Removed /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [[email protected] ~]# vim /etc/selinux/config SELINUX=disabled [[email protected] ~]# reboot

  安装epel源和软件

   wget -O /etc/yum.repos.d/epel.repo [email protected] ~]# yum -y install epel-release vim wget net-tools unzip zip gcc gcc-c++

  下载软件

   [[email protected] ~]# yum -y install qemu-kvm qemu-kvm-common qemu-img virt-manager libvirt python3-libvirt libvirt-client virt-install virt-viewer bridge-utils libguestfs-tools

  配置桥接网卡

   [[email protected] network-scripts]# cp ifcfg-ens33 ifcfg-br0 [[email protected] network-scripts]# ls ifcfg-br0 ifcfg-ens33 [[email protected] network-scripts]# vim ifcfg-br0 [[email protected] network-scripts]# TYPE=Bridge BOOTPROTO=static NAME=br0 DEVICE=br0 onBOOT=yes IPADDR=192.168.244.136 PREFIX=24 GATEWAY=192.168.244.2 DNS1=114.114.114.114 [[email protected] network-scripts]# vim ifcfg-ens33 TYPE=Ethernet BOOTPROTO=static NAME=ens33 DEVICE=ens33 onBOOT=yes BRIDGE=br0

  重启网卡

   [[email protected] ~]# systemctl restart NetworkManager [[email protected] ~]# ip a 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000 link/ether 00:0c:29:7e:0b:9b brd ff:ff:ff:ff:ff:ff 3: br0: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:0c:29:7e:0b:9b brd ff:ff:ff:ff:ff:ff inet 192.168.244.136/24 brd 192.168.244.255 scope global noprefixroute br0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe7e:b9b/64 scope link valid_lft forever preferred_lft forever 4: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:3a:01:4f brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 5: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:3a:01:4f brd ff:ff:ff:ff:ff:ff

  启动服务

   [[email protected] ~]# systemctl start libvirtd [[email protected] ~]# systemctl enable libvirtd

  查看服务以及版本号

   /usr/libexec/qemu-kvm [[email protected] ~]# lsmod grep kvm kvm_intel 315392 0 kvm 847872 1 kvm_intel irqbypass 16384 1 kvm [[email protected] ~]# brctl show bridge name bridge id STP enabledinterfaces br0 8000.000000000000 no 在node3上操作 kvm web管理界面安装

  安装依赖包

   [[email protected] ~]# yum -y install git python2-pip python36-libvirt libxml2-python python-websocket-client supervisor nginx python2-devel

  从github上下载webvirtmgr代码

   [retspen/webvirtmgr.git 正克隆到 webvirtmgr... remote: Enumerating objects: 5614, done. 接收对象中: 19% (1067/5614), 204.01 KiB 289.00 Ki .....

  安装webvirtmgr

   [[email protected] webvirtmgr]# pip2 install -r requirements.txt

  检查sqlite3是否安装

   im exit()

  初始化账号信息

   [[email protected] webvirtmgr]# python manage.py syncdb ./manage.py syncdb WARNING:root:No local_settings file found. Creating tables ... Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_groups Creating table auth_user_user_permissions Creating table auth_user Creating table django_content_type Creating table django_session Creating table django_site Creating table servers_compute Creating table instance_instance Creating table create_flavor You just installed Djangos auth system, which means you dont have any superusers defined. Would you like to create one now? (yes/no): yes //问你是否创建超级管理员帐号 Username (leave blank to use root): //指定超级管理员帐号用户名,默认留空为root Email address:[email protected] //设置超级管理员邮箱 Password: //设置超级管理员密码 Password (again): //再次输入超级管理员密码 Superuser created successfully. Installing custom SQL ... Installing indexes ... Installed 6 object(s) from 1 fixture(s)

  拷贝web网页至指定目录

   [[email protected] webvirtmgr]# mkdir /var/[email protected] webvirtmgr]# cp -r /usr/local/src/webvirtmgr /var/[email protected] webvirtmgr]# chown -R nginx.nginx /var/[email protected] webvirtmgr]#

  生成密钥

   [[email protected] ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:Y82SD1PgOnvrVlbhwcL9mZwc8xmTOwtqO3h15seA2HU[email protected] The keys randomart image is: +---[RSA 2048]----+ .. o . . .o = o+ . .o * B= . = o.O+E o S o+.o..o + *+oo..+ . .o+ o +o ..o + .o oo . . . +----[SHA256]-----+ [[email protected] ~]# ssh-copy-id[email protected] /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: /root/.ssh/id_rsa.pub /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys[email protected]s password: Number of key(s) added: 1 Now try logging into the machine, with: ssh[email protected] and check to make sure that only the key(s) you wanted were added. [[email protected] ~]# ssh[email protected] Last login: Wed Oct 20 20:32:37 2021 from 192.168.244.1 [[email protected] ~]#

  配置nginx

   [f ...... include /etc/nginx/conf.d/*.conf; server { listen 80; ...... [f server { listen 80 default_server; server_name $hostname; #access_log /var/log/nginx/webvirtmgr_access_log; location /static/ { root /var/

  确保bind绑定的是本机的8000端口

   .... bind = 0.0.0.0:8000 backlog = 2048 ...

  重启服务

   [[email protected] ~]# systemctl enable --now nginx

  设置supervisor

   [f .....此处省略上面的内容,在文件最后加上以下内容 [program:webvirtmgr] command=/usr/bin/python2 /var/nsole directory=/var/www/webvirtmgr autostart=true autorestart=true stdout_logfile=/var/log/supervisor/webvirtmgr-console.log redirect_stderr=true user=nginx

  启动supervisor并设置开机自启

   [[email protected] ~]# systemctl start supervisord [[email protected] ~]# systemctl enable supervisord Created symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service. [[email protected] ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:8000 *:* LISTEN 0 128 *:80 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::*

  配置nginx用户

   [[email protected] home]# su - nginx -s /bin/bash -bash-4.2$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/var/lib/nginx/.ssh/id_rsa): Created directory /var/lib/nginx/.ssh. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /var/lib/nginx/.ssh/id_rsa. Your public key has been saved in /var/lib/nginx/.ssh/id_rsa.pub. The key fingerprint is: SHA256:/P0RcwRe9lp1mC5dNVjB7kvH0krbOSjzmwB42g2I+4M[email protected] The keys randomart image is: +---[RSA 2048]----+ =*O oo=* oo.+ ..o . o= . oS+ .=o. . +.+. o*+ ... ..o..+=+ E.. o.o+=. .. ++o . +----[SHA256]-----+ -bash-4.2$ touch ~/.ssh/config && echo -e StrictHostKeyChecking=no ~/.ssh/config -bash-4.2$ chmod 0600 ~/.ssh/config -bash-4.2$ ssh-copy-id[email protected] /bin/ssh-copy-id: INFO: Source of key(s) to be installed: /var/lib/nginx/.ssh/id_rsa.pub /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys Warning: Permanently added 192.168.244.143 (ECDSA) to the list of known hosts.[email protected]s password: Number of key(s) added: 1 Now try logging into the machine, with: ssh[email protected] and check to make sure that only the key(s) you wanted were added. -bash-4.2$ exit logout [[email protected] home]# cat /etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla [Remote libvirt SSH access] Identity=unix-user:root Action=org.libvirt.unix.manage ResultAny=yes ResultInactive=yes ResultActive=yes

  重启服务

 
关键词: 考试
(文/小编)
打赏
免责声明
• 
本文为小编原创作品,作者: 小编。欢迎转载,转载请注明原文出处:http://www.31duo.com/news/show-2689961.html 。本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们。
 

(c)2016-2019 31DUO.COM All Rights Reserved浙ICP备19001410号-4

浙ICP备19001410号-4