CentOS7与CentOS6的差异

75 篇文章 1 订阅
69 篇文章 2 订阅

linux综合架构敲门砖

先给SentOS7安装自动补全的安装包。

1

yum install bash-completion -y

安装以后退出,重新登录安装包才会生效。

CentOS7版本与CentOS6有着些许的区别。

一、本地yum

1、CentOS6必须自己编译repo文件。
2、CentOS7的做法:
1.挂载光盘->设置->cdrom->iso->选择对应的镜像文件
2.在centos7系统进行挂载

1

[root@oldboyedu ~]# mount /dev/cdrom /mnt

3.查询yum-config-manager工具属于哪个软件包提供(查询方式是联网)

1

[root@oldboyedu ~]# yum provides yum-config-manager

4.安装对应的软件包

1

[root@oldboyedu ~]# yum install yum-utils -y

yum-utils 管理repository(包)及扩展包的工具 (主要是针对repository)
5.备份repo文件

1

2

[root@oldboyedu ~]# cd /etc/yum.repos.d/

[root@oldboyedu yum.repos.d]# gzip *

6.使用yum-config-manager命令创建一个本地仓库

1

[root@oldboyedu ~]# yum-config-manager --add-repo=file:///mnt

7.测试yum是否能正常使用

1

[root@oldboyedu ~]# yum install vim -y

修改主机名

CentOS6实现方式
1.临时修改主机名

1

2

[root@c6 ~]# hostname oldboy_temp

[root@c6 ~]# bash

2.永久修改主机名

1

2

3

4

[root@oldboy_temp ~]# sed -i '/^HOSTNAME=/c HOSTNAME=oldboyedu' /etc/sysconfig/network

[root@oldboy_temp ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=oldboyedu

centos7实现方式

1.临时修改主机名

1

2

[root@oldboyedu ~]# hostname oldboy-c7

[root@oldboyedu ~]# bash

2.永久修改主机名

1

2

3

[root@oldboy-c7 ~]# hostnamectl set-hostname oldboyedu-cc7

[root@oldboy-c7 ~]# cat /etc/hostname

oldboyedu-cc7

时区修改

1.查看时区

1

[root@oldboy-c7 ~]# timedatectl list-timezones

2.修改时区

1

2

[root@oldboy-c7 ~]#timedatectl set-timezone "America/Punta_Arenas"

[root@oldboy-c7 ~]# timedatectl set-timezone "Asia/Shanghai"

系统文件目录结构

centos6	    cetos7    
bin     ->  usr/bin    
sbin    ->  usr/sbin    
lib	lib ->  usr/lib   

网络命名的规则

默认命名规则        eth0 eth1 eth2    
biosdevname         em1 em2 em3    
net.ifnames         ens33 ens34 ens35   

安装net-tools工具,可使用ifconfig命令

1

[root@oldboy-c7 ~]# yum install net-tools -y

启动级别

SysVinit	                    Systemd    
关闭系统	        0	        runlevel0.target,poweroff.target    
单用户模式	        1	        runlevel1.target,rescue.target    
多用户模式	        2	        runlevel2.target,multi-user.target    
多用户带网络模式	3	        runlevel3.target,multi-user.target    
多用户图形化模式	5	        runlevel5.target,graphical-user.target    
重启操作系统	    6	        runlevel6.target,reboot.target       

Centos6开机默认系统启动运行级别

1

vim /etc/inittab

Centos7开机默认系统启动目标target

multi-user.target: analogous to runlevel 3
graphical.target: analogous to runlevel 5
1.查看系统当前默认运行级别(目标)

1

2

[root@oldboy-c7 ~]# systemctl get-default

multi-user.target

2.修改系统启动默认级别(目标)

1

[root@oldboy-c7 ~]# systemctl set-default runlevel5.target

建议修改回去

1

[root@oldboy-c7 ~]# systemctl set-default multi-user.target

3.centos7关机指令
poweroff、shutdown -h now、init0 (不建议使用)
reboot

systemd服务管理

命令 选项(非必须) 执行命令 单元名称(非必须)    
systemctl [OPTIONS...]COMMAND[NAME...]    
操作	    Centos6	                        Centos7    
启动服务	/etc/init.d/crond start	        systemctl start     crond    
停止服务	/etc/init.d/crond stop	        systemctl stop      crond    
重启服务	/etc/init.d/crond restart	    systemctl restart   crond    
查看状态	/etc/init.d/crond status	    systemctl status    crond    
开机启动	chkconfig --level 35 crond on	systemctl enable    crond    
开机禁用	chkconfig crond off	            systemctl disable   crond    
禁止运行	                                systemctl umask     crond        

centos7上的service命令还是为了兼容centos6的习惯

1

2

[root@oldboyedu-cc7 ~]# service crond restart

Redirecting to /bin/systemctl restart crond.service

centos7启动与停止建议使用systemctl

1

[root@oldboyedu-cc7 ~]# systemctl restart crond

centos7查看所有的服务开机启动和开机不启动的单元

1

[root@oldboyedu-cc7 ~]# systemctl list-unit-files

centos7开机不自启

1

[root@oldboyedu-cc7 ~]# systemctl disable crond

centos7开机自启

1

[root@oldboyedu-cc7 ~]# systemctl enable crond

centos7检查是否开机自启

1

2

[root@oldboyedu-cc7 ~]# systemctl is-enabled crond

disabled

Centos7系统优化

1.调整yum源

1

2

3

rm -rf /etc/yum.repos.d/*

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

2.清理缓存,并重新生成缓存文件

1

2

yum clean all

yum makecache

3.安装基础软件包

1

2

3

yum install net-tools vim tree htop iotop iftop \

iotop lrzsz sl wget unzip telnet nmap nc psmisc \

dos2unix bash-completion sysstat rsync nfs-utils -y

4.关闭防火墙

1

2

systemctl disable firewalld #临时关闭

systemctl stop firewalld #永久关闭

5.关闭selinux

1

sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config

6.优化ulimit

1

echo '* - nofile 65535' >> /etc/security/limits.conf

7.执行shutdown -h now 关闭Centos7系统
8.选中对应的虚拟机->快照->拍摄快照

重新配置网卡

1

[root@oldboy-50 ~]# nmcli connection add con-name eth1 ifname eth1 type ethernet ipv4.addresses 172.16.1.222/24 autoconnect yes ipv4.method manual

综合架构

1.什么是项目
类似于腾讯公司旗下的qq就是一个项目,微信也是一个项目,每个游戏都是一个项目
2.什么是架构
维护一个项目使用的一套服务器。挣钱
3.什么是集群
服务器集群就是指将很多服务器集中起来一起进行同一种服务,在客户端看来就像是只有一个服务器。集群可以利用多个计算机进行并行计算从而获得很高的计算速度,也可以用多个计算机做备份,从而使得任何一个机器坏了整个系统还是能正常运行。
4.什么是高可用->双击热备
备用服务器。主服务器出现故障时备用服务器忙上代替它的工作。

三星级酒店(初步了解架构结构)

顾客(满足一切需求)
保安 --> 验证身份
迎宾 --> 接待
服务员 --> 翻译顾客需求
吧台 --> 烟酒
备菜 --> 提前让厨师准备好菜
后厨 --> 厨师
仓库 --> 存放一些重要的东西

用户访问网站流程

1.用户通过浏览器输入oldboyedu.com->回车  
2.进行DNS解析->获取真实的公网IP地址  
3.用户通过tcp的三次握手发起连接->真实的公网IP  
4.连接会通过公网->路由器->交换机->抵达前端的防火墙  
5.防火墙根据自身访问规则,进行判定->如果恶意的连接则拒绝->如果是正常的连接则放行  
6.防火墙会将连接发送给负载均衡器->查看用户请求的内容->根据内容进行任务下发->下发给web服务器  
7.web服务接收请求后会根据请求进行判断  
    如果是请求图片或者附件->存储服务  
    如果请求的网站上的文章或者内容->缓存服务器->如果缓存服务器没有则->数据库  
    数据库查询完数据之后会返回数据给web服务器->同时也会返回一份给缓存服务器  
8.数据库返回内容->web服务器->负载均衡->用户  
五层架构模型-->  负载均衡   web服务   存储服务   缓存服务   数据库服务(通过tcp连接)  

管理人员维护流程

1.用户通过公网连接(隧道)VPN服务器,这样方便管理内部主机,并且可以实现批量管理主机,备份所有重要文件。  
2.用户可以通过公网连接监控服务器(也可以使用其他方式去实现)  
3.提交视频http://192.168.20.250 ->  提交的大小300M  ->  提交的格式1_姓名_内容.mp4  
4.检查->组长->(声音->思路->流畅度)--> ocam录制工具    
克隆  
1.连接克隆(需要依赖于母体)  
2.完整克隆(完完全全的复制一份,占用磁盘空间)  

克隆后的机器需要做如下操作

    1. 修改主机名

      1

      hostnamectl set-hostname backup<em id="__mceDel"> </em>

    2. 修改IP地址

      1

      sed -i 's#222#41#g' /etc/sysconfig/network-scripts/ifcfg-eth[01]

      3.重启服务器

      1

      2

      nmcli connection reload #重新加载配置

      nmcli connection down eth1 && nmcli connection up eth1 && nmcli connection down eth0 && nmcli connection up eth0 #重启两块网卡

      4.创建xshell标签->测试连接服务器是否成功
      5.基于已克隆好的机器快照
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值