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

# 常用linux下载网站推荐

Linux系统下载网 - 帮技术人员找到合适的系统!

# ls -l显示具体时间

ls -l --time-style=long-iso

# 复制文件显示进度

原文:如何优雅地给cp命令添加进度条_cp命令显示进度_一只晨兴夜不得寐的运维人的博客-CSDN博客

# -a  参数表示归档复制,-info=progress2  使用进度条 并实时更新
# source_dir/和dest_dir/分别表示源目录和目标目录。
rsync -a --info=progress2 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/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config # 关闭selinux

# 常用开发工具  python3  git 

yum -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

# mysql

wget -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/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/mysql-community.repo
sed -i 's/gpgcheck=1/gpgcheck=0/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 'root'@'localhost' 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

# centos7 换国内源  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

# 只找出 当前目录   2016-12-06 这一天修改的文件

find . -maxdepth 1 -newermt "2016-12-06"

# centos history增加时间戳    和  cut 截取 复制命令

export HISTTIMEFORMAT='%F %T '
source /etc/profile
history 
history | 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 requests
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

   # 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 
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"         # 使用静态IP地址,默认为dhcp
IPADDR="192.168.1.102"   # 设置的静态IP地址 
NETMASK="255.255.255.0"    # 子网掩码
GATEWAY="192.168.1.1"    # 网关地址 
DNS1="192.168.1.1"       # DNS服务器
#DNS2="172.20.10.1 "
DNS2="192.168.90.1"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="66c0a6eb-0b92-4a00-96e0-92e0980d69df"
DEVICE="ens33"
"ONBOOT="yes"
EOF

二 更新yum源:

centos7:

cd   /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 update

centos6.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 2>&1

#  时间同步chrony

yum -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


四 开启ssh

yum install -y openssl openssh-server
vim /etc/ssh/sshd_config
systemctl status sshd

五 关闭防火墙  和 selinux 

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config # 关闭selinux

六 主机名

# 临时
hostname  xxx
# 永久 
hostnamectl set-hostname xxx

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值