安装阿里云的base源与EPEL源 仓库和常用命令
- rm -f /etc/yum.repos.d/*.repo
- curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
- yum clean all
- yum repolist
安装腾讯云base源与EPEL源 仓库和常用命令
- rm -f /etc/yum.repos.d/*.repo
- curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
- curl -o /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
- yum clean all
- yum repolist
安装centos常用软件包
yum install -y net-tools vim lrzsz tree screen lsof tcpdump bash-completion bash-completion-extras wget ntp
systemctl disable NetworkManager && systemctl stop NetworkManager
systemctl disable firewalld && systemctl stop firewalld
关闭并确认 SELinux 处于关闭状态
- sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config && grep 'SELINUX=disabled' /etc/selinux/config
- setenforce 0
- getenforce
- sed -i 's%#UseDNS yes%UseDNS no%g' /etc/ssh/sshd_config
- systemctl restart sshd
安装chrony
yum -y install chrony ntp
编辑chrony配置文件
- vim /etc/chrony.conf
- server ntp1.aliyun.com iburst
启动chrony服务
- systemctl enable chronyd.service
- systemctl start chronyd.service
验证ntp服务客户端是否同步时间正常
ntpstat
检查当前 root 账号下的 max open files 值
ulimit -n
如果为默认的 1024,建议通过修改配置文件调整为 102400 或更大。
- cat >>/etc/security/limits.conf<< EOF
- root soft nofile 102400
- root hard nofile 102400
- EOF
修改后,重新使用 root 登录检查是否生效
ulimit -n
在线安装时,依赖 pip,需要配置可用的 pip 源
- mkdir -p ~/.pip/
- cat > ~/.pip/pip.conf<<EOF
-
- [global]
- index-url = https://mirrors.cloud.tencent.com/pypi/simple
- trusted-host = mirrors.cloud.tencent.com
- EOF
- mkdir -p ~/.pip/
- cat > ~/.pip/pip.conf<<EOF
- [global]
- index-url = https://pypi.tuna.tsinghua.edu.cn/simple
-
- [install]
- trusted-host=pypi.tuna.tsinghua.edu.cn
- EOF
- hostname linux-node-moban
- echo "linux-node-moban" >/etc/hostname
需要修改locale.conf配置文件
- # vim /etc/locale.conf
- LANG="en_US.UTF-8"
- # source /etc/locale.conf
- > /var/log/messages
- > /var/log/secure
- history -c
- > /root/.bash_history
- poweroff
- mkfs.xfs -f /dev/sdb
- mkdir -p /data
- mount /dev/sdb /data/
- echo "/dev/sdb /data xfs defaults 0 0" >>/etc/fstab ; cat /etc/fstab |grep data
- sudo mkdir -p /etc/docker
- sudo tee /etc/docker/daemon.json <<-'EOF'
- {
- "registry-mirrors": ["https://1v0q5mvy.mirror.aliyuncs.com"]
- }
- EOF
- sudo systemctl daemon-reload
- sudo systemctl restart docker
- sudo systemctl status docker
编辑网卡信息
- [root@linux-node2~]# cd /etc/sysconfig/network-scripts/ #进入网卡目录
- [root@linux-node2network-scripts]# mv ifcfg-eno16777728 ifcfg-eth0 #重命名网卡名称
- [root@linux-node2 network-scripts]# cat ifcfg-eth0 #编辑网卡信息
- TYPE=Ethernet
- BOOTPROTO=static
- DEFROUTE=yes
- PEERDNS=yes
- PEERROUTES=yes
- IPV4_FAILURE_FATAL=no
- NAME=eth0 #name修改为eth0
- ONBOOT=yes
- IPADDR=192.168.56.12
- NETMASK=255.255.255.0
- GATEWAY=192.168.56.2
- DNS1=192.168.56.2
重启网络
systemctl restart network