1. Software preparation#
-
CentOS7.6 system image file, this article uses CentOS-7.6.1810
-
Official website download addresshttps://wiki.centos.org/Download
-
Alibaba Cloud download addresshttps://mirrors.aliyun.com/centos-vault/
-
The VMware Workstation software is installed in the Windows system. The following is the recommended version of VMware Workstation software
-
Windows7:VMware Workstation12.0
-
Windows10:VMware Workstation14.0
2. Create a virtual machine#
After selecting the system image, if you choose Install the program CD image file
, the system will be installed automatically. Although it is convenient, it will install too many services and programs, and will automatically partition, so we choose Install the system later
to come Install the system manually.
System version |
Memory required for installation |
Memory required for startup |
CentOS-5 |
256M |
100M |
CentOS-6 |
At least 512M, recommended 1GB+ |
at least 512M, recommended 1GB+ |
CentOS-7 |
at least 512M, recommended 1GB+ |
at least 512M, recommended 1GB+ |
If the memory is smaller than the minimum recommended memory during installation, an error may be reported. In addition, it is recommended to set a larger value during installation, such as 2GB, and then adjust it according to the local resource usage.
The following briefly introduces network types:
- NAT (Network Address Translation): Network address translation, virtual machines go online and exchange data through [Host] (https://cloud.tencent.com/product/cdh?from=10680). In NAT mode, the virtual machine's network card is connected to the host machine's VMnet8, and the VMware NAT Service service in the host machine acts as a router. It is responsible for address translation of the packets sent by the virtual machine to VMnet8 before sending to the actual network. In the same way, the packets returned on the actual network are translated and sent to the virtual machine through VMnet8. VMware DHCP Service is responsible for assigning IP addresses to the virtual machines. NAT network is suitable for the host computer directly connected to the network cable or the office LAN environment. The advantage is that it will not conflict with the IP of other physical machines. After changing the network environment, the virtual machine's IP will not be affected. NAT mode is recommended.
- Bridged (Bridged mode): The virtual machine can be assigned to the independent IP of the same network segment of the host. All network functions are almost the same as the real machine. The virtual machine is directly connected to the real network. Applicable scenarios: LAN environment, advantages: remote machines can Disadvantages of accessing the virtual machine through the router: the communication with the host machine will go through the real router, and may cause IP conflicts. After changing the network environment, the IP of all virtual machines will be affected.
- Host-only (host mode only): The virtual machine cannot access the external network and can only communicate with the host
3. Virtual host network configuration#
4. System installation#
4.1 Enter the system installation guide interface##
Tip: Mouse switch between virtual machine interface and Windows interface: Ctrl + Alt
4.2 Modify the form of the network card named eth0 (consistent with CentOS7 before)
-
In order to unify the environment where multi-version systems coexist in the enterprise, the network card name is set to the form of "eth*" here, instead of using the default special network card naming rules of CentOS7, the relevant instructions are as follows:
The naming method of the ethX numbered network card before CentOS7 often does not exactly correspond to the physical order of the network card interface. The default naming method of the network card of CentOS7 can solve this problem, but it also brings additional troubles to the Linux system administrator, namely It is not compatible with the environment and usage habits of CentOS6, so generally it will be changed back to the early eth0 and eth1 network card naming methods. The specific modification of the kernel parameter combination is as follows, the default kernel parameters (biosdevname=0,net.ifnames=1), network card If the name is "enp5s2", if biosdevname=1, net.ifnames=0, the network card name is "em1", if biosdevname=0, net.ifnames=0, the network card name is "eth0" (traditional way)
-
Therefore, during the initial installation, you need to increase the kernel parameters (you can also configure after the system is installed, refer to https://blog.51cto.com/oldboy/1722101), first select Install CentOS 7
, Press Tab to enter the kernel parameter configuration interface, and manually enter the following parameters. After the input is complete, press Enter to enter the next step, and then you will see a prompt to press Enter, just wait
4.3 Choose language, it is recommended to choose English##
If you cannot see the Continue button due to resolution issues, you need to enter full screen mode:
4.4 Installation Summary Page (INSTALLATION SUMMARY)
4.5 Configure system time zone and time (DATE&TIME)
4.6 Select additional language support (LANGUAGE SUPPORT)
4.7 System software package selection (SOFTWARE SELECTION)
According to experience, the principle of minimization should be adopted when selecting the installation package, that is, things that are not needed or not sure whether they are needed are not installed, that is, "Minimal Install", which can ensure system security to the greatest extent.
If some components are missing during the installation process, or other partners did not select during installation, then after the installation is complete, you can add the uninstalled components in the following ways:
The commands for installing "Compatibility Libraries", "Base" and "Development tools" are:
yum group install "Compatibility libraries""Base""Development tools"
The commands for installing the two components "Debugging Tools" and "Dial-up Networking Support" are:
yum group install "debugging Tools""Dial-up Networking Support"
You can view the installed packages through yum groupinfo [package-name]
.
4.8 Configure network and hostname (NETWORK&HOSTNAME)
4.9 Select disk partition, configure partition (INSTALLATION DESTINATION)
Introduction to Linux Disk Partition Knowledge
- Disks must be partitioned before they are used (equivalent to dividing the house into several residences)
- Disk partitions are divided into primary partition, extended partition and logical partition. A disk can have up to 4 primary partitions. Among them, the location of a primary partition can be replaced by an extended partition, and multiple logical partitions can be divided into this extended partition
- If the number of planned partitions exceeds 4, the partition combination can be 3primary(p)+1extend(e) or 2p+1e or 1p+1e
- A disk can only have one extended partition at most. The extended partition cannot be used directly. You must divide the logical partition on the extended partition and format (create a file system) before you can access data or install the system
Disk partition naming and numbering
- Named after the device name
In the Linux system, disk devices correspond to special files in the system. These special files are placed in the "/dev" directory. The device names corresponding to different devices are as follows:
- The hard disk name of the first IDE interface of the system is /dev/hda
- The hard disk name of the second IDE interface of the system is /dev/hdb
- The hard disk name of the first SCSI interface of the system is /dev/sda
- The hard disk name of the second SCSI interface of the system is /dev/sdb
- Use number
In order to indicate different partitions, numbers are usually used for numbering, such as:
- The name of the first partition of the system’s first IDE interface hard disk is /dev/hda1
- The fifth partition name of the first IDE interface hard disk of the system is /dev/hda5
- The name of the first partition of the hard disk with the second SCSI interface of the system /dev/sdb1
- The name of the fifth partition of the hard disk with the second SCSI interface of the system /dev/sdb5
When numbering the partitions, the numbers 1-4 can only be reserved for the main partition or the extended partition, which will be created by the system during installation
Click "Done" to enter the partition setting page:
Description:
LVM means logical volume management, which can dynamically adjust the size of the partition that has been set, provided that all partition formats need to be made into LVM partition format in advance, that is, the partition label is 8e, and the partitions in the enterprise environment are generally based on demand The realization of the plan is good, there is very little need for subsequent adjustments, and there is still a certain gap in the performance of LVM compared with standard partitions and hardware RAID cards. Therefore, if there are no special requirements, LVM functional partitions will not be selected, but Use the better standard partition mode "Standard Partition".
Linux system's basic requirements for partitions
- It is better to have a root (/) partition for storing system files and programs, the size is above 5GB
- There must be a swap partition, which is equivalent to the virtual memory of Windows. The size of the swap partition is generally 1.5 times the physical memory capacity (memory <8GB). When the physical memory of the system is greater than 8GB, the swap partition configuration is 8- 16GB is enough, too large and useless, wasting disk space. The swap partition is not necessary, but in most cases it is better to set it up. The database application scenarios of individual enterprises do not distinguish between swap.
- /boot partition, this is the boot partition of the Linux system, used to store system boot files, such as the Linux kernel. For CentOS7, this partition is a bit larger than the previous version, and can be set to 1024MB. This partition is not necessary
Linux partition scheme in enterprise production scenarios
- Solution 1: For a node server partition in the website cluster architecture, the data on the server contains multiple copies (other nodes also have) and the data is not important. The recommended partitioning method is as follows:
- /boot:512~1024MB
- /swap: When the physical memory is less than 8GB, set it to 1.5 times the physical memory. When the physical memory is greater than or equal to 8GB, allocate 8-16GB. It is recommended to give 8GB.
- /: The remaining space of the hard disk (/usr, /home, /var and other partitions and "/" share the same partition, which is equivalent to only one C drive in the Windows system, all data and system files are stored together)
- Solution 2: For the server partition of the database and storage roles, the server's business contains a lot of important data. The recommended partitioning method is as follows:
- /boot:512~1024MB
- /swap: When the physical memory is less than 8GB, set it to 1.5 times the physical memory. When the physical memory is greater than or equal to 8GB, allocate 8-16GB. It is recommended to give 8GB.
- /: The size is set to 50~200GB, only system-related files are stored, and business data such as websites are not stored here
- /data: The size of the remaining hard disk space, storing important data such as databases and storage services, of course, the name of data can be customized
The second option is to partition important data separately for easy backup and management
- Solution 3: Partition the servers of large websites or portal-level enterprises
- /boot:512~1024MB
- /swap: When the physical memory is less than 8GB, set it to 1.5 times the physical memory. When the physical memory is greater than or equal to 8GB, allocate 8-16GB. It is recommended to give 8GB.
- /: The size is set to 50~200GB, only system-related files are stored, and business data such as websites are not stored here
Reserve the remaining disk space and no longer partition it. In the future, it will be allocated to different user departments, and they will be subdivided according to their needs. This partitioning scheme is more flexible and more suitable for large enterprises with more business lines and uncertain needs.
- Not recommended partition scheme:
Manually partition /usr, /home, /var, etc., so that too many additional partitions are allocated, which are unnecessary and cause management troubles. This partitioning method is not recommended
This article uses scenario one to partition:
- Mount Point: Mount Point, this is the entry point for Linux to access the disk partition, that is, if you want to write data to the /boot partition (/dev/sda1), you must write through the /boot entry
- File System: File system type. The disk partition can store data only after the file system type is set, formatted and mounted to the mount point. Common file system types are as follows:
- xfs: An excellent file system type, replacing ext4 as the default file system type in CentOS7
- ext2/ext3/ext4: A file system type suitable for Linux. ext3 has more logging functions, so the system will recover faster. ext4 is an upgrade of ext3, which is more efficient. CentOS6 uses ext4 by default.
- physical volume (LVM): A mechanism to flexibly adjust the size of the file system, that is, the file system can be made larger or smaller without changing the content of the original file data. The function is good, but the performance will be reduced.
- swap: Memory swap space. Since swap does not use the mounting of the directory tree, there is no need to specify the mount point
- vfat: supports both Linux and Windows file system types. If the host has both Windows and Linux operating systems and there is a data exchange requirement, this file system type can be used
Click "Done":
Note: Check if all partitions (/, /boot, swap) are Standard Partition.
4.10 System security related##
- KDUMP: save system memory abnormal information before the downtime
- SECURITY POLICY: System security policy configuration
4.11 System installation##
Click "Begin Installation":
Set the password of the root user:
Set the password of a common user: It prompts that the password is not strong enough, you need to click "Done" twice to force use
Then wait for the system to be installed. When the Reboot button appears, it is already installed:
Then click the Reboot button to restart. The restart process does not require any operation, just wait.
5. Operation and configuration after system installation#
5.1 Login to view basic information##
Information on the login interface:
-
Version information: Kernel 3.10.0-957.el7.x86_64 on an x86_64
-
3 : Major version number, only changed when there are structural changes
-
10 :Minor version number, which will be changed after new functions are added. Generally, the odd number is the test version, and the even number is the development version.
-
0 : Indicates the number of revisions or patch packs of the minor version
-
957 : Compilation times, a few programs can be optimized or modified each time
-
el7: version specific information, with greater arbitrariness, el represents the enterprise version of Linux (pp represents the beta version of Linux, fc represents the fedora core, and rc represents the candidate version)
-
x86_64: 64-bit operating system
-
[ root@node01]#
中#: The prompt for the super administrator root to enter commands. After the # sign, you can enter commands to manage the system. For example, you can enter the following command to view system information:
Manually view the system version information# If there is _64, it is a 64-bit operating system# If there is i386/i686, it is a 32-bit operating system [root@node01]# uname -m x86_64 [root@node01]# uname -r 3.10 .0-957.el7.x86_64 [root@node01]# uname -a Linux node01 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux # The following command If there is a result, it is a 64-bit operating system [root@node01]# ls -d /lib64 /lib64
5.2 Check network configuration##
- ip address show, abbreviated as ip a: view IP information
- ip route: view gateway settings
- View DNS settings: cat /etc/resolv.conf
- clear/Ctrl + L, clear the screen content
5.3 Troubleshooting method for the system unable to connect to the Internet##
- Check if IP, subnet mask, gateway and DNS are set correctly
To replace a certain configuration in this file, for example, the command to change ONBOOT=no to ONBOOT=yes is:
sed -i 's#ONBOOT=no#ONBOOT=yes#g' /etc/sysconfig/network-scripts/ifcfg-eth0
View a certain configuration, such as the command to view the value of ONBOOT configuration:
grep ONBOOT /etc/sysconfig/network-scripts/ifcfg-eth0
Restart the network card after modification:
systemctl restart network
- Check whether the VMware NAT service of Windows is enabled
5.4 Use the nmtui command to set the network card##
If there is a problem with the server's network, you may need to reset the network card information. You can modify the configuration by modifying the file /etc/sysconfig/network-scripts/ifcfg-eth0
. Here is a method of setting using the UI interface.
- Enter
nmtui
command and press Enter
- Operation of various interfaces of nmtui
- After setting, select "OK", "back", "quit" in turn to save and return to the command line
5.5 Virtual machine save snapshot##
- Shut down first: poweroff
- Then create a snapshot