K8S from entry to proficiency: 1. Installation of CentOS template machine

注意:This article is the basis of this series. I believe that for senior operation and maintenance, it is as simple as drinking water. The boss skips it directly, Xiaobai can follow along, and there are many details that can be answered.

1. Preliminary preparation

1. Virtual machine (HyperVisor)

There are many ways to build a virtual machine environment, this article mainly uses the installationVmware WorkStation Pro17approach to virtual environments. 安装包下载链接: The official download address , the installation process is simple, this article does not introduce.

2. CentOS7 image file

This article and this column use theCentOS7.9version of the image file, in order to ensure the consistency of the experimental environment, the author recommends 相同the system used by everyone. Link: Tsinghua source download link

2. System installation

At this point, I hope readers have installed their own virtual machine environments and downloaded the required system image files.

VMworkstation
Open the virtual machine control software and choose to create a new virtual machine

Create new virtual machine
Select Typical and click Next

create virtual machine
What you need to pay attention to in this step is to choose to install the system later, because if you choose your own system image in this one, the virtual machine control software may automatically install the system for you. After selecting the correct one, click Next.

create virtual machine
Choose Linux for the operating system, choose the corresponding version for the version, and the system image file prepared by the author is CentOS7.9, so choose CentOS7 64-bit

create virtual machine
Fill in the virtual name to distinguish the virtual machine and select the corresponding storage path. The author recommends that you choose a stable solid-state hard disk. After the cluster becomes larger in the future, the hard disk speed will be an important influence.

create virtual machine
Modify the disk size from the original 20G to 40G. Readers boldly change it. This 40G means capping, and 40G will not be pre-stored.

create virtual machine
create virtual machine
create virtual machine

When you come to the virtual machine hardware configuration section, you don’t need to choose the configuration of memory and processor. Select the path of the CD as the prepared system image file, and select the NAT mode for the network adapter. Change the configuration of each machine) After the selection is complete, click Finish to start the virtual machine and enter the system.

create virtual machine
Press the up arrow key, select "Install CentOS7", and press Enter to confirm

create virtual machine
Press the Enter key to start the process related to system installation (you can also wait for automatic execution), and enter the key steps below

create virtual machine

In the language selection link, it is strongly recommended to select English for the construction, to facilitate future operations, to prevent Chinese garbled characters, or the situation that cannot be typed, and click Continue after selection.

create virtual machine
Select SOFTWARE SELECTION, the default selection is Minimal Install, and the version without GUI is installed. If you want to have a GUI, you can choose Server With GUI. This series of tutorials does not involve GUI, just choose Minimal Install. Then select INSTALL DESTINATION, which is selected by default. After clicking in, click Done on the upper left to complete. Finally, press Begin Installation to start the installation.
create virtual machine
create virtual machine

create virtual machine
To set a password and create an account, just follow the settings given in the picture above. By default, the small numeric keypad is turned off. Please set your own password and remember it. After waiting patiently for a few minutes, you can enter the installed system. 一定要牢记root密码
create virtual machine
Click reboot to reboot into the installed system.

3. System configuration

1. System login

create virtual machine
Enter the user name root and the root password you just set to log in directly with the highest authority. When entering the password, it should be noted that the default numeric keypad is off. If you want to use the small keyboard, press NUMLK on the top of the keyboard. When entering the password It is not displayed by default, so don’t worry, just press Enter after typing.
create virtual machine
The picture shows the successful login interface

2. Network card configuration

create virtual machine

View the local virtual NAT network card information, the operation of the workstation is Edit->Virtual Network Editor, the subnet in the author's environment is 192.168.136.0

Set network card

Set network card
Change the ONBOOT parameter from the original no to yes, BOOTPROTO from the original dhcp to static, manually configure the network, add IPADDR, NETMASK, GATEWAY and DNS parameters, fill in according to your own environment (this part may not be friendly to novices , welcome to leave a message or private message below, of course it is recommended to go online to find other blogs to learn)

service network restart 

After the configuration is completed and saved, enter the above command to restart the network card module.

ping baidu.com

If it can be returned, the network configuration is completed.

3. Network strategy and closing of SELINUX

systemctl stop firewalld && systemctl disable  firewalld
iptables -F 

Enter the above command in the terminal to clear the network policy

setenforce 0

Enter the above command to close selinux temporarily, and it will fail after restarting. In order to permanently close selinux, you can modify the configuration file as follows

vi /etc/selinux/config

configuration of selinux

getenforce

Enter the above command in the terminal to view the current status of selinux.

4. Basic software installation

The image file given in the Tsinghua source has been configured with the yum repository (students who use other images can visit the relevant image sites, or refer to other blogs for operations). Decentralization gives the repo.list file

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra      
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra       
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra   
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

yum makecache

After configuring the yum repository, enter the above command to generate the cache, and then start the installation of the basic software package.

yum install git cmake gcc gcc-c++ vim -y

Readers can add the required software by themselves. Since it is a template machine, it is enough to install commonly used software.
At this point, the installation of the template machine is over.

Fourth, the use of template machine

This paragraph will show how the template machine can be put into use by cloning

clone virtual machine

clone method
For the cloning step, just keep clicking the next step and keep the default. You need to consider the cloning method above as shown in the figure according to your own situation, and it has no effect. The most important part of virtual machine cloning is the modification of the ip address and the modification of the hostname. These two steps will be written in subsequent articles, and readers do not need to worry.

One, Q&A

This article belongs to the first article of this column. In order to ensure the integrity of the column, it roughly talks about how to operate the virtual machine. It is no stranger to students who have known it before, but there are still some problems for Xiaobai. If you encounter any problems, you can send me a private message or ask Du Niang. OK, the most important tutorials in this series are k8s technology-oriented tutorials, and you can search for related basic tutorials by yourself.

Guess you like

Origin blog.csdn.net/m0_46197553/article/details/128269860