1.如果连不了网,执行以下命令,确保没有vbr
[student@room9pc01 ~]$ virsh
欢迎使用 virsh,虚拟化的交互式终端。
输入:'help' 来获得命令的帮助信息
'quit' 退出
virsh # net-destroy vbr
网络 vbr 被删除
virsh # exit
2.创建一台虚拟机
[student@room9pc01 ~]$ virt-manager
[student@room9pc01 ~]$ clone-auto7 创建虚拟机
Enter VM number: 1
VM stu_node01 Create [ 确定 ]
3.在虚拟机器上配置ip
[root@localhost ~]# nmcli connection modify eth0 ipv4.method manual ipv4.addresses 192.168.4.2/24 connection.autoconnect yes
[root@localhost ~]# nmcli connection up eth0
[ 274.964923] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)
[root@localhost ~]# hostnamectl set-hostname postgresql
[root@localhost ~]# exit
logout
CentOS Linux 7 (Core)
Kernel 3.10.0-862.el7.x86_64 on an x86_64
postgresql login: root
Password:
Last login: Sun Dec 22 14:27:40 on ttyS0
.-"""-.
/ .===. \
\/ 6 6 \/
( \___/ )
_________ooo__\_____/_____________
/ \
| I am Virtual Host ! ! ! |
\_______________________ooo________/
| | |
|_ | _|
| | |
|__|__|
/-'Y'-\
(__/ \__)
[root@postgresql ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.4.2 netmask 255.255.255.0 broadcast 192.168.4.255
ether 52:54:00:56:e1:85 txqueuelen 1000 (Ethernet)
RX packets 237 bytes 12740 (12.4 KiB)
RX errors 0 dropped 226 overruns 0 frame 0
TX packets 1 bytes 42 (42.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@postgresql ~]# yum repolist
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Determining fastest mirrors
repo id repo name status
!local_repo CentOS-7 - Base 9,911
repolist: 9,911
4.用真机传送文件到虚拟机中
[student@room9pc01 ~]$ scp '/home/student/桌面/postgresql-10.1.tar.bz2' root@192.168.4.2:/root
The authenticity of host '192.168.4.2 (192.168.4.2)' can't be established.
ECDSA key fingerprint is SHA256:l6noBEulrbGNvnQ49u14XiBVe8zFixieJC1PInupjeg.
ECDSA key fingerprint is MD5:1e:76:cc:e8:d9:55:86:df:dc:a1:ea:7a:6c:67:c6:00.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.4.2' (ECDSA) to the list of known hosts.
postgresql-10.1.tar.bz2 100% 19MB 61.8MB/s 00:00
5.用真机链接虚拟机器
[student@room9pc01 ~]$ ssh root@192.168.4.2
Last login: Sun Dec 22 15:15:31 2019
.-"""-.
/ .===. \
\/ 6 6 \/
( \___/ )
_________ooo__\_____/_____________
/ \
| I am Virtual Host ! ! ! |
\_______________________ooo________/
| | |
|_ | _|
| | |
|__|__|
/-'Y'-\
(__/ \__)
[root@postgresql ~]# exit ----退出链接
登出
Connection to 192.168.4.2 closed.
来源:CSDN
作者:zhy-dream
链接:https://blog.csdn.net/zhydream77/article/details/103653030