Oct 9, 2021 No Comments Centos7系统初始化 1.开始配置yum源(这里使用阿里云) ``` mv /etc/yum.repos.d/* /tmp 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 makecache ``` 2.下载常用必备软件 ``` yum install -y libcurl openssl lrzsz httpd gcc cpp binutils glibc-kernheaders glibc-common glibc-devel make gcc-c++ automake autoconf libtool make zlib-devel openssl-devel tree nmap sysstat dos2unix telnet bash-completion bash-completion-extras vim nc lsof net-tools rsync ntpdate open-sshclients tree screen nload sysstat wget ``` 3.关闭防火墙 ``` systemctl stop firewalld systemctl disable firewalld ``` 4.优化SElinux ``` setenforce 0 sed -i 's#^SELINUX=.*#SELINUX=disabled#g' /etc/sysconfig/selinux ``` 5.关闭NetworkManager ``` systemctl stop NetworkManager systemctl disable NetworkManager ``` 6.同步阿里云系统时间 ``` echo '#Timing synchronization time' >>/var/spool/cron/root echo '*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com &>/dev/null' >>/var/spool/cron/root ``` 7.加大文件描述符 ``` echo '* - nofile 65535 ' >>/etc/security/limits.conf ``` 8.命令行优化 ``` cat>>/etc/profile.d/color.sh<<-EOF alias ll='ls -l --color=auto --time-style=long-iso' PS1="\[\e[37;40m\][\[\e[32;1m\]\u\[\e[37;40m\]@\h \[\e[36;40m\]\w\[\e[0m\]]\[\e[32;1m\]\\# \[\e[0m\]" export HISTTIMEFORMAT='%F-%T ' EOF source /etc/profile ``` 9.优化内核参数 ``` [ -f /etc/sysctl.conf.bak ] || cp /etc/sysctl.conf{,.bak} cat >/etc/sysctl.conf<<-EOF vm.swappiness = 0 net.ipv4.neigh.default.gc_stale_time=120 net.ipv4.conf.all.rp_filter=0 net.ipv4.conf.default.arp_announce = 2 net.ipv4.conf.lo.arp_announce=2 net.ipv4.conf.all.arp_announce=2 net.ipv4.tcp_syncookies = 1 kernel.sysrq=1 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_rmem = 4096 87380 4194304 net.ipv4.tcp_wmem = 4096 16384 4194304 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 262144 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 30 net.ipv4.ip_local_port_range = 10000 65000 EOF sysctl -p ``` 10.设置主机名 ``` hostname <主机名> #临时修改 hostnamectl set-hostname <主机名> #永久修改 ``` 最后更新于 2023-02-06 10:01:17 并被添加「」标签,已有 2503 位童鞋阅读过。 本站使用「署名 4.0 国际」创作共享协议,可自由转载、引用,但需署名作者且注明文章出处
此处评论已关闭