windows vmware 扩展硬盘 + 共享文件
文章很长,而且持续更新,建议收藏起来,慢慢读!疯狂创客圈总目录 博客园版 为您奉上珍贵的学习资源 :
免费赠送 :《尼恩Java面试宝典》 持续更新+ 史上最全 + 面试必备 2000页+ 面试必备 + 大厂必备 +涨薪必备
免费赠送 经典图书:《Java高并发核心编程(卷1)加强版》 面试必备 + 大厂必备 +涨薪必备 加尼恩免费领
免费赠送 经典图书:《Java高并发核心编程(卷2)加强版》 面试必备 + 大厂必备 +涨薪必备 加尼恩免费领
免费赠送 经典图书:《Java高并发核心编程(卷3)加强版》 面试必备 + 大厂必备 +涨薪必备 加尼恩免费领
免费赠送 经典图书:《尼恩Java面试宝典 最新版》 面试必备 + 大厂必备 +涨薪必备 加尼恩免费领
免费赠送 资源宝库: Java 必备 百度网盘资源大合集 价值>10000元 加尼恩领取
《SpringCloud Nginx 高并发核心编程》 环境搭建 图文教程和演示视频:
组件 | 链接地址 |
---|---|
【必须】 虚拟机Linux 开发环境准备 | windows vmware 扩展硬盘 + 共享文件 |
Linux openresty 安装 | Linux openresty 安装 |
【必须】Linux Redis 安装(带视频) | Linux Redis 安装(带视频) |
【必须】Linux Zookeeper 安装(带视频) | Linux Zookeeper 安装, 带视频 |
Windows Redis 安装(带视频) | Windows Redis 安装(带视频) |
RabbitMQ 离线安装(带视频) | RabbitMQ 离线安装(带视频) |
ElasticSearch 安装, 带视频 | ElasticSearch 安装, 带视频 |
Nacos 安装(带视频) | Nacos 安装(带视频) |
【必须】Eureka | Eureka 入门,带视频 |
【必须】springcloud Config 入门,带视频 | springcloud Config 入门,带视频 |
【必须】Zuul 详解,带视频 | Zuul 详解,带视频 |
【必须】SpringCloud 脚手架打包与启动 | SpringCloud脚手架打包与启动 |
1 虚拟机Linux 环境准备
VMware下载和安装
绝大多数初学者使用的是 Windows,这里仅仅介绍在 Windows 下安装 VMware 和 Linux。
VMware 有两个版本,分别是 VMware Workstation Pro 和 VMware Workstation Player。
VMware Workstation Pro 下载地址:https://pan.baidu.com/s/1XXhFFh0Fx0vzvcd1A543Yg,提取码:2o19
VMware 对计算机的硬件配置要求比较高,配置低了虚拟机会很慢,甚至不能运行。理论上,配置越高越好,现在主流的计算机配置都可以达到运行 VMware 的要求。千万不要用多年珍藏的老古董来运行 VMware,我保证你将会失去耐心。
由于 VMware 的安装过程比较简单,与安装普通软件无异,因此不再过多阐述。这里假设读者已经下载并已安装好 VMware,接下来直接开始使用 VMware 安装 Linux 系统。
使用 VMware 安装 Linux 系统
启动 VMware,进入其主界面,如图 1 所示。
图 2 虚拟机设置向导界面
点击“下一步”,进入“安装操作系统”界面,若初学者已提前准备好 Linux 系统的映像文件(.iso 文件),此处可选择“安装程序光盘映像文件”,并通过“浏览”按钮找到要安装 Linux 系统的 iso 文件;否则选择“稍后安装操作系统”,如图 3 所示。
- 32 位 CentOS 6.5 映像下载:http://archive.kernel.org/centos-vault/6.5/isos/i386/CentOS-6.5-i386-bin-DVD1.iso
- 64 位 CentOS 6.5 映像下载:http://archive.kernel.org/centos-vault/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso
点击“下一步”,进入“选择客户机操作系统”,选择“Linux”,并在“版本”下拉列表框中选择要安装的对应的 Linux 版本,这里选择“CentOS 6”,如图 4 所示。
图 5 命名虚拟机
单击"下一步"按钮,进入"指定磁盘容量"界面。默认虚拟硬盘大小为 20GB(虚拟硬盘会以文件形式存放在虚拟机系统安装目录中)。虚拟硬盘的空间可以根据需要调整大小,但不用担心其占用的空间,因为实际占用的空间还是以安装的系统大小而非此处划分的硬盘大小为依据的。
比如你设定了硬盘容量为 20GB,但是安装 Linux 只用了 4GB,那么实际上只会在你的 Windows 分区中占用 4GB 的空间,占用空间会随着虚拟机系统使用的空间增加而增加。
此“指定磁盘容量”界面保持默认设置即可,如图 6 所示。
图 6 指定磁盘容量界面
接下来进入“已准备好创建虚拟机”界面,确认虚拟机设置,不需改动则单击"完成"按钮,开始创建虚拟机,如图 7 所示。
图 12 VMware 启动 Linux 系统
而在图 3 中选择“稍后安装操作系统”的读者,此时必须先下载某个 Linux 映像文件,并通过“编辑虚拟机设置->CD/DVD(IDE)”中,选择“使用ISO映像文件”,手动添加 iso 文件,然后点击“确定”即可手动开启 Linux 系统。如图 13 所示。
经过以上几步,我们就成功地用 VMware 虚拟机安装好了 Linux 系统。
2、挂载扩展硬盘
1 前言
本机vmware会老提示nospace空间不足,一般都需要挂载扩展硬盘
2.添加新硬盘
依次点击"虚拟机"->"设置"
3.查看磁盘信息
[root@localhost ~]# fdisk -l
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x364f5e2e
Device Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 83 Linux
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000cbf1e
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris
/dev/sda3 4810752 41943039 18566144 83 Linux
可以看到有2个磁盘,/dev/sda磁盘有3个分区,/dev/sdb磁盘为我这次新增的,1分区
4.磁盘分区
fdisk /dev/sdb
分区后可以通过fdisk -l查看/dev/sdb磁盘下有一个sdb1分区
5.格式化分区
# 格式化分区
mkfs.ext4 /dev/sdb1
# 将分区挂载到根目录
mount -t ext4 /dev/sdb1 /work
挂载后
[root@localhost ~]# df -ll
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 18555904 7347232 11208672 40% /
devtmpfs 1925244 0 1925244 0% /dev
tmpfs 1934520 0 1934520 0% /dev/shm
tmpfs 1934520 58484 1876036 4% /run
tmpfs 1934520 0 1934520 0% /sys/fs/cgroup
/dev/sda1 303788 109596 194192 37% /boot
/dev/sdb1 20510288 11187164 8258216 58% /work
tmpfs 386908 0 386908 0% /run/user/0
6.设置开机自动挂载
vi /etc/rc.d/rc.local
#mount disk 2 挂载第二块硬盘
/bin/mount /dev/sdb1 /work
3 CentOS7 安装VMware Tools
VMware 强烈建议你在每一台虚拟机中完成操作系统安装之后立即安装 VMware Tools 套件。在客户操作系统中安装 VMware Tools 非常重要。
VMware Tools是VMware虚拟机中自带的一种增强工具,相当于VirtualBox中的增强功能(Sun VirtualBox Guest Additions),是VMware提供的增强虚拟显卡和硬盘性能、以及同步虚拟机与主机时钟的驱动程序。
只有在VMware虚拟机中安装好了VMware Tools,才能实现主机与虚拟机之间的文件共享,同时可支持自由拖拽的功能,鼠标也可在虚拟机与主机之前自由移动(不用再按ctrl+alt),且虚拟机屏幕也可实现全屏化。
1 安装依赖包
[root@localhost ~]# yum -y install perl gcc gcc-c++ make cmake kernel kernel-headers kernel-devel net-tools
2 加载 vmware tools 到CentOS7光驱CD-ROM
点击菜单 `虚拟机` ——> `安装VMware Tools(T)...`
点击加载 vmware tools 到CentOS7光驱CD-ROM
3 将CD-ROM挂载到指定目录
通常情况下都是将设备目录 /dev/crrom 挂载到 /mnt/cdrom 目录,
-
如果 /mnt 目录下不存在 cdrom 目录则创建
/mnt/cdrom
则创建
[root@localhost ~]# mkdir -p /mnt/cdrom
-
挂载目录
[root@localhost ~]# mount -t auto /dev/cdrom /mnt/cdrom mount: /dev/sr0 is write-protected, mounting read-only
如果挂载目录错了,可以输入umout /dev/cdrom进行卸载挂载。
ps:mount命令介绍
命令格式:mount [-t vfstype] [-o options] device dir
1.-t vfstype 指定文件系统的类型,通常不必指定。mount 会自动选择正确的类型。常用类型有:
光盘或光盘镜像:iso9660
DOS fat16文件系统:msdos
Windows 9x fat32文件系统:vfat
Windows NT ntfs文件系统:ntfs
Mount Windows文件网络共享:smbfs
UNIX(LINUX) 文件网络共享:nfs
2.-o options 主要用来描述设备或档案的挂接方式。常用的参数有:
loop:用来把一个文件当成硬盘分区挂接上系统
ro:采用只读方式挂接设备
rw:采用读写方式挂接设备
iocharset:指定访问文件系统所用字符集
3.device 要挂接(mount)的设备。
4.dir设备在系统上的挂接点(mount point)。
完整的挂载命令为
mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom
4 拷贝安装包到用户家目录
[root@localhost ~]# cp /mnt/cdrom/VMwareTools-10.0.5-3228253.tar.gz ~
5 解除挂载
[root@localhost ~]# umount /dev/cdrom
6 解压VMwareTools安装包
[root@localhost ~]# tar -zxvf VMwareTools-10.0.5-3228253.tar.gz
输入命令tar -zxf VMwareTools-10.0.5-3228253.tar.gz 将刚刚复制的VMwareTools-10.0.5-3228253.tar.gz解压,默认解压到当前目录下,此时就会多出一个命名为类似于“vmware-tools-distrib”的文件夹,这里和windows 里面的解压结果一样。
7 安装VMware Tools
输入命令 cdvmware-linux-tools 进入解压后的目录
[root@localhost ~]# cd vmware-tools-distrib/
运行
vmware-install.pl
文件
[root@localhost vmware-tools-distrib]# ./vmware-install.pl
在运行安装过程中,它会一步一步的有问题提出要你回应,此过程中,你只要见到问题后面显示[yes]、[no]、[yes/no]的都输入yes,然后回车, 如果是其他的问题,不管[ ]里面是什么直接回车就好
一路Enter即可
[root@XD-ORACLE vmware-tools-distribu]# cd vmware-tools-distrib/
[root@XD-ORACLE vmware-tools-distrib]# ls
bin doc etc FILES INSTALL installer lib vmware-install.pl
[root@XD-ORACLE vmware-tools-distrib]# ./vmware-install.pl
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
Uninstalling the tar installation of VMware Tools.
Stopping services for VMware Tools
Stopping VMware Tools services in the virtual machine:
Guest operating system daemon: [ OK ]
VMware User Agent (vmware-user): [ OK ]
Blocking file system: [ OK ]
Unmounting HGFS shares: [ OK ]
Guest filesystem driver: [ OK ]
VM communication interface socket family: [ OK ]
VM communication interface: [ OK ]
Stopping Thinprint services in the virtual machine:
Stopping Virtual Printing daemon: done
/sbin/restorecon: Warning no default label for /tmp/vmware-block-restore0/tmp_file
File /etc/pulse/default.pa is backed up to /etc/pulse/default.pa.old.0.
The removal of VMware Tools 9.6.1 build-1378637 for Linux completed
successfully.
Installing VMware Tools.
In which directory do you want to install the binary files?
[/usr/bin]
What is the directory that contains the init directories (rc0.d/ to rc6.d/)?
[/etc/rc.d]
What is the directory that contains the init scripts?
[/etc/rc.d/init.d]
In which directory do you want to install the daemon files?
[/usr/sbin]
In which directory do you want to install the library files?
[/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
In which directory do you want to install the documentation files?
[/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]
The installation of VMware Tools 9.6.1 build-1378637 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
Initializing...
/usr/bin/xrandr: Failed to get size of gamma for output default
Making sure services for VMware Tools are stopped.
Stopping Thinprint services in the virtual machine:
Stopping Virtual Printing daemon: done
Stopping VMware Tools services in the virtual machine:
Guest operating system daemon: [ OK ]
VMware User Agent (vmware-user): [ OK ]
Blocking file system: [ OK ]
Unmounting HGFS shares: [ OK ]
Guest filesystem driver: [ OK ]
VM communication interface socket family: [ OK ]
VM communication interface: [ OK ]
Found a compatible pre-built module for vmci. Installing it...
Found a compatible pre-built module for vsock. Installing it...
The module vmxnet3 has already been installed on this system by another
installer or package and will not be modified by this installer.
Use the flag --clobber-kernel-modules=vmxnet3 to override.
The module pvscsi has already been installed on this system by another
installer or package and will not be modified by this installer.
Use the flag --clobber-kernel-modules=pvscsi to override.
The module vmmemctl has already been installed on this system by another
installer or package and will not be modified by this installer.
Use the flag --clobber-kernel-modules=vmmemctl to override.
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
Found a compatible pre-built module for vmhgfs. Installing it...
Found a compatible pre-built module for vmxnet. Installing it...
The vmblock enables dragging or copying files between host and guest in a
Fusion or Workstation virtual environment. Do you wish to enable this feature?
[yes] yes
VMware automatic kernel modules enables automatic building and installation of
VMware kernel modules at boot that are not already present. This feature can be
enabled/disabled by re-running vmware-config-tools.pl.
Would you like to enable VMware automatic kernel modules?
[no] no
Thinprint provides driver-free printing. Do you wish to enable this feature?
[yes] yes
Disabling timer-based audio scheduling in pulseaudio.
Detected X server version 1.13.0
Distribution provided drivers for Xorg X server are used.
Skipping X configuration because X drivers are not included.
Creating a new initrd boot image for the kernel.
Starting Virtual Printing daemon: done
Checking acpi hot plug [ OK ]
Starting VMware Tools services in the virtual machine:
Switching to guest configuration: [ OK ]
VM communication interface: [ OK ]
VM communication interface socket family: [ OK ]
Guest filesystem driver: [ OK ]
Mounting HGFS shares: [ OK ]
Blocking file system: [ OK ]
VMware User Agent: [ OK ]
Guest operating system daemon: [ OK ]
The configuration of VMware Tools 9.6.1 build-1378637 for Linux for this
running kernel completed successfully.
You must restart your X session before any mouse or graphics changes take
effect.
You can now run VMware Tools by invoking "/usr/bin/vmware-toolbox-cmd" from the
command line.
To enable advanced X features (e.g., guest resolution fit, drag and drop, and
file and text copy/paste), you will need to do one (or more) of the following:
1. Manually start /usr/bin/vmware-user
2. Log out and log back into your desktop session; and,
3. Restart your X session.
Enjoy,
--the VMware team
Found VMware Tools CDROM mounted at /media/VMware Tools. Ejecting device
/dev/sr0 ...
/sbin/restorecon: Warning no default label for /tmp/vmware-block-restore0/tmp_file
[root@XD-ORACLE vmware-tools-distrib]#
安装完成后,选择虚拟机上方的:虚拟机-设置-选项-客户机隔离,勾选“启用复制粘贴”,然后重启centos系统,就可以实现在虚拟机系统与主机系统之间复制,粘贴文字,以及文件可以直接在两系统间拖动了。
8 启用共享文件夹
在命令窗口输入如下命令(ls /mnt/hgfs/)之后,会看到自己刚刚设置的共享文件夹
[root@localhost ~]# ls /mnt/hgfs/
develop
[root@localhost ~]#
完整的自定义开机程序 /etc/rc.d/rc.local
[root@localhost ~]# cat /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
#start redis
/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
#mount disk 2 挂载第二块硬盘
/bin/mount /dev/sdb1 /work
#start nginx 以root账号 启动 nginx
/usr/bin/su - root -c "/usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf"
# 启动 zookeeper
/usr/bin/su - root -c "/work/zookeeper/zookeeper-1/bin/zkServer.sh start"
/usr/bin/su - root -c "/work/zookeeper/zookeeper-2/bin/zkServer.sh start"
sleep 10s
#start springcloud 注册中心 eureka
/usr/bin/su - root -c "/work/cloud-eureka-1.0-SNAPSHOT/bin/start.sh start"
sleep 20s
#start springcloud 配置中心 config
/usr/bin/su - root -c "/work/cloud-config-1.0-SNAPSHOT/bin/start.sh start"
# 启动 Nacos ,如果要使用的话
/usr/bin/su - root -c "/work/nacos/bin/startup.sh -m standalone"
以上用到的 su命令,说明如下:
su - root -c command :
切换到root并获得root的环境变量及执行权限并执行命令,
-c
是command的缩写