• centos的环境配置


    YUM仓库配置

    安装阿里云的base源与EPEL源 仓库和常用命令

    1. rm -f /etc/yum.repos.d/*.repo
    2. curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    3. curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    4. yum clean all
    5. yum repolist

    安装腾讯云base源与EPEL源 仓库和常用命令

    1. rm -f /etc/yum.repos.d/*.repo
    2. curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
    3. curl -o /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
    4. yum clean all
    5. yum repolist

    安装常用软件包

    安装centos常用软件包

    yum install -y net-tools vim lrzsz tree screen lsof tcpdump bash-completion bash-completion-extras wget ntp

    关闭NetworkManager

    systemctl disable NetworkManager && systemctl stop NetworkManager

    关闭防火墙

    systemctl disable firewalld && systemctl stop firewalld

    关闭SELinux

    关闭并确认 SELinux 处于关闭状态

    1. sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config && grep 'SELINUX=disabled' /etc/selinux/config
    2. setenforce 0
    3. getenforce

    配置SSH服务

    1. sed -i 's%#UseDNS yes%UseDNS no%g' /etc/ssh/sshd_config
    2. systemctl restart sshd

    配置NTP服务

    安装chrony

    yum -y install chrony ntp

    编辑chrony配置文件

    1. vim /etc/chrony.conf
    2. server ntp1.aliyun.com iburst

    启动chrony服务

    1. systemctl enable chronyd.service
    2. systemctl start chronyd.service

    验证ntp服务客户端是否同步时间正常

    ntpstat 

    调整文件描述符

    检查当前 root 账号下的 max open files 值

    ulimit -n

    如果为默认的 1024,建议通过修改配置文件调整为 102400 或更大。

    1. cat >>/etc/security/limits.conf<< EOF
    2. root soft nofile 102400
    3. root hard nofile 102400
    4. EOF

    修改后,重新使用 root 登录检查是否生效

    ulimit -n

    PIP国内源

    在线安装时,依赖 pip,需要配置可用的 pip 源

    腾讯源

    1. mkdir -p ~/.pip/
    2. cat > ~/.pip/pip.conf<<EOF
    3. [global]
    4. index-url = https://mirrors.cloud.tencent.com/pypi/simple
    5. trusted-host = mirrors.cloud.tencent.com
    6. EOF

    清华源

    1. mkdir -p ~/.pip/
    2. cat > ~/.pip/pip.conf<<EOF
    3. [global]
    4. index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    5. [install]
    6. trusted-host=pypi.tuna.tsinghua.edu.cn
    7. EOF

    配置主机名称

    1. hostname linux-node-moban
    2. echo "linux-node-moban" >/etc/hostname

    中文乱码问题

    需要修改locale.conf配置文件

    1. # vim /etc/locale.conf
    2. LANG="en_US.UTF-8"
    3. # source /etc/locale.conf

    清理模板虚拟机

    1. > /var/log/messages
    2. > /var/log/secure
    3. history -c
    4. > /root/.bash_history
    5. poweroff

    挂载数据盘

    1. mkfs.xfs -f /dev/sdb
    2. mkdir -p /data
    3. mount /dev/sdb /data/
    4. echo "/dev/sdb /data xfs defaults 0 0" >>/etc/fstab ; cat /etc/fstab |grep data

    docker镜像源配置

    1. sudo mkdir -p /etc/docker
    2. sudo tee /etc/docker/daemon.json <<-'EOF'
    3. {
    4. "registry-mirrors": ["https://1v0q5mvy.mirror.aliyuncs.com"]
    5. }
    6. EOF
    7. sudo systemctl daemon-reload
    8. sudo systemctl restart docker
    9. sudo systemctl status docker

    配置eth网卡

    编辑网卡信息

    1. [root@linux-node2~]# cd /etc/sysconfig/network-scripts/ #进入网卡目录
    2. [root@linux-node2network-scripts]# mv ifcfg-eno16777728 ifcfg-eth0 #重命名网卡名称
    3. [root@linux-node2 network-scripts]# cat ifcfg-eth0 #编辑网卡信息
    4. TYPE=Ethernet
    5. BOOTPROTO=static
    6. DEFROUTE=yes
    7. PEERDNS=yes
    8. PEERROUTES=yes
    9. IPV4_FAILURE_FATAL=no
    10. NAME=eth0 #name修改为eth0
    11. ONBOOT=yes
    12. IPADDR=192.168.56.12
    13. NETMASK=255.255.255.0
    14. GATEWAY=192.168.56.2
    15. DNS1=192.168.56.2

    重启网络

     systemctl restart network

  • 相关阅读:
    PAM从入门到精通(十九)
    【CMake】windows10下入门课程
    Caused by: java.net.UnknownHostException: nacos
    内网穿透的应用-如何搭建Linux站点并结合内网穿透实现公网访问宝塔面板
    matlab中类的分别之handle类和value类——matlab无法修改类属性值的可能原因
    古琴必修律学原理,学古琴路上太重要的密码
    Vue源码学习(五):<templete>渲染第四步,生成虚拟dom并将其转换为真实dom
    Feign源码分析(without spring)
    Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
    MySQL实用安装教程
  • 原文地址:https://blog.csdn.net/qq_63431773/article/details/132725203