安装Centos镜像
我这里安装的版本是:CentOS-7-x86_64-Minimal-2003.iso
下载地址:mirrors.aliyun.com/centos-vaul…
安装虚拟机步骤这里就不再赘述了。
Linux初始配置
- 查看centos版本
cat /etc/centos-release
- 配置阿里云yum源
#先安装wget
yum install -y wget
#备份默认的yum
mv /etc/yum.repos.d /etc/yum.repos.d.backup
#设置新的yum目录
mkdir -p /etc/yum.repos.d
#下载阿里yum配置到该目录中,选择对应版本
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#更新epel源为阿里云epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#重建缓存
yum clean all
yum makecache
#看下yum仓库有多少包
yum repolist
- 升级系统内核
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install -y kernel-lt
grep initrd16 /boot/grub2/grub.cfg
grub2-set-default 0
升级完成后重启系统
- 查看系统情况
# 查看系统内核
uname -r
#查看cpu
lscpu
#查看内存
freee -h
#查看硬盘信息
fdisk -l
- 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
- 关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
setenforce 0
- 网桥过滤
vi /etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
net.ipv4.ip_forward=1
net.ipv4.ip_forward_use_pmtu = 0
生效命令:sysctl --system
- 命令补全
安装bash-completion
yum -y install bash-completion bash-completion-extras
使用bash-completion
source /etc/profile.d/bash_completion.sh
- 上传下载文件
yum -y install lrzsz
1.鼠标拖拽上传文件
2.下载文件
2.1下载一个文件
sz filename
2.2下载多个文件
sz filename1 filename2
2.3下载dir目录下所有文件,不包含dir下的文件夹
sz dir/*
安装Docker
可以参考阿里云官网提供的docker安装教程进行安装:www.aliyun.com/
前置条件
- 安装docker前置条件
yum install -y yum-utils device-mapper-persistent-data lvm2
- 添加源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
- 查看docker版本
yum list docker-ce --showduplicates | sort -r
安装docker
安装最新版:推荐大家安装最新版本
yum -y install docker-ce
安装指定版本
# 语法规则:yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING>
yum install -y docker-ce-19.03.9-3.el7 docker-ce-cli-19.03.9-3.el7
- 开启docker服务
systemctl start docker
查看状态
systemctl status docker
- 安装阿里云镜像加速器
首先打开阿里云网站:cr.console.aliyun.com/cn-hangzhou… 查看你的镜像加速地址
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["你的加速地址,如:https://xxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
- 设置Docker开机启动服务
systemctl enable docker
- 查看docker版本
docker -v
#详细的版本信息
docker version
开启掘金成长之旅!这是我参与「掘金日新计划 · 2 月更文挑战」的第 1 天,点击查看活动详情