目录
一、前因:
最近在学hadoop、hive那一套东西,需要搭建一套伪分布式的实操环境做练习。于是就安装了VMware和CentOS。并下载了JDK、Hadoop、Hive等安装包,然后解压安装时就遇到了以下报错:
=========================================================================
“gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now”
=========================================================================
百度了一下,基本都是在说文件缺失。于是就查了一下文件大小,发现果然缩水严重!(下面左图是本机windows系统的文件属性,右图是拖拽到虚拟机centos之后的文件属性)。
于是重新尝试拖拽了几次,问题还是没有解决。
二、解决方法:启用共享文件夹
共享文件夹简单来说就是虚拟机和本机之间公用的一个文件夹。里面的文件,两个操作系统都可以访问和操作。
①启用共享文件夹的设置方法:
在虚拟机关机的状态下,点击VMware的【虚拟机】选项卡->【设置】->【选项】
然后如下图依次设置
通过【浏览】选定需要被共享的文件夹,继续【下一步】。
如图勾选‘启用此共享’。最后点击完成。
②开启虚拟机,输入以下命令检查是否可以看到需要被共享的文件(需要提前将文件放入共享文件夹)
cd /mnt/hgfs
ls
如可见,直接使用mv命令或cp命令将文件放入目的文件夹使用即可。
如不可见,考虑缺少vmware-tools组件,需要安装。
③vmware-tools的安装
1.首先检查VMware版本:【帮助】->【关于VMware WorkStation】
2.下载版本对应的组件(附链接)
CDS Repository - /var/www/public/stage/session-304/cds/vmw-desktop/ws
↑这里注意选则的是安装了VMware的操作系统,而不是VMware安装的操作系统。
下载之后打开会看到一个.iso的镜像文件
3.把它解压,然后在VMware的虚拟机中设置将它挂载在CD/DVD设备商。(如不能操作,需要先关闭虚拟机)
4. 启动或重启虚拟机,在未进入用户登录页面之前点击【虚拟机】->【重新安装VMware Tools】
(进入用户登录页面之后,该按钮会变为不可点击,呈灰色)
之后正常登录系统,会在桌面上看到一个光盘
5.鼠标右击,选择在终端中打开【Open in Terminal】
6. 在弹出的窗口中使用ls命令可以看到一个VMwareTools-x.x.x-yyyy.tar.gz的安装包(忘记截图了...),使用mv命令将它移动到/tmp目录下。
7.接着cd进入/tmp目录,使用tar -zxpf VMwareTools-x.x.x-yyyy.tar.gz解压该文件。
tar -zxpf VMwareTools-x.x.x-yyyy.tar.gz
#等待解压完成
#等待解压完成
cd vmware-tools-distrib
sudo ./vmware-install.pl
输入root账户的密码,开始安装,期间遇到一些需要输入的设置信息。原则是与目录&地址相关的直接复制输入其提示,其余全部yes。详情如下:
The installer has detected an existing installation of open-vm-tools packages
on this system and will not attempt to remove and replace these user-space
applications. It is recommended to use the open-vm-tools packages provided by
the operating system. If you do not want to use the existing installation of
open-vm-tools packages and use VMware Tools, you must uninstall the
open-vm-tools packages and re-run this installer.
The packages that need to be removed are:
open-vm-tools
The installer will next check if there are any missing kernel drivers. Type yes
if you want to do this, otherwise type no [yes] yes
INPUT: [yes]
A previous installation of VMware Tools has been detected.
The previous installation was made by the tar installer (version 4).
Keeping the tar4 installer database format.
You have a version of VMware Tools installed. Continuing this install will
first uninstall the currently installed version. Do you wish to continue?
(yes/no) [yes] yes
INPUT: [yes]
Uninstalling the tar installation of VMware Tools.
The removal of VMware Tools 10.3.23 build-16594550 for Linux completed
successfully.
Installing VMware Tools.
In which directory do you want to install the binary files?
[/usr/bin] /usr/bin
INPUT: [/usr/bin]
What is the directory that contains the init directories (rc0.d/ to rc6.d/)?
[/etc/rc.d] /etc/rc.d
INPUT: [/etc/rc.d]
What is the directory that contains the init scripts?
[/etc/rc.d/init.d] /etc/rc.d/init.d
INPUT: [/etc/rc.d/init.d]
In which directory do you want to install the daemon files?
[/usr/sbin] /usr/sbin
INPUT: [/usr/sbin]
In which directory do you want to install the library files?
[/usr/lib/vmware-tools] /usr/lib/vmware-tools
INPUT: [/usr/lib/vmware-tools]
The path "/usr/lib/vmware-tools" does not exist currently. This program is
going to create it, including needed parent directories. Is this what you want?
[yes] yes
INPUT: [yes]
In which directory do you want to install the documentation files?
[/usr/share/doc/vmware-tools] /usr/share/doc/vmware-tools
INPUT: [/usr/share/doc/vmware-tools]
The path "/usr/share/doc/vmware-tools" does not exist currently. This program
is going to create it, including needed parent directories. Is this what you
want? [yes] yes
INPUT: [yes]
The installation of VMware Tools 10.3.23 build-16594550 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command: "/usr/bin/vmware-uninstall-tools.pl".
Before running VMware Tools for the first time, you need to configure it by
invoking the following command: "/usr/bin/vmware-config-tools.pl". Do you want
this program to invoke the command for you now? [yes] yes
INPUT: [yes]
You have chosen to install VMware Tools on top of an open-vm-tools package.
You will now be given the option to replace some commands provided by
open-vm-tools. Please note that if you replace any commands at this time and
later remove VMware Tools, it may be necessary to re-install the open-vm-tools.
The file /usr/bin/vmware-hgfsclient that this program was about to install
already exists. Overwrite? [no] yes
INPUT: [yes]
The file /usr/bin/vmhgfs-fuse that this program was about to install already
exists. Overwrite? [no] yes
INPUT: [yes]
Initializing...
Making sure services for VMware Tools are stopped.
Stopping vmware-tools (via systemctl): [ OK ]
The module vmci has already been installed on this system by another installer
or package and will not be modified by this installer.
The module vsock has already been installed on this system by another installer
or package and will not be modified by this installer.
The module vmxnet3 has already been installed on this system by another
installer or package and will not be modified by this installer.
The module pvscsi has already been installed on this system by another
installer or package and will not be modified by this installer.
The module vmmemctl has already been installed on this system by another
installer or package and will not be modified by this installer.
The VMware Host-Guest Filesystem allows for shared folders between the host OS
and the guest OS in a Fusion or Workstation virtual environment. Do you wish
to enable this feature? [yes] yes
INPUT: [yes]
The vmxnet driver is no longer supported on kernels 3.3 and greater. Please
upgrade to a newer virtual NIC. (e.g., vmxnet3 or e1000e)
Skipping configuring automatic kernel modules as no drivers were installed by
this installer.
Skipping rebuilding initrd boot image for kernel as no drivers to be included
in boot image were installed by this installer.
The configuration of VMware Tools 10.3.23 build-16594550 for Linux for this
running kernel completed successfully.
Found VMware Tools CDROM mounted at /run/media/master/VMware Tools. Ejecting
device /dev/sr0 ...
Enjoy,
--the VMware team
安装大约会持续个3~4分钟。
装好后再次进入到/mnt/hgfs/目录,即可看到共享文件夹
cd /mnt/hgfs/
使用mv相关命令将被共享的文件移动到虚拟机系统的对应目录即可,此方式传递文件,文件不会缺损。