目录

前言

一、VMware安装CentOS7系统

二、基础环境配置

登录系统设置静态网络

ssh工具连接

修改主机名

关闭防火墙、selinux

安装常用软件包

配置国内YUM源及拓展源

快照


前言

CentOS(Community Enterprise Operating System,中文意思是社区企业操作系统)是Linux发行版之一,它是来自于Red Hat Enterprise Linux依照开放源代码规定释出的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定性的服务器以CentOS替代商业版的Red Hat Enterprise Linux使用。两者的不同,在于CentOS完全开源

CentOS官网:The CentOS Project

Centos yarn安装及环境配置 centos安装基本环境怎么选择_centos

https://www.centos.org/

一、VMware安装CentOS7系统

使用默认配置安装

Centos yarn安装及环境配置 centos安装基本环境怎么选择_linux_02

选择安装

Centos yarn安装及环境配置 centos安装基本环境怎么选择_centos_03

默认英文,可以选择中文


时区设置为上海


默认最小化安装,这里我们也使用最小化安装

Centos yarn安装及环境配置 centos安装基本环境怎么选择_centos_04

默认自动分区,也可以手动配置,这里选择默认

Centos yarn安装及环境配置 centos安装基本环境怎么选择_linux_05

设置完后开始安装

Centos yarn安装及环境配置 centos安装基本环境怎么选择_运维_06

 

设置root用户密码,可以不用创建普通用户

Centos yarn安装及环境配置 centos安装基本环境怎么选择_运维_07

设置密码后点两次完成退出

Centos yarn安装及环境配置 centos安装基本环境怎么选择_centos_08

等待安装完成

Centos yarn安装及环境配置 centos安装基本环境怎么选择_Centos yarn安装及环境配置_09

完成后重启

Centos yarn安装及环境配置 centos安装基本环境怎么选择_centos_10

二、基础环境配置

登录系统设置静态网络

Centos yarn安装及环境配置 centos安装基本环境怎么选择_运维_11

Centos yarn安装及环境配置 centos安装基本环境怎么选择_CentOS_12

测试能否ping通外网

 

Centos yarn安装及环境配置 centos安装基本环境怎么选择_运维_13

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 
[root@localhost ~]# systemctl restart network
[root@localhost ~]# ping -c www.baidu.com
PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data.
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=128 time=17.4 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=128 time=17.2 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=128 time=16.8 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=4 ttl=128 time=16.8 ms

--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3007ms
rtt min/avg/max/mdev = 16.879/17.106/17.409/0.281 ms


ssh工具连接

新建会话,设置名称添加主机ip

Centos yarn安装及环境配置 centos安装基本环境怎么选择_Centos yarn安装及环境配置_14

输入用户名密码登录

Centos yarn安装及环境配置 centos安装基本环境怎么选择_CentOS_15

Centos yarn安装及环境配置 centos安装基本环境怎么选择_Centos yarn安装及环境配置_16

双击连接新建的会话

Centos yarn安装及环境配置 centos安装基本环境怎么选择_CentOS_17

修改主机名

使用hostnamectl set-hostname [主机名] 命令修改,也可以编辑/etc/hostname文件修改

修改后使用bash或者重新连接会话就会显示主机名已经更改

[root@localhost ~]# hostnamectl set-hostname centos
[root@localhost ~]# vi /etc/hostname 
[root@localhost ~]# bash
[root@centos ~]# 

Centos yarn安装及环境配置 centos安装基本环境怎么选择_Centos yarn安装及环境配置_18

关闭防火墙、selinux

永久关闭防火墙和selinux,setenforce 0 命令可以临时关闭

[root@centos ~]# systemctl stop firewalld
[root@centos ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@centos ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Centos yarn安装及环境配置 centos安装基本环境怎么选择_Centos yarn安装及环境配置_19

Centos yarn安装及环境配置 centos安装基本环境怎么选择_运维_20

安装常用软件包

wget:下载软件包工具

vim:编辑器

net-tools:含有netstat、ifconfig、route、arp等命令

bash-completion:tab补全功能工具包

tree:tree以树形结构显示文件和目录

htop:系统进程相关信息查看工具

lrzsz:包含上传(rz)下载(sz)文件工具

 [root@centos ~]# yum install -y wget vim net-tools bash-completion tree htop lrzsz

Centos yarn安装及环境配置 centos安装基本环境怎么选择_linux_21

配置国内YUM源及拓展源

[root@centos ~]# cd /etc/yum.repos.d/
[root@centos yum.repos.d]# mkdir bak
[root@centos yum.repos.d]# mv *.repo bak/

新建文件夹将原有repo文件备份

Centos yarn安装及环境配置 centos安装基本环境怎么选择_centos_22

浏览器搜索阿里镜像站,找到CentOS和epel

Centos yarn安装及环境配置 centos安装基本环境怎么选择_centos_23

Centos yarn安装及环境配置 centos安装基本环境怎么选择_centos_24

 下滑找到CentOS-7.repo拉取命令复制运行

Centos yarn安装及环境配置 centos安装基本环境怎么选择_运维_25

 下滑找到epel-7.repo拉取命令复制运行

Centos yarn安装及环境配置 centos安装基本环境怎么选择_运维_26

[root@centos yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@centos yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

Centos yarn安装及环境配置 centos安装基本环境怎么选择_运维_27

测试YUM源是否可用并建立缓存

[root@centos yum.repos.d]# yum repolist

[root@centos yum.repos.d]# yum makecache

Centos yarn安装及环境配置 centos安装基本环境怎么选择_linux_28

快照

建议对配置好基础环境的虚拟机做快照,方便后续使用干净的机器

Centos yarn安装及环境配置 centos安装基本环境怎么选择_CentOS_29