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

相关新闻

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

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

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

2026/10/14 2:06:53 阅读更多 →
详谈购物小程序开发需要注意什么

详谈购物小程序开发需要注意什么

在移动互联网普及下的当下,手机购物已经成为人们获取商品的标配。如今各种各样的在线购物平台越来越多,但是却并没有给商家带来良好的收益。因为大多数的商家在入驻第三方平台之后收益并不能成正比,所以纷纷都有了开发购物小程序的想法。想法…

2026/10/13 0:38:24 阅读更多 →
滑动窗口协议:TCP可靠传输的核心机制与优化实践

滑动窗口协议:TCP可靠传输的核心机制与优化实践

1. 滑动窗口协议的核心价值 在计算机网络通信中,滑动窗口协议(Sliding Window Protocol)是确保数据可靠传输的基石机制。我第一次在实际项目中接触这个协议,是在调试一个跨数据中心文件同步工具时——当时传输大文件总是出现丢包重…

2026/10/9 18:12:23 阅读更多 →

最新新闻

Python pywebcopy整站镜像:实现网页离线保存的完整方案

Python pywebcopy整站镜像:实现网页离线保存的完整方案

简介:pywebcopy 是一款用 Python 编写的网页镜像与归档工具,面向需要离线保存网页、网站资源或研究爬虫实现的开发者。它尊重 robots.txt,一次调用即可把 CSS、JS、图片等资产连同页面完整下载,并能重新映射链接、克隆整站&#x…

2026/10/14 2:06:18 阅读更多 →
SO增强与状态修改实战:从ELF结构到Hook技术详解

SO增强与状态修改实战:从ELF结构到Hook技术详解

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

2026/10/14 2:06:18 阅读更多 →
无人自助拼豆系统架构设计与落地实战 核心功能开发全指南

无人自助拼豆系统架构设计与落地实战 核心功能开发全指南

无人自助拼豆系统架构设计与落地实战 核心功能开发全指南 随着无人自助业态的普及,手工DIY场景的无人化运营需求持续提升,无人自助拼豆系统通过结合物联网、移动开发、服务端技术,实现了24小时无人值守、用户自助拼团、设备智能管控的完整业务…

2026/10/14 2:06:18 阅读更多 →
无人自助拼豆系统开发实战指南 核心功能实现流程与踩坑经验总结

无人自助拼豆系统开发实战指南 核心功能实现流程与踩坑经验总结

无人自助拼豆系统开发实战指南 核心功能实现流程与踩坑经验总结 随着DIY手工业态的快速发展,无人自助拼豆店凭借低运营成本、24小时营业的优势,在年轻消费群体中普及度越来越高。无人自助拼豆系统作为门店的核心支撑,是典型的「多端应用物联网…

2026/10/14 2:06:18 阅读更多 →
IB_Robot 容器验证排障手册:Ubuntu Docker 中 setup.sh / build.sh 的 21 个已知陷阱与修复实践

IB_Robot 容器验证排障手册:Ubuntu Docker 中 setup.sh / build.sh 的 21 个已知陷阱与修复实践

具身智能机器人人工智能大模型模型推理服务本地部署计算机视觉ROS 【免费下载链接】IB_Robot Save the code of IB-Robot, an AI robot execution framework developed by openEuler Embedded for embodied intelligence scenarios. It includes references to the forked vers…

2026/10/14 2:06:18 阅读更多 →
Java 设计模式之 Template View:用模板视图分离静态布局与动态内容,打造可复用网页渲染骨架

Java 设计模式之 Template View:用模板视图分离静态布局与动态内容,打造可复用网页渲染骨架

示例工程教程 【免费下载链接】java-design-patterns Design patterns implemented in Java 项目地址: https://gitcode.com/GitHub_Trending/ja/java-design-patterns 点击查看 免费下载 导读:Template View(模板视图)是一种面向…

2026/10/14 2:05:18 阅读更多 →

日新闻

AnyPS5通用适配层设计:兼容性与性能的工程取舍

AnyPS5通用适配层设计:兼容性与性能的工程取舍

1. 从"AnyPS5"这个名字说起:它到底想解决什么问题第一次看到"AnyPS5"这个标题,我脑子里冒出来的第一个念头是:这大概率是一个围绕"跨平台运行"或者"通用适配"做文章的项目。名字里的"Any"…

2026/10/14 0:00:41 阅读更多 →
Flutter跨平台开发实战:二手交易应用与HarmonyOS适配

Flutter跨平台开发实战:二手交易应用与HarmonyOS适配

1. 项目概述:Flutter跨平台二手交易应用开发作为一名长期从事移动应用开发的工程师,我最近完成了一个基于Flutter框架的二手物品交易平台项目。这个项目最吸引我的地方在于它完美结合了Flutter的跨平台优势与HarmonyOS的生态特性,实现了"…

2026/10/14 0:00:41 阅读更多 →
DFS算法解决飞机降落调度问题实战

DFS算法解决飞机降落调度问题实战

1. 项目背景与核心思路飞机降落问题是一个经典的调度优化场景,也是算法竞赛和面试中的高频题目。这个题目要求我们合理安排多架飞机的降落顺序和时间,确保所有飞机都能安全着陆而不发生冲突。在实际航空管制中,这类问题直接关系到飞行安全和机…

2026/10/14 0:00:41 阅读更多 →

周新闻

流感时间序列预测实战:ARIMA/LSTM全流程拆解与避坑指南

流感时间序列预测实战:ARIMA/LSTM全流程拆解与避坑指南

简介:基于 ARIMA、LSTM、Transformer 等模型的流感时间序列预测 Python 源码,面向计算机相关专业课程设计与期末大作业学生,以及项目实战学习者。内容覆盖预处理、平稳性检验、定阶、残差分析、多模型对比预测的完整时序建模流程,…

2026/10/13 2:54:56 阅读更多 →
影刀RPA新手教程:键盘模拟输入实战——输入文本与模拟按键的区别

影刀RPA新手教程:键盘模拟输入实战——输入文本与模拟按键的区别

影刀RPA新手教程:键盘模拟输入实战——输入文本与模拟按键的区别 做影刀RPA自动化,十个新手有八个栽在"往输入框里填东西"这件事上:要么填不进去,要么填了一半,要么直接把原来内容追加在后面。这背后的根因&…

2026/10/13 16:22:04 阅读更多 →
影刀RPA新手教程:阅文起点小说数据采集实战——书籍信息与章节内容

影刀RPA新手教程:阅文起点小说数据采集实战——书籍信息与章节内容

影刀RPA新手教程:阅文起点小说数据采集实战——书籍信息与章节内容 1. 认识影刀:什么场景该用RPA采小说数据 起点中文网的页面结构相对稳定——分类榜单、书籍详情、章节内容三块独立页面,跳转链路清晰。这种场景非常适合影刀自动化&#x…

2026/10/13 1:58:08 阅读更多 →

月新闻

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

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

2026/10/13 22:01:27 阅读更多 →
Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

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

2026/10/13 14:57:39 阅读更多 →
黑夜航拍船只数据集训练YOLOV5模型全流程解析

黑夜航拍船只数据集训练YOLOV5模型全流程解析

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

2026/10/12 18:11:17 阅读更多 →