Linux-02 establishes a linux experimental environment

Download environment

To learn the linux environment, you need to install the mirror

https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso?spm=a2c6h.25603864.0.0.62e76aean3fIHp

Need to download and download the mirror with the .iso suffix

CentOS installation type selection

Desktop: The basic desktop system, including commonly used desktop software, such as document viewing tools.

Minimal Desktop: A basic desktop system with less software included.

Minimal: The basic system, without any optional packages.

Basic Server : Platform support for the installed base system, excluding the desktop.

Database Server: Basic system platform, plus MySQL and PostgreSQL databases, no desktop.

Web Server: The basic system platform, plus PHP, Web server, and MySQL and PostgreSQL database clients, no desktop.

Virtual Host: Basic system plus virtual platform.

Software Development Workstation: Contains many software packages, basic systems, virtualization platforms, desktop environments, and development tools.

The installation of Linux is basically used to build a server, so basically choose Basic Server.

The difference between the download versions of Centos

DVD ISO: Standard installation disk, generally you can download this (about 4G)

Everything ISO: Supplement the software of the full version installation disk and integrate all the software (about 8G)
Minimal ISO: The smallest installation disk, only the necessary software, and the least self-contained software (about 1G)

Imprint

64-LiveDVD.iso trial version

64-bin-DVD1.iso real installation package

64-minimal.iso Minimal installation package

Install the virtual machine

First of all, you need to install virtual machine software on your own computer, I use VMware Workstation Pro

Create a new virtual machine

File > New Virtual Machine

Choose the mirror we downloaded

Define the name and select the location

Configure resources

CPU configuration is 1

The memory configuration is 1G

Here, choose 1CPU1G memory, which can be expanded as needed

Configure the network

Select network as NAT

Here we need to explain the three networks of virtual machines

  • Bridged (Bridged Mode)
  • NAT (Address Translation Mode)
  • Host-Only (host mode only)

To understand these three networks, we need to open Edit > Virtual Machine Network Editor

There are three network cards here, VMnet0, VMnet1, VMnet8

Here the three network cards correspond to the three modes

  • Bridge mode: here is the network used by your physical machine, here is the request address through your connection to wifi or physical network card, which is in the same network segment as your PC network card, but please note that this requires wifi and switch support, if It is found that this function cannot be used to communicate friendly with the network administrator.

  • Host mode: This network has a feature that it cannot connect to external networks. The reason is that this network cannot be configured with a gateway, and can only communicate with hosts in host mode through Layer 2, and audit some virtual machines that are inconvenient to expose to external networks.

  • Nat mode: This is the mode we often use. We can see that the subnet address is 192.168.47.0, the mask is 255.255.255.0, and the gateway configuration is 192.168.47.2. In fact, there are two hidden conditions. Our host IP is 192.168.47.1, DNS server is 192.168.47.2

To select Nat mode, we only need to configure the virtual machine in the middle of the 192.168.47.0-254 network, and then configure the gateway to 192.168.47.2 to access the external network normally.

Disk configuration

Virtual machine configuration

Choose a language

Language To avoid coding problems, choose English

Select the running version

Hard disk partition

For the sake of simplicity of configuration, no partitioning is performed here.

Partitioning scheme

general method

/boot  Boot partition 200 M
swap  swap partition memory 1.5 times (memory less than 8 G)  greater than 8 G give 8 G
/   How much is left in the root partition?

Data is very important

/boot  Boot partition 200 M
swap  swap partition memory 1.5 times (memory less than 8 G)  greater than 8 G give 8 G
/   50-200
/data  how much is left

Not sure if the data is important

/boot  Boot partition 200 M
swap  swap partition memory 1.5 times (memory less than 8 G)  greater than 8 G give 8 G
/   50 -200
 The rest of the space is not allocated

Configure root password

Click to restart

virtual machine initialization

In order to avoid some repetitive operations, various configurations are required. The following configuration is my habit, and you can learn from it.

Configure fixed IP

The vi editor is used here, you should not be used to it, here is a brief introduction, vim has two modes for our main operations, the default mode and the editing mode

Use i to enter edit mode from default mode

Use esc to exit the default mode from edit mode

Use in default mode

:q  #quit
:q! #force quit
:wq #save and exit
:wq!#Force save and exit
~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.110.191
NETMASK=255.255.255.0
GATEWAY=192.168.110.2
DNS1=192.168.110.2
~]#systemctl restart network

Due to the configured fixed ip, the following operations are performed in the shell connection tool

Modify time zone

[root@localhost ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@localhost ~]# hwclock -w        
[root@localhost ~]# timedatectl status
      Local time: Fri 2022-09-09 06:28:15 CST
  Universal time: Thu 2022-09-08 22:28:15 UTC
        RTC time: Thu 2022-09-08 22:28:15
       Time zone: Asia/Hong-Kong (CST, +0800)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

Modify hostname

[root@localhost ~]# hostnamectl set-hostname Template-host
[root@localhost ~]# bash
[root@template-host ~]# 

Configure domestic yum source

[root@template-host ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@template-host ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0   7786      0 --:--:-- --:--:-- --:--:--  7787
yum makecache
 Non-Alibaba Cloud ECS user will appear Couldn't resolve host 'mirrors.cloud.aliyuncs.com' information, does not affect use. Users can also modify the relevant configuration by themselves: 
[root@template-host ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

turn off firewall

[root@template-host ~]# systemctl stop firewalld.service && systemctl disable firewalld.service && iptables -F && setenforce 0
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@template-host ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

Install basic software

[root@template-host ~]#yum -y install gcc gcc-c++ wget vim lrzsz net-tools curl lsof unzip tree bash-completion

shutdown

The experimental machine needed later needs to be cloned from this machine, and we do not use this machine directly, so that our experimental machine is produced.

[root@template-host ~]# shutdown now

Tags: Linux CentOS Vmware

Posted by Kunax on Fri, 09 Sep 2022 05:37:07 +0930