Table of contents
2. Installation and configuration of centos7
4. Initial settings for virtual machine startup
1. Check the network configuration
4. VMWare virtual machine snapshot manager
Preface
CentOS 7 is a popular Linux operating system with stability and security for servers and PCs. This blog will introduce the installation and configuration process of CentOS 7, and provide some commonly used Linux commands to help beginners get started quickly.
1. centos7 operating system
1.Introduction to centos7
CentOS 7 is a Linux operating system based on the Red Hat Enterprise Linux (RHEL) source code. It is a free, open source operating system for server and enterprise environments designed to provide stability and security.
CentOS 7 adopts many enterprise-level technologies and features, such as systemd service manager, XFS file system and support for Docker containers. At the same time, it also supports various software packages and applications, such as Apache web server, MySQL database, and PHP programming language.
2. Installation and configuration of centos7
Open the virtual machine (VM ware) and create a new virtual machine
Here are the differences between the three network connection modes of the virtual machine:
About VMware’s three network connection methods: NAT Bridged Host-Only
First of all: NAT mode
relies on the ultimate physical VMware8 network card to access the Internet. Virtual machines can ping each other, provided that the gateway of the physical host's VMnet8 network card
must be the same as the virtual machine! If they are not on the same gateway, the virtual machine may be able to ping the physical host, but the physical host cannot ping the
virtual machine.
1. The NAT method makes it convenient for the virtual machine to access the external network. No other configuration is required. It only requires that the physical host can access
the Internet. 2. If you want to install a virtual machine but do not want to configure the network, it is recommended to use the NAT method to access the Internet.
3. The TCP/IP configuration information of the virtual system in NAT mode is provided by the DHCP server of the VMnet8 (NAT) virtual network and cannot
be modified manually. Therefore, the virtual system cannot communicate with other real hosts in this LAN. .
( The reason why the cluster cannot be configured with NAT )
Secondly: Bridged (bridge)
Based on the above topology test, the system virtualized by the bridge method is like an independent "physical machine" that exists alone in the LAN. It can
access any server in the same LAN. A machine can also access the external network through a LAN gateway or router alone.
However, IP, gateway, network segment, DNS, etc. need to be configured separately on each machine.
Since this virtual system is a separate host system in the LAN, its TCP/IP configuration information can be manually configured to
access the Internet through the LAN gateway or router.
Using the same gateway segment configuration, Bridged can be used to configure the cluster.
Finally:
The TCP/IP configuration information (such as IP address, gateway address, DNS server, etc.) of the Host-Only (host) virtual machine is
dynamically allocated by the DHCP server of the VMnet1 (host-only) virtual network.
In this mode, all virtual machines in all LANs can communicate with each other, but the virtual machines cannot access the external network and are completely isolated from the external network.
This mode can also configure a cluster, but the cluster cannot access the external network, so it is more suitable for the company's intranet.
3. Configure centos mirroring
Centos image download https://wiki.centos.org/Download.html Double-click the CD/DVD, then use the ISO image file (where you store it), confirm, and then start the virtual machine
4. Initial settings for virtual machine startup
Note: Keep the network open during the installation process.
Note: If this error message appears, it means that the "CentOS 64-bit" selected previously cannot be installed.
Reason: The Virtualization Technology setting in the computer BIOS is disabled.
solution:
(1) Restart the computer, enter the BIOS and set it to Enabled. (Note: Different brands of computers have different methods of entering the BIOS. Please check online for the method of entering the BIOS of the corresponding computer model)
(2) After entering the BIOS, set Security -> Virtualization -> Inter(R) Virtualization Technology to: Enabled.
(3) Save the BIOS and restart the computer.
(4) Note: Various brands of machines have different BIOS configurations. Determine your computer brand, and then check the information on how to configure it.
Note: Do not select minimal installation in "Software Selection" here. Minimal installation will not install some commonly used commands in Linux. You will also need to install the commands yourself, which is more troublesome.
Here, select "Infrastructure Server" to install, and select "Debugging Tools" on the right. Note: The debugging tool has no interface.
Next click to start the installation
After installation, restart
Note: The perfect solution to a black screen when the virtual machine is turned on
First, we search for "CMD" in the search bar of the start menu and find the command prompt. We right-click "Command Prompt" and select "Run as administrator" from the pop-up menu, as shown in the figure below.
Enter "netsh winsock reset" in the command prompt window and then restart the computer to solve the problem.
If it doesn't work, uncheck Accelerate 3D graphics in the content column on the right in VM->Settings->Hardware->Display, and then restart the computer.
5. View and set IP address
Enter: cd /etc/sysconfig/network-scripts/ (enter directory)
Enter: ll (to view all files or ls)
Check the IP address: ip addr or ifconfig. Note the difference with the windows environment. In win, it is ipconfig.
Check that there is no inet attribute in ens33, which means that the ip is not specified for the virtual machine, so you cannot connect to the virtual machine through ip.
Note:
The new version of CentOS7 has a set of rules for the numbering of network cards. The codename of the network card is related to the type of the network card:
- eno1: represents the network card built into the motherboard bios
- ens1: represents the PCI-E network card built into the motherboard bios
- enp2s0: PCI-E independent network card
- eth0: If none of the above are used, return to the default network card
ens33, which belongs to the second type, which means that your network card is a built-in PCI-E network card.lo: The full name is loopback, which is the loopback address. It is often assigned to the 127.0.0.1 address and is used for local communication. It returns directly after kernel processing and will not appear on any network.
link/ether: MAC address, hardware address, global Unique
network device status identifier: <BROADCAST,MULTICAST,UP,LOWER_UP>
UP: The network card is in the startup state
BROADCAST: The network card has a broadcast address and broadcast packets can occur
MULTICAST: The network card sends multicast packets
LOWER_UP: L1 is started, that is, the network cable is plugged in On.
Use vi to edit ifcfg-ens33
- Enter the command: vi ifcfg-ens33 to enter the editing interface
- Click the i key to enter insert mode. The mouse is unavailable at this time. Use the up, down, left and right buttons to move the mouse.
- Change the ONBOOT value to yes
- ESC key to exit insert mode
- :wq means save and exit. If you want to exit without saving, enter :q!
vi: Edit; :q!: Exit the file without saving; cat: View; :wq: Exit and save;
Note:
ONBOOT: Indicates whether to activate the network card when the system starts. Only the activated network card can connect to the network for network communication.
DEVICE: The name of the network card
BOOTPROTO=none indicates what routing protocol is used. If the value is none/static, it indicates that the network card is used. Static routing, then you must fill in the IPADDR (ip address), NETMASK (subnet mask), GATEWAY (gateway), and DNS1 options. If it is dhcp, it means that dynamic routing is used. The above mentioned items do not need to be Fill it in and it will be automatically assigned by the DHCP service. If it is filled in, it will be based on what you filled in.
HWADDR: The physical address of your network card. You don’t need to write it. The system will automatically generate it.
If you only view files, you can use the following command: cat The file name is: cat ifcfg-ens33
service
network restart
After restarting, use the ifconfig / ip addr command again to view the ip address.
Shut down, restart, log off
1) Shut down
- shutdown -h now Shut down immediately
- shutdown -h +1 shut down after one minute
- poweroff immediately stops the system and turns off the power
2) Restart
- reboot reboot
- shutdown -r now Restart immediately
- shutdown -r +1 Restart after one minute
3) Log out
- logout
- exit
- ctrl + d
2. Use of MobaXterm tool
1. Introduction to MobaXterm
MobaXterm is a powerful cross-platform remote computer management tool, compatible with multiple operating systems such as Windows, macOS and Linux. It provides a command line interface similar to a Unix terminal and supports multiple protocols such as SSH, Telnet, SCP, and FTP. In addition, MobaXterm also has a built-in X11 server and a variety of network tools, such as ping, traceroute, dig, whois, nc, etc., to facilitate users' network diagnosis and management.
Key features of MobaXterm include:
- A variety of remote connection protocols are built-in, such as SSH, Telnet, RDP, VNC, etc., to facilitate users to manage and remotely control remote computers.
- Provides a Unix-like terminal command line interface that supports commonly used commands and programs.
- It integrates multiple text editors, such as vim, nano, emacs, etc., to facilitate users to edit text and modify configuration files.
- Built-in X11 server supports running graphical applications on remote computers on the Windows desktop.
- It integrates a variety of network tools, such as ping, traceroute, dig, whois, nc, etc., to facilitate users to perform network diagnosis and management.
- It is highly customizable and users can add or remove plug-ins according to their needs.
2.MobaXterm installation
Mobaxterm client tool download https://mobaxterm.mobatek.net/ Download and unzip the file and click on the .exe program to run it
3.Usage of MobaXterm
Use the ifconfig command to view the IP address of the virtual machine
The client enters the IP address to connect
Enter password and account login
4. Switch to domestic sources
Download tool command: yum install wget
Enter the source file: cd /etc/yum.repos.d
Enter the command to continue file backup: mv CentOS-Base.repo CentOS-Base.repo.bak
Generate Ali source: wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
Next we can download the plug-in through Alibaba Source
Execute the yum install vim command to load the vim plug-in
3. Common Linux commands
1. Check the network configuration
ifconfig
You can set the status of network devices or display the current settings. ip addr
The command can also view network configuration information
//Only display the detailed information of the specific network card ifconfig specific network card name //Display all network cards including the unstarted network card ifconfig -a //Indicates turning on or off the network card ifconfig network card name [up/down] //Temporarily set the network card address ifconfig network interface IP address [/subnet mask length] //Create a new virtual network card ifconfig network card name: numeric address //View communication messages ifconfig -s
2.File management
cd ~ # Enter the user's home directory cd / # Return to the previous level cd .. # Enter the root directory dir # View all files in the current path ls # List all contents in the current folder ls -ltr | cat -vte # Display Details of all contents under the folder pwd # Display the current path clear # Clear the terminal screen command, Ctrl+L to clear the screen mkdir xxx # Create a new folder rmdir xxx # Delete the folder mv # Move or rename rm -r xxx # Delete folders or files rm -rf xxx # Recursively delete folders and subfolders, use cp with caution # Copy touch file name # Create new file vi file name # Edit file command cat file name # View file content
3.vi or vim editor
The Vi editor is the standard editor under all Unix and Linux systems, similar to the notepad editor under the Windows system. Since the Vi editor is exactly the same in any version of Unix and Linux systems, it can be used in Any other place where vi is introduced can be used to learn more about it. Vi is also the most basic text editor in Linux. After learning it, we will be able to flow smoothly in the Linux world, especially in the terminal.
Both vi and vim are editors in Linux. The difference is that vim is more advanced and can be regarded as an upgraded version of vi. vi is used for text editing, but vim is more suitable for coding.
There are three modes in Vim (public perception): command mode, editing mode (input mode), and last line mode (last line mode).
3.1.Command mode
After starting the vi editor, it enters command mode by default. In this mode, related operations such as cursor movement, string search, deletion, copying, and pasting of file contents are mainly completed.
Order | illustrate |
---|---|
gg | Move the cursor to the first line |
G | Move the cursor to the last line |
yy | By 按键:yy copying a line. Based on the line where the cursor is located (including the current line), copy the specified number of lines downwards. Press the p key where you want to paste |
number yy | By 按键:数字yy copying multiple lines |
dd | After deletion, move the next line up dd. Strictly speaking, it is a cut command, but if you cut it without pasting, it will have the effect of deletion. |
Number dd | Delete multiple lines |
After deletion, the current line will become a blank line. | |
u | Cancel |
3.2.Edit mode
The main operation in this mode is to enter the file content, and you can modify the text file body or add new content. When in input mode, the status prompt message "-- INSERT --" will appear on the last line of the vi editor.
Order | illustrate |
---|---|
i | Start inserting before the character under the cursor |
a | Start inserting after the character under the cursor |
o | Insert a new line below the line where the cursor is. |
l | Insert starting from the first line of the line where the cursor is located. If there is a space at the beginning of the line, insert it after the space. |
A | Start inserting at the end of the line where the cursor is. |
O | Start inserting on a new line above the line where the cursor is. |
S | Delete the line under the cursor and start inserting |
3.3.Last line mode
In this mode, you can set up the vi editing environment, save files, exit the editor, and perform operations such as searching and replacing file contents. When in the last line mode, the == colon ":" == prompt will appear on the last line of the vi editor.
Order | illustrate |
---|---|
:wq | Save and exit |
:q | quit |
:q! | Force quit, the modifications just made will not be saved. |
:w | save document |
:w path | Save as |
:/keyword | Search/Find |
:$ | jump to end of file |
:number | Jump to line N of file |
4. VMWare virtual machine snapshot manager
effect:
Back up virtual machine state: Use Snapshot Manager to create a snapshot of a virtual machine, a backup of its current state. Through snapshots, administrators can record the complete state of a virtual machine at a certain point in time, including the operating system, applications, and data. In this way, if problems arise during subsequent operation and maintenance or configuration changes, the virtual machine can be quickly restored to its previous state.
Simplify test and development environments: In test and development environments, frequent configuration changes and experiments are common. Using Snapshot Manager, administrators can create a snapshot before each change, allowing them to quickly roll back to a previous state if needed. This can greatly simplify the testing and development process and improve efficiency.
Disaster recovery: When a catastrophic failure occurs or a major problem occurs with a virtual machine, the snapshot manager can help administrators quickly restore the virtual machine to normal working status. By using previously created snapshots, administrators can easily restore a virtual machine to its state before the failure, thereby reducing business interruption time.
Experimentation and rollback: Before undertaking major operations, administrators can use Snapshot Manager to create a snapshot as a safe backup. If an experiment fails or operations go wrong, you can easily roll back to a previous snapshot state without having to manually restore or recover the virtual machine.
Steps for usage
Restore operation