首页 > 系统相关 >安装centos79的笔记

安装centos79的笔记

时间:2023-04-23 15:48:20浏览次数:51  
标签:centos mirrors com 笔记 centos79 ce aliyun docker 安装

一、安装

下载centos79最终全集版的iso文件:

https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/isos/x86_64/

一般建议下载那个CentOS-7-x86_64-Everything-2207-02.iso,一代经典的centos7,出到的最后一个版本。

这里进行的是在vmware workstation 16.1中安装,2C4G40G的简朴配置。

文件系统配置建议/boot 512MB占sda1,LVM管理 / 和 swap,创建sda2作为物理卷占剩余39.5GB硬盘,vg00作为唯一卷组,swap给2GB,/ 给10GB;

时区选择中国上海;

关闭没有任何用的KDump;

软件可以使用最小化software的方式安装,安装之后 / 下约1.3GB,一般不需要GUI;

网络和主机名可以先不配置,安装好了以后再配。

二、配置

1 网卡配置

vi /etc/sysconfig/network-scripts/ifcfg-ens32

如果是NAT模式+DHCP,则按照下面配置网卡

TYPE=Ethernet
DEVICE=ens32
NAME=ens32
ONBOOT=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
BOOTPROTO=DHCP

如果是NAT模式+指定IP,则按照下面配置网卡

TYPE=Ethernet
DEVICE=ens32
NAME=ens32
ONBOOT=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
BOOTPROTO=none
IPADDR=192.168.124.11
NETMASK=255.255.255.0
GATEWAY=192.168.124.1

如果是桥接模式,配置的网卡参数与NAT模式一致,但由于桥接模式直接连入路由器,当选择桥接+指定IP时,需要手动配置DNS

vi /etc/resolv.conf,追加

nameserver 114.114.114.114
nameserver 8.8.8.8

配置之后可以通过重启NetworkManager服务,或者重启网卡的方式,让网络设置生效

重启NetworkManager服务:

systemctl restart NetworkManager.service

重启网卡:

nmcli c reload && nmcli c down ens32; nmcli c up ens32

2 主机名配置

按照以下命令设置主机名,动态+永久生效

hostnamectl --static set-hostname myhostname

3 yum源配置

除了网卡和主机名,后面的配置多数需要安装rpm包,这里先配置yum源。

centos自带了一套yum源,都是连接社区的,速度比较慢,这里改为全套阿里的yum源。

cd /etc/yum.repo.d
mkdir bak
mv *.repo bak
touch CentOS-Base.repo

CentOS-Base.repo内容

# 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 - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

常用的docker和k8s的yum源一并加上

docker-ce.repo

#docker-ce.repo
#docker repo from aliyun
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

kubernetes.repo

#kubernetes.repo
#kubernetes el7 from aliyun
[kubernetes]
name=Kubernetes el7
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg

yum源配置好以后,统一清理并缓存yum源内容,缓存成功后,base、extra、updates、docker-ce、kubernetes的yum源就准备完毕了

yum clean all
yum makecache
yum repolist

4 常用软件安装

有了国内的yum源,装什么都很方便,这里将常用的服务器软件和工具安装上

yum install wget chrony iproute net-tools telnet vim samba-client sysstat nmap-ncat tree psmisc lsof iputils

5 防火墙、selinux关闭并打卡时间同步

systemctl stop firewalld
systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config
systemctl start chronyd
systemctl enable chronyd

注意这里关闭selinux,必须重启OS才能生效

6 确认时区正确

timedatectl status
(确认时区为)
Time zone: Asia/Shanghai (CST, +0800)
(确认时钟同步生效)
NTP enabled: yes
NTP synchronized: yes
如果需要修改时区,则:
timedatectl set-timezone Asia/Shanghai

7 设置日志和历史相关配置

给history增加时间戳

vim /etc/profile
追加一行
export HISTTIMEFORMAT="%F %T  "
退出vim并执行
source /etc/profile
这样history命令的结果都会带时间戳

(可选)配置journalctl

手工创建journal目录,存放journal日志:
mkdir /var/log/journal
防止journal在OS重启后被清空,在journal主配置文件中解开Storage,并配置为:
vim /etc/systemd/journald.conf
Storage=persistent
重启journald服务生效
systemctl restart systemd-journald

三、克隆操作系统

安装配置好的centos79可以做为模板,保持关机状态,克隆成其他的OS使用。

克隆后,只需要修改hostname即可,如果需要改变网络配置,也只需要在克隆后的OS中修改网络配置。

标签:centos,mirrors,com,笔记,centos79,ce,aliyun,docker,安装
From: https://www.cnblogs.com/bmwhero/p/17346711.html

相关文章

  • redis linux下安装 redis启动方式 redis典型场景 redis通用命令 数据结构和内部编码 r
    内容回顾#dockerfile命令 RUNCOPYADDENVEXPOSEWORKDIRCMD:可以用新命令覆盖的ENTRYPOINT:不可以被覆盖#容器要运行,必须有个前台进程#dockerfile部署图书管理系统项目 FROMpython:3.8MAINTAINERlqzWORKDIR/soft......
  • Linux环境下安装VSCode
    方式一:将下载的安装包解压后直接进入VSCode/bin/目录,双击目录中的名为code的shell脚本,即可启动VSCode。方式二:1.下载VSCode访问VisualStudioCode官网https://code.visualstudio.com/docs?dv=linux64下载64位code-stable-x64-1658162259.tar.gz安装包。2.解压tar-zxvf c......
  • Vue的学习笔记(下篇)
    一、什么是Vue.js?Vue是一套用于构建用户界面的渐进式框架。与其它大型框架不同的是,Vue被设计为可以自底向上逐层应用。Vue的核心库只关注视图层,不仅易于上手,还便于与第三方库或既有项目整合。另一方面,当与现代化的工具链以及各种支持类库结合使用时,Vue也完全能够为复杂的单页......
  • Vue的学习笔记(中篇)
    一、什么是Vue.js?Vue是一套用于构建用户界面的渐进式框架。与其它大型框架不同的是,Vue被设计为可以自底向上逐层应用。Vue的核心库只关注视图层,不仅易于上手,还便于与第三方库或既有项目整合。另一方面,当与现代化的工具链以及各种支持类库结合使用时,Vue也完全能够为复杂的单页......
  • Centos7下杀毒软件clamav的安装和使用
      ClamAntiVirus(ClamAV)是一个Linux系统上使用的反病毒软件包。主要应用于邮件服务器,采用多线程后台操作,可以自动升级病毒库。ClamAntiVirus(ClamAV)是免费而且开放源代码的防毒软件,软件与病毒码的更新皆由社群免费发布。目前ClamAV主要是使用在由Linux、FreeBSD等Unix-like系统......
  • electron安装,打包成应用程序或者小程序
    在使用 Electron 进行开发之前,需要安装Node.js,可以在终端输入以下命令输出了Node.js和npm的版本信息:node-vnpm-v 没有的话,自行查找并安装。 全局安装:npminstallelectron-g  ,非全局安装:npminstallelectron 如果不能安装,卡住或者不动可以试试淘宝镜......
  • Nginx 入门实战(1)--简介及安装
    本文介绍的Nginx为开源版本Nginx,官网地址为:https://nginx.org/en/,如需了解商业版本,可访问商业官网:https://www.nginx-cn.net/;文中所使用到的软件版本:nginx1.22.1、pcre8.43、opnessl1.1.1s、CentOS 7.9.20091、简介nginx[enginex]是一款Http和反向代理服务器、邮件......
  • 「学习笔记」重修 FHQ-treap
    无旋treap的操作方式使得它天生支持维护序列、可持久化等特性。无旋treap又称分裂合并treap。它仅有两种核心操作,即为分裂与合并。通过这两种操作,在很多情况下可以比旋转treap更方便的实现别的操作。变量与宏定义#definelsch[u][0]#definersch[u][1]intcnt,r......
  • Go语言上手(三) | 青训营笔记
    高质量编程简介及编码规范高质量:各种边界条件考虑完备异常情况处理,稳定性易读易维护编程原则简单性可读性生产力编码规范公共符号始终要注释例外:实现接口的方法不需要注释格式化使用gofmt(官方工具)自动格式化注释代码作用(适合公共符号)代码如......
  • JS学习笔记
    js中有几种数据类型8种\(number\)、\(string\)、\(null\)、\(undefined\)、\(boolean\)、\(Symbol\)、\(object\)、\(BigInt\).ArrayFunction的本质也是Object前5种是基本数据类型number,string,null、undefined、boolean后面三种是引用数据类型Symbol、object、BigInt.......