发布时间:2026/8/17 15:09:57
Centos基础配置 centos7基础 含 yum 配置 时区配置 ssh配置 - openstack基础镜像-手工配置时间 linux基础 含cp显示进度 linux下载站等 # 先换成国内源 这里使用的aliyun的 换国内源 24年更新 http的163已经启用了cd /etc/yum.repos.d/ mkdir test mv *.repo test # wget http://mirrors.163.com/.help/CentOS7-Base-163.repo # 使用163国内源快一些 # 阿里源 curl -s -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo curl -s -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo yum -y install telnet # 阿里 epel wget -O /etc/yum.repos.d/epel.repo \ http://mirrors.aliyun.com/repo/epel-7.repo# 不用下载的 cat 命令cat /etc/yum.repos.d/CentOS-Base.repo EOF # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist does not work for you, as a fall back you can try the # remarked out baseurl line instead. # # [base] nameCentOS-$releasever - Base - mirrors.aliyun.com baseurlhttp://mirrors.aliyun.com/centos/$releasever/os/$basearch/ gpgcheck1 gpgkeyhttp://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] nameCentOS-$releasever - Updates - mirrors.aliyun.com baseurlhttp://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ gpgcheck1 gpgkeyhttp://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] nameCentOS-$releasever - Extras - mirrors.aliyun.com baseurlhttp://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ gpgcheck1 gpgkeyhttp://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] nameCentOS-$releasever - Plus - mirrors.aliyun.com baseurlhttp://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ gpgcheck1 enabled0 gpgkeyhttp://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 EOFcat /etc/yum.repos.d/epel.repo EOF [epel] nameExtra Packages for Enterprise Linux 7 - $basearch baseurlhttp://mirrors.aliyun.com/epel/7/$basearch failovermethodpriority enabled1 gpgcheck0 gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] nameExtra Packages for Enterprise Linux 7 - $basearch - Debug baseurlhttp://mirrors.aliyun.com/epel/7/$basearch/debug failovermethodpriority enabled0 gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck0 [epel-source] nameExtra Packages for Enterprise Linux 7 - $basearch - Source baseurlhttp://mirrors.aliyun.com/epel/7/SRPMS failovermethodpriority enabled0 gpgkeyfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck0 EOF# K8S 容器常用优化# 1.1 关闭swap分区 # 1.2 sysctl 修改内核参数 # 1.3 开启ipvs # 1.4 配置主机名 关闭防火墙等 systemctl stop firewalld systemctl disable firewalld sed -i s/^SELINUX.*/SELINUXdisabled/ /etc/selinux/config setenforce 0 swapoff -a sed -i / swap / s/^\(.*\)$/#\1/g /etc/fstab timedatectl set-timezone Asia/Shanghai yum install ntpdate -y ntpdate pool.ntp.org cat /etc/sysctl.d/k8s.conf EOF net.bridge.bridge-nf-call-ip6tables 1 net.bridge.bridge-nf-call-iptables 1 EOF# 临时关闭提示音rmmod pcspkr# 常用linux下载网站推荐Linux系统下载网 - 帮技术人员找到合适的系统# ls -l显示具体时间ls -l --time-stylelong-iso# 复制文件显示进度原文如何优雅地给cp命令添加进度条_cp命令显示进度_一只晨兴夜不得寐的运维人的博客-CSDN博客# -a 参数表示归档复制-infoprogress2 使用进度条 并实时更新 # source_dir/和dest_dir/分别表示源目录和目标目录。 rsync -a --infoprogress2 source_dir/ dest_dir/# 如果能安装pv工具的话 直接用 cp也可以显示# -r 表示递归复制 source_dir/和dest_dir/分别表示源目录和目标目录。 cp -r source_dir/ dest_dir/ | pv -lep -s $(du -sb source_dir | awk {print $1})# 原始centos部署之后 常规初始化配置timedatectl set-timezone Asia/Shanghai setenforce 0 sed -i s/SELINUXenforcing/SELINUXdisabled/g /etc/selinux/config # 关闭selinux# 常用开发工具 python3 gityum -y install git #wget http://mirrors.163.com/.help/CentOS7-Base-163.repo # 使用163 yum -y install epel-release yum install -y python3 python3-devel which pip3 pip3 install --upgrade pip pip3 install requests# mysqlwget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm yum -y install mysql57-community-release-el7-10.noarch.rpm # yum -y install mysql-community-server # 这步可能会花些时间安装完成后就会覆盖掉之前的mariadb。 sed -i s/gpgcheck1/gpgcheck0/g /etc/yum.repos.d/mysql-community.repo sed -i s/gpgcheck1/gpgcheck0/g /etc/yum.repos.d/mysql-community-source.repo yum -y install mysql-community-server # 这步可能会花些时间安装完成后就会覆盖掉之前的mariadb。 # 启动mysql 查看\修改密码 systemctl start mysqld.service grep password /var/log/mysqld.log alter user rootlocalhost identified by cy7m0ypu8CpLFperzI45;# 常用 运维工具yum install gcc -y yum install pcre pcre-devel -y yum install zlib zlib-devel -y yum install openssl openssl-devel -y yum -y install gcc gcc-c autoconf automake make yum -y install unzip zip #安装常用插件 yum install -y bash-completion # base-completion.noarch补全 yum -y install net-tools lrzsz wget tree screen lsof tcpdump vim bash-completion telnet sysstat yum install -y bind-utils yum -y install wget yum -y install vim net-tools lrzsz #安装常用插件 yum install -y bash-completion # base-completion.noarch补全 yum -y install net-tools lrzsz wget tree screen lsof tcpdump vim bash-completion telnet sysstat yum install -y bind-utils yum install rpcbind nfs-utils -y yum install -y libaio yum -y install httpd-tools# 只找出 当前目录 2016-12-06 这一天修改的文件find . -maxdepth 1 -newermt 2016-12-06# centos history增加时间戳 和 cut 截取 复制命令export HISTTIMEFORMAT%F %T source /etc/profile historyhistory | cut -c 28- # 带时间戳截取命令是 26- history | cut -c 8- # 不带时间戳是 8-零 # linux 查看进程网络工具安装 原文linux 查看某进程或程序的网卡流量(转) - 清明-心若淡定 - 博客园yum install epel-release -y yum install libpcap nethogs -y nethogs eth0 lsof -i :80 lsof -p 6402# 安装python3 centos#wget http://mirrors.163.com/.help/CentOS7-Base-163.repo # 使用163 yum -y install epel-release yum install -y python3 python3-devel which pip3 pip3 install --upgrade pip pip3 install requestsyum install gcc -y yum install pcre pcre-devel -y yum install zlib zlib-devel -y yum install openssl openssl-devel -y yum -y install gcc gcc-c autoconf automake make yum -y install unzip zip #安装常用插件 yum install -y bash-completion # base-completion.noarch补全 yum -y install net-tools lrzsz wget tree screen lsof tcpdump vim bash-completion telnet sysstat yum install -y bind-utils yum -y install wget yum -y install vim net-tools lrzsz#安装常用插件 yum install -y bash-completion # base-completion.noarch补全 yum -y install net-tools lrzsz wget tree screen lsof tcpdump vim bash-completion telnet sysstat yum install -y bind-utils# mysql nfs还需要装的依赖yum install -y libaio yum install mysql-devel gcc gcc-devel python-devel -y # 记得安装mysql客户端或服务端 python链接mysql才能用yum install rpcbind nfs-utils -y# 开始关闭网卡ifdown ifcfg-ens33 #关闭网卡 ifup ifcfg-ens33 #开启网卡 # 有时候上面命令不好用用下面的 效果等同 ifconfig ens33 down ifconfig ens33 up一 配置网络# eth0为网卡名称 cat /etc/sysconfig/network-scripts/ifcfg-eth0 EOF TYPEEthernet PROXY_METHODnone BROWSER_ONLYno BOOTPROTOstatic # 使用静态IP地址默认为dhcp IPADDR192.168.1.102 # 设置的静态IP地址 NETMASK255.255.255.0 # 子网掩码 GATEWAY192.168.1.1 # 网关地址 DNS1192.168.1.1 # DNS服务器 #DNS2172.20.10.1 DNS2192.168.90.1 DEFROUTEyes IPV4_FAILURE_FATALno IPV6INITyes IPV6_AUTOCONFyes IPV6_DEFROUTEyes IPV6_FAILURE_FATALno IPV6_ADDR_GEN_MODEstable-privacy NAMEens33 UUID66c0a6eb-0b92-4a00-96e0-92e0980d69df DEVICEens33 ONBOOTyes EOF二 更新yum源centos7cd /etc/yum.repos.d wget http://mirrors.aliyun.com/repo/Centos-7.repo mv Centos-7.repo CentOs-Base.repo yum clean all yum makecache yum updatecentos6.5 Centos6.6 yum源更新# 备份 下载 清理 cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d//CentOS-Base.repo.ori wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo yum clean all # 更新缓存 yum makecache yum install tree -y yum update -y crontab -e # 加入定时任务 每晚一点校准 30 1 * * * ntpdate time.windows.com三 配置时间# 时间同步 ntp# 时间同步ntp yum install ntpdate -y ntpdate time.windows.com # crontab -e # 设置定时任务 */15 * * * * /usr/sbin/ntpdate time.windows.com /dev/null 2 1 */30 * * * * /usr/sbin/ntpdate time.nist.gov /dev/null 21# 时间同步chronyyum -y install chrony # a时间同步 timedatectl set-timezone Asia/Shanghai # 如果时区有问题的需要重启 系统日志时间才正常 systemctl restart chronyd systemctl status chronyd # 如果是想要作为内部 chrony # 服务端 echo allow 10/8 /etc/chrony.conf systemctl restart chronyd cat /etc/chrony.conf | grep -v ^# | grep -v ^$ # 客户端 sed -i s/server 0.centos.pool.ntp.org/#/ /etc/chrony.conf sed -i s/server 1.centos.pool.ntp.org/#/ /etc/chrony.conf sed -i s/server 2.centos.pool.ntp.org/#/ /etc/chrony.conf # 执行服务端IP sed -i s/server 3.centos.pool.ntp.org/server 10.69.15.111 iburst/ /etc/chrony.conf systemctl restart chronyd# 手工配置时间# date -s 时:分:秒 data -s 年-月-日 如 date -s 16:58:00 date -s 2021-07-21#有下面这个命令的更好timedatectl set-timezone Asia/Shanghai# 修改时区加上 修改ssh openstack镜像常用# 脚本 #!/bin/bash timedatectl set-timezone Asia/Shanghai sed -i s/PasswordAuthentication no/PasswordAuthentication yes/g /etc/ssh/sshd_config # 修改ssh可以密码登录 systemctl restart rsyslog.service systemctl restart sshd# 修改时间戳 CentOS7如何修改日志的时间戳格式包括24小时格式_beeworkshop的博客-CSDN博客vim /etc/rsyslog.conf # Use default timestamp format # 下一行是原来的配置将它注释 #$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat # 添加下面两行 $template CustomFormat,%$NOW% %TIMESTAMP:8:15% %HOSTNAME% %syslogtag% %msg%\n $ActionFileDefaultTemplate CustomFormat 然后重启 rsyslog 服务 systemctl restart rsyslog.service四 开启sshyum install -y openssl openssh-server vim /etc/ssh/sshd_config systemctl status sshd五 关闭防火墙 和 selinuxsystemctl stop firewalld systemctl disable firewalld setenforce 0 sed -i s/SELINUXenforcing/SELINUXdisabled/g /etc/selinux/config # 关闭selinux六 主机名# 临时 hostname xxx # 永久 hostnamectl set-hostname xxx

相关新闻

2026/8/17 15:09:57

无界鼠标:多设备办公的高效解决方案

1. 多设备办公的痛点与解决方案 作为一名长期需要同时操作三台电脑的开发者,我深刻理解多设备切换的烦恼。每次都要在几套键鼠之间来回切换,不仅效率低下,桌面空间也被各种线缆占据。直到发现了微软车库项目出品的Mouse Without Borders&…

2026/8/17 15:09:57

百元级DIY贴片机方案:低成本实现PCB精准贴装

最近在折腾电子制作时,发现很多爱好者都被贴片机的高门槛劝退了。市面上的商业贴片机动辄数万甚至数十万,而开源的OpenPnP虽然免费,但其复杂的配置、对机械硬件的苛刻要求以及陡峭的学习曲线,让很多只想小批量、快速验证PCB设计的…

2026/8/17 16:00:07

使用 TRAE Work 手搓高质量 GEO 标准官网完整实操指南

前言:从传统官网转向 GEO 原生网站生成式引擎优化 GEO,也就是 Generative Engine Optimization,已经成为本地商家、品牌抢占 AI 问答流量最重要的数字基建。区别于传统 SEO 只针对搜索引擎网页排名,GEO 官网建设目标,是…

2026/8/17 15:55:04

OpenClaw部署难题解析与实战指南

1. OpenClaw部署难题深度解析OpenClaw作为一款新兴的AI工具链集成平台,在开发者社区中逐渐崭露头角。但很多初次接触的用户都会遇到同一个问题:为什么它的部署过程如此具有挑战性?经过多次实战部署和问题排查,我发现这背后存在一系…

2026/8/17 10:49:52

工业通信系统底层逻辑:04 反射——高频能量撞墙之后会发生什么?

第四篇:反射——高频能量撞墙之后会发生什么? —— 你以为信号已经过去了,其实它正在回来打你 老Q的现场笔记 第五季,我们正式进入工业神经系统层。这里不再是单个设备的战斗,而是整个工厂“经脉”层面的秩序之战。从这一篇开始,你将第一次看清:看似简单的信号传播,背…

2026/8/17 5:02:51

工业传感器与变送器详解:序章 从物理世界到工业数据

序章 从物理世界到工业数据 ——重新认识工业传感器与变送器 工业自动化系统正变得日益复杂。今天的工业现场早已不是简单的控制回路,而是由多层技术共同构成的立体体系:PLC、DCS、SCADA、MES、工业互联网、边缘计算与人工智能。控制系统可以执行复杂算法,工业网络可以实现…

2026/8/17 0:02:57

LabVIEW异步调用实战:解决界面卡顿与并行处理难题

1. 项目概述:为什么异步调用是LabVIEW进阶的必经之路如果你在LabVIEW里写过稍微复杂点的程序,尤其是涉及到界面响应、多任务并行或者硬件IO等待,大概率会遇到一个头疼的问题:程序“卡”住了。前面板点不动,进度条不更新…

2026/8/17 0:02:57

飞书局域网文件传输实战:3种方案实现高速点对点传输

1. 项目概述:为什么要在局域网内用飞书传文件? 飞书作为一款主流的协同办公套件,其核心功能是围绕云端协作设计的。无论是文档、表格还是文件,通常的分享逻辑都是“上传到云端 -> 生成链接 -> 分享给同事”。这个流程在互联…

2026/8/17 15:07:41

实测才敢推 AI论文网站 2026最新测评与推荐

2026年真正好用的AI论文网站,核心看生成的论文质量、低AI味、格式正确、学术适配四大指标。综合实测,千笔AI、ThouPen、豆包、DeepSeek、Grammarly 是当前最值得推荐的梯队,覆盖从免费到付费、从中文到英文、从文科到理工的全场景需求。一、综…

2026/8/16 16:53:03

2026必备!AI论文网站测评:最新推荐与深度对比

2026年真正好用的AI论文网站,核心看生成的论文质量、低AI味、格式正确、学术适配四大指标。综合实测,千笔AI、ThouPen、豆包、DeepSeek、Grammarly 是当前最值得推荐的梯队,覆盖从免费到付费、从中文到英文、从文科到理工的全场景需求。 一、…

2026/8/15 9:46:30

摆脱论文困扰!盘点2026年全网爆红的的AI论文写作工具

一天写完毕业论文在2026年已不再是天方夜谭。2026年最炸裂、实测能大幅提速的AI论文写作工具,覆盖选题构思、文献整理、内容生成、格式排版等核心场景,真正帮你高效搞定论文难题。 一、全流程王者:一站式搞定论文全链路(一天定稿首…