Linux basic environment construction (CentOS7)-virtual machine preparation
Introduction to Linux
Strictly speaking, Linux is not an operating system, but only the kernel in the Linux system, that is, the platform between computer software and hardware communication; the full name of Linux is GNU/Linux, which is a real Linux system. GNU is a project organized by Richard Stallman. Programmers from all over the world can transform GNU programs, and at the same time follow the GPL agreement, allowing anyone to change it at will. However, the modified program must follow the GPL agreement.
Linux is a multi-user and multi-tasking operating system, as well as a free software, fully compatible with POSIX standards, with a good user interface, supporting multiple processor architectures, and easy portability.
The software that allocates system resources to programs and handles the internal details of the computer is called the operating system or kernel. If you want to learn more about operating system concepts, please check the operating system tutorial.
The user interacts with the Linux kernel through Shell. Shell is a command line interpretation tool (a piece of software) that converts commands entered by the user into a language (command) that the kernel can understand.
virtual machine
On a physical computer, one or more virtual computers simulated by software are called virtual machines. The virtual machine uses the hardware resources of the host machine and has most of the functions of a real computer. You can install the operating system supported by the virtual machine software in the virtual machine. For example, you can install linux in the vm virtual machine, or you can install windows in the vm virtual machine, no matter if your host machine is using lunix system or windows system .
1. Create a new virtual machine
1.1 New
First create a new virtual machine
Choose the typical, the next step is
to choose to install the operating system later, the next step
Since we are installing CentOS7, so choose Linux, and then choose CentOS7 64-bit, the next step is
to write a name for the virtual machine, choose a suitable disk storage virtual machine Data (don’t choose drive C!) The
largest disk varies from person to person, 20G is recommended, and the next step is to
complete
Now use the ISO image file for the virtual machine
Need to use the ISO image file (need to download) to create a new virtual machine after completion of
select Chinese - Simplified Chinese
file selection
to select the software you want to install their own
Suggestion: Development and generation workstations (just select the required software):
FTP server, file and storage server, graphics generation tool, hardware monitoring tool, identity management server, KDE, large system performance, compatibility of traditional X Windows system, MariaDB Database server, PHP support, Python, virtualization hypervisor, security tools, smart card support, system management tools
Set root password and create user
Since it is not for commercial use, the password can be simple.
Wait for the download,
restart,
accept the license, and
tick to
log in to the user.
Select the language and
finish!
Open the terminal and perform command line operations~
1.2 Cloning
Clone the virtual machine to reduce tedious steps
Right-click the virtual machine you want to clone, manage-clone,
select the current state of the virtual machine, and
choose to create a full clone in the next step.
Similarly, in the next step , write a name for the virtual machine and choose a suitable disk to store the virtual machine's data (don't select C drive!)
2 Modify the static IP of the virtual machine
Get the serial number of the machine first, copy and paste it into the ifcfg-ens33 file
ip addr
Edit the ifcfg-ens33 file, modify the BOOTPROTO and ONBOOT parameters, add IPADDR, NETMASK, GATEWAY, DNS1, DNS2, HWADDR (paste the serial number just copied), and then save it with wq.
vim /etc/sysconfig/network-scripts/ifcfg-ens33
! ! ! Note: The
first two digits of IPADDR are fixed at 192.168, the third digit needs to be queried by ipconfig in the cmd window of the window system, and the fourth digit should not exceed 255 (the fourth digit of the three virtual machines cannot be the same)!
The first 3 digits of GATEWAY are the same as IPADDR, and the fourth digit is 2!
3 Modify the host name (all three machines need to be changed)
vim /etc/hostname (主节点master,从节点slave1,从节点slave2)
Configure the hosts file
vim /etc/hosts(三台机器都执行)
Enter the corresponding IP of each node (previously modified the static IP settings of the virtual machine)
Restart the virtual machine (the three operations are complete)
reboot
4 Turn off the firewall
View firewall status
systemctl status firewalld.service
Stop firewall
systemctl stop firewalld.service
Prohibit firewall startup
systemctl disable firewalld.service
5 Time synchronization
tzselect #三台机器都执行
yum install -y ntp #下载ntp(三台机器都执行)
vim /etc/ntp.conf #添加内容
Add content as follows:
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10 #stratum is also possible to set other values, the range is 0~15
/bin/systemctl restart ntpd.service #重启ntp服务(master上执行)
ntpdate master #其他机器进行同步(在slave1,slave2中执行)
/bin/systemctl restart ntpd.service #重启ntp服务(在slave1,slave2中执行)
6 Configure ssh without password
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa #在master上执行如下命令生成公私密钥:(注意master上执行)
ssh-copy-id -i /root/.ssh/id_dsa.pub slave1 #将master公钥复制到slave1
ssh-copy-id -i /root/.ssh/id_dsa.pub master #将master公钥复制到master
ssh-copy-id -i /root/.ssh/id_dsa.pub slave2 #将master公钥复制到slave2
Note: The above is only the exemption from master to slave1 and slave2. If you want to configure other secret-free, the command is similar.
退出连接:exit
7 Xshell tool connection
Need to create 3 new
windows. The names of the three windows are the respective IPADDRs of the previous 3 nodes
, then connect, then accept the agreement, and finally log in to the root user!
The software installation package that needs to be used can be transferred to the virtual machine with the Xftp tool