CentOS7安装配置

发布时间:2024-05-14 点击:136
系统运维
centos7安装配置
本文步骤说明
1.下载centos7 iso镜像
2.使用vmware workstation 创建计算机硬件资源,包括cpu,内存,硬盘,网卡等信息 此配置本文省略
3.使用下在好的iso镜像安装centos7 操作系统,并对其做安装前的配置
4.安装后的一些常用配置,包括yum配置,网卡配置等
5.创建镜像,方便以后快速还原到一个相对纯净的操作系统,克隆操作系统使用
1.下载centos7 操作系统镜像
这里推荐几个国内镜像源下载,速度要比官网的快,本文推荐的都是最小安装版minimal。原因是占用空间小600m左右,系统干净dvd版要4g左右。
阿里云镜像源
华为云镜像源
清华大学镜像源
其他国内镜像源还有很多,网易镜像源等。
2.使用vmware workstation创建虚拟机省略,本文标示下我的配置
之后便可开启虚拟机,安装操作系统
3开始安装配置虚拟机
选择install centos7
选择操作系统语言
配置操作系统时区,硬盘分区等
本文并未对磁盘定制化配置,而是采用的系统默认的lvm逻辑卷做默认设置
开始安装centos7 操作系统,并配置root用户密码
至此,操作系统安装成功
4.安装后,对系统网卡,yum源,selinux,防火墙配置
网卡配置
修改网卡配置文件
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33type=ethernetproxy_method=nonebrowser_only=nobootproto=none # 修改dhcp为none或者static都可以defroute=yesipv4_failure_fatal=noipv6init=yesipv6_autoconf=yesipv6_defroute=yesipv6_failure_fatal=noipv6_addr_gen_mode=stable-privacyname=eth0 # 此处可不做修改,本人习惯性修改 网卡名称uuid=219ac969-2c0b-4571-b8c8-f2bf7fe1e162device=eth0 # 此处可不做修改,本人习惯性修改 设备名称onboot=yes # 此配置为开机是否自动启动网卡,yes为开机自动启动ipaddr=11.1.1.31 # 配置静态ipprefix=24 # 子网掩码为24位gateway=11.1.1.2 # 默认网关dns1=114.114.114.114 # dns域名解析 dns1 阿拉伯数字1不可少ipv6_privacy=no# :wp保存退出如果没有修改name和device名称为eth0的话,wq保存退出后,重启网卡就可以上网了
# 重启网卡命令[root@localhost ~]# systemctl restart network如果修改了name和device名称为eth0的话,还需如下配置
# 1.修改网卡配置文件名称[root@localhost ~]# cd /etc/sysconfig/network-scripts/[root@localhost ~]# mv ifcfg-ens33 ifcfg-eth0# 2.修改grub文件参数[root@localhost ~]# vi /etc/sysconfig/grub # net.ifnames=0 biosdevname=0 即可# 我这里用不到ipv6,所以一并禁用掉了 ipv6.disable=1grub_timeout=5grub_distributor=$(sed \\\'s, release .*$,,g\\\' /etc/system-release)grub_default=savedgrub_disable_submenu=truegrub_terminal_output=consolegrub_cmdline_linux=crashkernel=auto net.ifnames=0 biosdevname=0 ipv6.disable=1 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quietgrub_disable_recovery=true# :wq保存退出# 3.是更改后的grub文件重启后生效[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg# 4.重启操作系统[root@localhost ~]# reboot重启后我们就可以用xshell或者mobaxterm这样的windows操作系统连接shell工具操作centos操作系统了
selinux配置
[root@localhost ~]# vi /etc/sysconfig/selinux# 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 # 修改enforcing为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:wq # 保存退出关闭防火墙,禁止开机自动启动
[root@localhost ~]# systemctl disable firewalld[root@localhost ~]# systemctl stop firewalld修改主机名
[root@localhost ~]# hostnamectl set-hostname node3.sumailcode.cn[root@localhost ~]# rebootyum 源配置
本文采用阿里云yum源
[root@node3 ~]# mv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.backup[root@node3 ~]# curl -o /etc/yum.repos.d/centos-base.repo http://mirrors.aliyun.com/repo/centos-7.repo[root@node3 ~]# yum clean all && yum makecache fast[root@node3 ~]# yum update -y # 更新操作系统[root@node3 ~]# yum -y install ntpdate git vim net-tools lrzsz # 常用软件安装安装epel源,epel分centos官方提供的包仓库,epel中包含一些优秀的开源软件,包括nginx等
[root@node3 ~]# wget -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo安装docker源,方便日后我们使用docker安装软件
# step 1: 安装必要的一些系统工具[root@node3 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2# step 2: 添加软件源信息[root@node3 ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo# step 3: 更新并安装docker-ce[root@node3 ~]# yum makecache fast[root@node3 ~]# yum -y install docker-ce# step 4: 开启docker服务[root@node3 ~]# systemclt start

各国域名后缀详细介绍 国外域名转国内流程
山东华为服务器云主机价格查询
什么是域名,个人域名注册步骤
云服务器ecs选择
seo优化的前期准备工作怎么做?seo都需要优化什么
购买域名哪个网站好 境外购买域名是否需要备案
虚拟主机商哪个好
阿里云后端租什么服务器