Analysis of common problems in VMware virtual machine deployment linux system

  1) How to use linux desktop

  When the installed linux system virtual machine is used as a server, minimal installation is used by default for safety. Developers who like to use the desktop can choose to install the GNOME desktop, as shown in the figure below, select the additional installation desktop. The function of this machine is no different from that of a windows computer. It can work normally on the Internet or continue to use it as a server.

image.png

  2) Manually customize the partition problem

  When the installation system selects a custom partition, a partition is divided and the next operation cannot be performed, often because there are too few partitions that do not meet the requirements of system creation.

  Virtual machine system disk partition generally requires three areas: /boot (kernel partition), / (root partition), swap (swap partition)

  /boot (kernel partition) generally needs to allocate 200M, this is used for boot loading of the system kernel. Swap (swap partition) is to temporarily exchange the disk space for storing part of the data in the memory when the system memory is insufficient. Generally, the size of the virtual test machine can be set to 2G, and the size of the production machine is set according to the demand. / (Root partition) is the root partition, where the system and applications are installed, and all remaining disk space can be allocated to this partition. Divide into three partitions as shown below:

image.png

   3) How to choose linux file system

  There are many kinds of linux file systems, the common ones are ext3, ext4, xfs, swap, etc. The default file system of Centos7 is xfs, Centos6 uses ext4, and Centos5 is ext3. The difference in read and write performance of these three file systems is not particularly large. Because read and write performance has a lot to do with disk material, quality, and category, mainly due to differences in capacity and scalability; ext3 supports 32000 subdirectories. When the block size is 1024, a single file supports a maximum of 16GB, and a single partition supports a maximum of 2T , Single disk maximum 8T; ext4 theory supports unlimited subdirectories, single file maximum support 16TB, single partition maximum support 1EB, single disk maximum capacity 4EB; xfs is a file system with log, which can be used for data recovery through log, with high security , Support wireless sub-directories, good scalability, single file system maximum support 8EB, overall performance is superior. According to the usage of linux market, xfs file system is recommended.

  4) Cannot find the mouse when using VMware virtual machine

  In the virtual machine in VMware, the mouse cannot be used in the command line interface of the default minimal installation, and it cannot be copied and pasted. When operating on the command line, the default exclusive mouse and keyboard cannot operate other contents of the host, and you need to use the Ctrl+Alt key combination to exit. Use the ssh client tool to connect to avoid this situation, and copy and paste can also be used to more easily manage these virtual servers.

  5) Forget the root password of the virtual machine

  When you forget the root password, don't panic, just use the single-user mode to reset the password. The following are the steps for Centos7.6.

  1 Restart the system ---> the first page of the grub boot program, press e to enter the edit mode

  2 Add rd.break at the end of the line at the beginning of Linux16, and then press Ctrl+c to enter single-user mode

  3 Perform remounting of the /sysroot partition: mount -o remount,rw /sysroot/

  4 Switch to the /sysroot partition path: chroot /sysroot/

  5 Use passwd command to modify the root password, the password must be more than 8 characters, such as super@2020 passwd

  6 Create autorelabel file: touch /.autorelabel

  7 Exit the /sysroot partition: exit

  8 Restart the system to log in with the new password: reboot

  The icons are as follows:

image.png

image.png

   6) The problem that the ssh tool cannot connect to the new virtual machine

  After the virtual machine's network configuration is completed, the problem of not being able to connect through the ssh tool is the most common cause is that the virtual machine's firewall is not closed. You can execute the shutdown command on the command line on Vmware. An example of the command to turn off the firewall is as follows:

    Temporarily close SELINUX setenforce 0 

    Permanently close SELINUX sed -i's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config  

    Temporarily turn off the firewall systemctl stop firewalld 

    Permanently turn off systemctl disable firewalld

  7) Chinese garbled characters appear in the ssh tool management server

  ssh工具登录连接服务器,使用中出现汉语乱码问题,出现这种情况有两个可能原因,一种是系统字符集不是utf-8所致,一种是ssh工具的字符集未使用utf-8。使用echo $LANG 命令可以查看系统使用的字符集,如果不是zh_CN.UTF-8,使用命令LANG="zh_CN.UTF-8"临时修改即可。ssh工具则是需要设置Session 配置,打开Session Options,点击Appearance,设置Character encoding为UTF-8即可。当系统和ssh工具的字符集都是utf-8时,命令操作时就不会有汉语乱码现象了。

  8)虚拟机不能连接外网问题

  首先保证宿主机是可以联网的,当虚拟机ping不通外网,说明网络设置连接有问题。在NAT和桥接网络模式下,设置静态ip的配置中,必须配置对应的IPADDR、NETMASK、GATEWAY、DNS参数并保证参数准确可用,然后重启网络即可访问外网。

  桥接模式下静态ip设置参数示例:

    BOOTPROTO="static"        静态ip参数值为static,动态ip参数值为dhcp

    IPADDR="192.168.1.101"    设置的静态ip值,尽量不要与局域网其他机器冲突

    NETMASK="255.255.255.0"   宿主机所在局域网的子网掩码

    GATEWAY="192.168.1.1"    宿主机所在局域网的路由网关

    DNS1="8.8.8.8"              谷歌国际通用DNS

    DNS2="114.114.114.114"          国内通用DNS 

  NAT网络下设置静态ip,首先查看Vmware界面上的配置,编辑--->虚拟网络边界器--->更改设置---->选择Vmnet8---打开 NAT设置,可以查看到子网掩码、网关IP。下面是NAT网络模式下静态ip设置参数示例:

    BOOTPROTO="static"            静态ip参数值为static,动态ip参数值为dhcp

    IPADDR="192.168.142.128"    设置静态ip,在VMware的NAT网络ip范围内

    NETMASK="255.255.255.0"    VMware的NAT网络子网掩码

    GATEWAY="192.168.142.2"     VMware的NAT网络网关IP

    DNS1="8.8.8.8"                  谷歌国际通用DNS

    DNS2="114.114.114.114"              国内通用DNS

  9)yum命令下载速度慢的问题

  新系统安装完成后,默认是Centos的官方yum源,该源在国外,下载安装部分命令工具时速度较慢。解决办法就是替换为国内的yum源,国内通用的有阿里云、网易云、华为云的源,推荐适用阿里的yum源。更换yum源文件前,先安装基础命令 yum install wget vim lrzsz unzip -y,之后按需求更换合适的yum源。

  更换为阿里云yum源步骤示例:

    创建备份目录  mkdir /home/backup

    进入yum源目录  cd /etc/yum.repos.d/

    转移备份repo文件 mv *.repo /home/backup/

    Download the Ali source file wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

    Download Ali epel source wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

    Run yum makecache 

  10) Inaccurate virtual machine time

  If the virtual machine is not configured to use the network time during installation, the time will be inaccurate. You can use commands to perform time synchronization.

    Installation time synchronization command yum install ntpdate -y

    Use Alibaba Cloud timing service ntpdate ntp1.aliyun.com

  The problems listed above are only the tip of the iceberg in operation and maintenance work and learning. One of the most important responsibilities of operation and maintenance is to solve various problems in the system environment. Don't panic when encountering problems. First check the performance of the problem, and then analyze the possibility of the problem. The reason, from the application itself to the related services and even the system, network, configuration, etc., from small to large, from inside to outside, verify one by one according to the direction of analysis, until the problem is solved, and finally make an experience summary. Textbooks, technical blogs, Baidu Google, operation and maintenance bosses, etc. are all important aids to solve problems, and Chang Xin is often used.


Guess you like

Origin blog.51cto.com/superleedo/2544058