首页 > 系统相关 >centos 7配置与调优

centos 7配置与调优

时间:2023-09-20 13:56:39浏览次数:49  
标签:set centos 配置 00m repo etc 调优 yum 033

centos7 配置调优

# 颜色
echo "PS1='\[\033[35m\][\[\033[00m\]\[\033[31m\]\u\[\033[33m\]\[\033[33m\]@\[\033[03m\]\[\033[35m\]\h\[\033[00m\] \[\033[5;32m\]\w\[\033[00m\]\[\033[35m\]]\[\033[00m\]\[\033[5;31m\]\\$\[\033[00m\] '" >> ~/.bashrc && source ~/.bashrc

# 0、centos7 环境配置
# 安装 vim
yum -y install vim wget net-tools

# 行号
echo "set nu" >> /root/.vimrc

# 搜索关键字高亮
sed -i "8calias grep='grep --color'" /root/.bashrc

# 腾讯源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
wget -O /etc/yum.repos.d/CentOS-Epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo

yum clean all
yum makecache

# 1、设置主机名
hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node1
hostnamectl set-hostname k8s-node2

# 2、添加hosts解析
cat >> /etc/hosts << EOF
192.168.1.201 k8s-master
192.168.1.202 k8s-node1
192.168.1.203 k8s-node2
EOF

# 3、同步时间
yum -y install ntp
systemctl enable ntpd --now

# 4、永久关闭seLinux(需重启系统生效)
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

# 5、永久关闭swap(需重启系统生效)
swapoff -a  # 临时关闭
sed -i 's/.*swap.*/#&/g' /etc/fstab # 永久关闭

# 6、升级内核为5.4版本(需重启系统生效)
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-5.el7.elrepo.noarch.rpm

yum --enablerepo=elrepo-kernel install -y kernel-lt

grub2-set-default 0

#这里先重启再继续
reboot

# 7、关闭防火墙、清空iptables规则
systemctl disable firewalld && systemctl stop firewalld

iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X && iptables -P FORWARD ACCEPT && service iptables save

# 8、关闭 NetworkManager
systemctl disable NetworkManager && systemctl stop NetworkManager

# 9、加载IPVS模块
yum -y install ipset ipvsadm

cat > /etc/sysconfig/modules/ipvs.modules <<EOF
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF

modprobe -- nf_conntrack

chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack

# 10、开启br_netfilter、ipv4 路由转发
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo modprobe br_netfilter

# 设置所需的 sysctl 参数,参数在重新启动后保持不变
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

# 应用 sysctl 参数而不重新启动
sudo sysctl --system

# 查看是否生效
lsmod | grep br_netfilter
lsmod | grep overlay

sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables net.ipv4.ip_forward

# 11、内核调优
 cat > /etc/sysctl.d/99-sysctl.conf << 'EOF'
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).

# Controls IP packet forwarding

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1

# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536

# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536

net.ipv4.conf.all.promote_secondaries = 1
net.ipv4.conf.default.promote_secondaries = 1
net.ipv6.neigh.default.gc_thresh3 = 4096

kernel.sysrq = 1
net.ipv6.conf.all.disable_ipv6=0
net.ipv6.conf.default.disable_ipv6=0
net.ipv6.conf.lo.disable_ipv6=0
kernel.numa_balancing = 0
kernel.shmmax = 68719476736
kernel.printk = 5
net.core.rps_sock_flow_entries=8192
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_local_reserved_ports=60001,60002
net.core.rmem_max=16777216
fs.inotify.max_user_watches=524288
kernel.core_pattern=core
net.core.dev_weight_tx_bias=1
net.ipv4.tcp_max_orphans=32768
kernel.pid_max=4194304
kernel.softlockup_panic=1
fs.file-max=3355443
net.core.bpf_jit_harden=1
net.ipv4.tcp_max_tw_buckets=32768
fs.inotify.max_user_instances=8192
net.core.bpf_jit_kallsyms=1
vm.max_map_count=262144
kernel.threads-max=262144
net.core.bpf_jit_enable=1
net.ipv4.tcp_keepalive_time=600
net.ipv4.tcp_wmem=4096 12582912    16777216
net.core.wmem_max=16777216
net.ipv4.neigh.default.gc_thresh1=2048
net.core.somaxconn=32768
net.ipv4.neigh.default.gc_thresh3=8192
net.ipv4.ip_forward=1
net.ipv4.neigh.default.gc_thresh2=4096
net.ipv4.tcp_max_syn_backlog=8096
net.bridge.bridge-nf-call-iptables=1
net.ipv4.tcp_rmem=4096  12582912        16777216
EOF

# 应用 sysctl 参数而不重新启动
sudo sysctl --system

标签:set,centos,配置,00m,repo,etc,调优,yum,033
From: https://www.cnblogs.com/yhtweirdo/p/17717141.html

相关文章

  • H3C交换机配置学习
    H3C交换机配置学习 设备型号:H3C3600V2工业交换机(配置同厂商交换机类似)所需设备:一台笔记本电脑、一条配置线(console线)、终端登录软件(SecureCRT、XShell…) 配置说明:采用串口通信的方式进行配置主要步骤:1、安装终端登录软件在笔记本(配置)电脑上;2、物理连接:用console(配置......
  • CentOS 7.9编译安装Python-3.10.13
    一、查看CentOS版本、系统默认gcc版本、Python版本和pip版本:#cat/etc/redhat-release#gcc--version#python-V#pip-V二、部署Python-3.10.13:1、下载Python-3.10.13.tar.xz,Python官网:https://www.python.org/2、安装编译依赖软件包及包组:#yum-ygroupinstall"Development......
  • quartz 时间配置规则
    格式:[秒][分][小时][日][月][周][年] 序号说明 是否必填 允许填写的值允许的通配符 1 秒 是 0-59  ,-*/ 2 分 是 0-59 ,-*/ 3小时 是 0-23 ,-*/ 4 日 是 1-31 ,-*?/LW 5 月 是 1-12orJAN-DEC ,-*/ 6 周 是 1-7o......
  • 记录 小程序调用前置摄像头的数据获取及简单配置
    业务是需要调取前置摄像头之后获取图片上代码wx.chooseMedia({count:1,//只允许上传一张照片 mediaType:['image'],//文件类型sizeType:['original','compressed'],//是否压缩所选文件,original原始compressed压缩......
  • 网关配置类,拦截和解析token
      @Component@Slf4jpublicclassAuthorizeFilterimplementsGlobalFilter,Ordered{@OverridepublicMono<Void>filter(ServerWebExchangeexchange,GatewayFilterChainchain){ServerHttpRequestrequest=exchange.getRequest();......
  • vmware虚拟机中的centos设置固定ip
    1、使用桥接模式,确保虚拟机目前可联网因为我们要使用目前的配置,使得目前ip为固定ip,确保ip无冲突 2、查看目前ip配置ipaddrshow #查看ip,找到虚拟机目前联网的网络接口,我的是ens33ipaddrshowens33 #查看,确定inet172.16.200.102/20  ip和子网掩码iproute......
  • SYZOJ 题目 Subtask 配置工具
    在程序运行后,需要输入测试数据文件所在的绝对目录,要求测试数据文件名称的格式形如"1-xxxxxxx",即存在至少一个分隔符-,且在分隔符前是区分Subtask的字符串,相同的内容会按相同Subtask对待,分隔符后是任意字符串,可以包含其他分隔符。Code#include<iostream>#include<fstrea......
  • nodejs的安装配置
    node.js的介绍Node.js是一个基于ChromeJavaScript运行时建立的平台,用于方便地搭建响应速度快、易于扩展的网络应用。Node.js使用事件驱动,非阻塞I/O模型而得以轻量和高效,非常适合在分布式设备上运行的数据密集型的实时应用。V8引擎执行Javascript的速度非常快,性能非常好。N......
  • M2芯片MAC安装CentOS7.9虚拟机
    安装CentOS7.91、官网下载的ARM镜像均不可用,卡在installcentos7界面。需找寻下载适合M1/2MAC的ARM镜像才行。例如从官网下载的CentOS-7-aarch64-Minimal-2009.iso安装时一直卡在这个界面。镜像下载地址:CentOS-7-aarch64-08191738.mpghttps://www.aliyundrive.com/s/nu972LGBLF......
  • 我的neovim配置
    init.vim"Vimwithallenhancements"文件管理器,我想试一下rangersyntaxenablesyntaxonletmapleader=""setnumber "显示行号setrelativenumber "显示相对行号sethlsearch "搜索结果高亮setautoindent "自动缩进setsmartindent ......