Centos基础配置 centos7基础 含 yum 配置 时区配置 ssh配置 - openstack基础镜像-手工配置时间 linux基础 含cp显示进度 linux下载站等

发布时间:2026/10/6 17:58:55

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/10/5 2:28:09

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

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

2026/10/5 23:04:29

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

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

2026/10/6 17:54:32

扣子COZE多轮对话客服搭建指南:意图识别、知识库与上线避坑

简介:面向有一定编程基础、希望在低代码环境中落地智能客服的开发者或企业技术人员,这份资料系统介绍了基于扣子COZE平台构建多轮对话智能客服助手的完整方案,重点解决官网场景下用户问题自动应答、意图识别、上下文跟踪、服务推荐及API集成等…

2026/10/6 17:54:32

华为eNSP从零开始:依赖安装、VLAN配置与三层互通实战

简介:华为ENSP是华为官方的网络模拟平台,这份配置文档围绕其常用网络技术整理,尤其适合网络初学者、备考华为认证或需要进行协议实验复现的工程师。内容以设备配置流程为主线,系统覆盖VLAN划分与trunk放行、VLAN间路由&#xff08…

2026/10/6 17:54:32

Agent开发范式转移:从工程化思维到稳定落地的实战指南

很多人问过我,Agent 开发到底跟传统后端开发有什么本质区别。看完 Alibaba Cloud AI Agent Handbook 和相关的开发者调研数据,我的感受是:Agent 不是又一种框架,而是把“软件从被动执行指令,变成主动理解目标”的一次范…

2026/10/6 17:54:32

PyTorch自定义C++/CUDA算子实战:从原理到性能优化

1. 为什么需要自定义算子 1.1 PyTorch 算子的两种来源 我一直觉得,很多人对“自定义算子”这个词的第一反应是“这是那些做框架的人才会碰的东西”。实际上 PyTorch 每天在用的所有功能,无论是 torch.add 还是 conv2d ,本质上都能归成两…

2026/10/6 17:49:32

汇川IS620N伺服回零模式调试全解析:从模式1到35的踩坑经验

最开始接触汇川IS620N回零模式的时候,我印象最深的是手册里那一张密密麻麻的模式定义表:从模式1到模式35,光看编号和方向组合就够让人头疼。当时我心想,不就找个原点嘛,搞这么复杂干什么。结果第一次上电调试&#xff…

2026/10/5 6:32:56

Jev+Agent接管浏览器:browser-use实战与jev-ultrafast性能优化

1. 从“Jev”说起:为什么我要把Agent接进浏览器“Jev”这个词最近在圈子里出现的频率越来越高,很多人第一次听到会以为是某个新模型的名字,其实它更像是一种思路——把Jev模型的能力当作底座,通过Agent的方式去接管浏览器&#xf…

2026/10/6 4:01:51

多智能体集群实战:DeepAgents编排、MCP与A2A协议及Skills体系

1. 从"单兵作战"到"集群协同":多智能体编排到底在解决什么问题如果你最近在折腾 Agent 相关的东西,大概率会有一种感觉:单个 Agent 能做的事情,其实很快就摸到天花板了。你给它一个提示词,挂几个工…

2026/10/6 17:46:51

无源低通滤波器设计实战:从RC到LC,手把手教你避开那些坑

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/6 0:03:23

MR25H40CDF+STM32F031C6工业级高可靠数据存储方案

1. 项目概述:为什么在工业现场非得用 MR25H40CDF 配 STM32F031C6 做数据存储?在工厂产线的 PLC 控制柜里、在风电变流器的散热片背面、在矿井监测终端的金属外壳下,你经常能看到一块指甲盖大小的黑色芯片——它既不是 Flash,也不是…

2026/10/6 0:03:23

MRAM+STM32工业断电数据保全实战指南

1. 项目概述:为什么在工业现场非得用 MR25H40CDF 配 STM32F031C6 做数据存储?在工厂产线的PLC柜里、在野外无人值守的环境监测终端里、在高速运转的包装机控制板上,你经常能看到一块指甲盖大小的黑色芯片,旁边贴着“MR25H40CDF”丝…

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
☎咨询二维码 ☎ ↑