linux综合架构敲门砖
先给SentOS7安装自动补全的安装包。
1 |
|
安装以后退出,重新登录安装包才会生效。
CentOS7版本与CentOS6有着些许的区别。
一、本地yum
1、CentOS6必须自己编译repo文件。
2、CentOS7的做法:
1.挂载光盘->设置->cdrom->iso->选择对应的镜像文件
2.在centos7系统进行挂载
1 |
|
3.查询yum-config-manager工具属于哪个软件包提供(查询方式是联网)
1 |
|
4.安装对应的软件包
1 |
|
yum-utils 管理repository(包)及扩展包的工具 (主要是针对repository)
5.备份repo文件
1 2 |
|
6.使用yum-config-manager命令创建一个本地仓库
1 |
|
7.测试yum是否能正常使用
1 |
|
修改主机名
CentOS6实现方式
1.临时修改主机名
1 2 |
|
2.永久修改主机名
1 2 3 4 |
|
centos7实现方式
1.临时修改主机名
1 2 |
|
2.永久修改主机名
1 2 3 |
|
时区修改
1.查看时区
1 |
|
2.修改时区
1 2 |
|
系统文件目录结构
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 |
|
启动级别
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 |
|
Centos7开机默认系统启动目标target
multi-user.target: analogous to runlevel 3
graphical.target: analogous to runlevel 5
1.查看系统当前默认运行级别(目标)
1 2 |
|
2.修改系统启动默认级别(目标)
1 |
|
建议修改回去
1 |
|
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 |
|
centos7启动与停止建议使用systemctl
1 |
|
centos7查看所有的服务开机启动和开机不启动的单元
1 |
|
centos7开机不自启
1 |
|
centos7开机自启
1 |
|
centos7检查是否开机自启
1 2 |
|
Centos7系统优化
1.调整yum源
1 2 3 |
|
2.清理缓存,并重新生成缓存文件
1 2 |
|
3.安装基础软件包
1 2 3 |
|
4.关闭防火墙
1 2 |
|
5.关闭selinux
1 |
|
6.优化ulimit
1 |
|
7.执行shutdown -h now 关闭Centos7系统
8.选中对应的虚拟机->快照->拍摄快照
重新配置网卡
1 |
|
综合架构
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
hostnamectl
set
-hostname backup<em id=
"__mceDel"
> </em>
- 修改IP地址
3.重启服务器1
sed -i
's#222#41#g'
/etc/sysconfig/network-scripts/ifcfg-eth[01]
4.创建xshell标签->测试连接服务器是否成功1
2
nmcli connection reload #重新加载配置
nmcli connection down eth1 && nmcli connection up eth1 && nmcli connection down eth0 && nmcli connection up eth0 #重启两块网卡
5.基于已克隆好的机器快照
- 修改主机名