4-网络层(上)
网络层基础在参考模型中网络层位于传输层之下,链路层之上。
网络层的功能主要是将源端产生的数据包/分组,送达至目的机
完成这项工作需要:
封装源数据
识别目的机
找到一条好的路径(路由)
可能遭遇的问题:
地址不够用
丢包
拥塞
网络层主要内容被路由协议:IP协议
IP地址:定位目的机
IP分组:解决信息封装
IPv6:新一代IP协议
路由选择协议:找到目的机和源机之间的最优路径
距离矢量路由选择协议(RIP)
链路状态路由选择协议(OSPF)
其他方面:
ARP
ICMP
CIDR
NAT
源和目的机之间的网络分为:数据报网络:提供无连接的服务
虚电路网络:提供面向连接的服务
比较项目
数据报子网(无连接服务)
虚电路子网(面向连接服务)
建立电路
不需要
要求
地址信息
每个分组含完整的SA和DA
每个VC包含一个很短的VC号码
状态信息
路由器不保留任何连接状态信息
每个VC都要求路由器建立表项
路由
每个分组独立选择路由
每个分组沿建立VC时确定的路由
路由器失效影响
没有,只有系统崩溃时丢失分组
所有经过失效R的VC都终止
服务质量 ...
4-Dockerfile And Docker Compose
DockerfileDocker镜像原理Linux文件系统由bootfs与rootfs两部分构成
bootfs:包含bootloader(引导加载程序)和kernel(内核)
rootfs:root文件系统,包含的就是典型的Linux系统中的/dev,/proc,/bin,/etc等标准文件与目录
不同的Linux发行版bootfs基本相同,主要区别在于rootfs
而Docker镜像是由特殊的文件系统叠加而成,其最底端同样依赖bootfs,但是其不需要自己独立拥有bootfs,其可以直接使用宿主机的bootfs。第二层是root文件系统rootfs,被称为base image即基础镜像。
在其上可以继续叠加其他镜像,而各个镜像之间的文件目录资源等可以相互共享,进一步提高了镜像利用率
统一文件系统(UFS:Union File System):该技术能够将不同层镜像整合为一个文件系统,为这些层提供一个统一的对外视角,这样就隐藏了多层存在,从用户角度来看,只暴露了最外层文件系统
一个镜像可以位于另一个镜像下层,位于下层的镜像被称为父镜像,最底部的镜像称为基础镜像
当从一个镜像启动 ...
3-Docker应用部署
Docker应用部署一般部署步骤
搜索镜像
拉取镜像
创建容器
操作容器
部署MySQL前文说到,Docker容器本身不能直接与外部机器通信,其只能与宿主机直接通信,而宿主机又可以直接与外部机器通信,所以想要访问Docker容器,就可以将Docker容器的端口映射到宿主机的端口上(一般都对应到相同端口),这样就可以利用宿主机的端口间接访问Docker容器,即端口映射
12345678910111213# 搜索镜像docker search mysql# 拉取镜像docker pull mysql# 创建容器,注意创建容器前,在根目录下创建mysql文件夹并进入该目录下,后续数据卷的安装在/root/mysql下进行docker run -id \-p 3306:3306 \ # 配置端口映射--name c_mysql \-v $PWD/conf:/etc/mysql/conf.d \ # 配置配置文件数据卷,$PWD表示当前所在文件夹路径-v $PWD/logs:/logs \ # 配置日志数据卷-v $PWD/data:/var/lib/mysql \ # 配置存放数据的数据卷 ...
2-Docker容器数据卷
Docker容器数据卷数据卷概述实际开发中,数据的持久化以及数据交互都是十分重要的功能,所以Docker需要处理以下问题
Docker容器删除后,容器中的应用数据是否被删除
Docker容器与外部机器(宿主机与网络机器)间如何进行文件交互
Docker容器之间如何进行文件的交换
面对以上问题,Docker提供了数据卷的概念,数据卷是宿主机中的一个目录或文件,当容器与数据卷目录绑定(挂载)后,双方对数据卷的修改会立即同步,数据卷与容器不是一一对应的关系,一个数据卷可以挂载多个容器,一个容器也可以被挂载多个数据卷
数据卷的作用
保证容器数据的持久化
实现容器与宿主机之间的文件交换
实现Docker容器之间的文件交换
配置数据卷配置数据卷只需要在创建容器时利用-v参数指定宿主机路径与容器路径的挂载关系
1234# 创建容器时,使用-v参数设置数据卷docker run -it --name test1 -v 宿主机目录(或文件):容器内目录(或文件) ...# 例如:docker run -it --name centosTest1 -v /root/data:/root/data_c ...
1-Docker概述
Docker概述
Docker 是一个开放源代码软件,是一个开放平台,用于开发应用、交付(shipping)应用、运行应用。 Docker允许用户将基础设施(Infrastructure)中的应用单独分割出来,形成更小的颗粒(容器),从而提高交付软件的速度。
Docker容器与虚拟机类似,但二者在原理上不同。容器是将操作系统层虚拟化,虚拟机则是虚拟化硬件,因此容器更具有便携性、高效地利用服务器。 容器更多的用于表示 软件的一个标准化单元。由于容器的标准化,因此它可以无视基础设施(Infrastructure)的差异,部署到任何一个地方。另外,Docker也为容器提供更强的业界的隔离兼容。
Docker安装步骤(centos)
1234567891011121314# 1. 更新所有yum包到最新yum update# 2. 安装所需软件包,yum-utils提供yum-config-manager功能另两个是devicemapper驱动所依赖的yum install -y yum-utils \ device-mapper-persistent-data \ lvm2# 3. ...
13-DCL用户管理语言
DCL-用户管理语言1234567891011121314151617181920212223242526272829303132333435363738show DATABASES;# 切换到mysql数据库use mysql;# 查看user表SELECT * from user;# 创建用户语法# CREATE USER '用户名'@'主机名' IDENTIFIED BY '密码';# localhost表示本地主机 通配符%表示任意主机(可远程访问)CREATE USER 'renboyu'@'%' IDENTIFIED BY 'renboyu01';# 修改密码# UPDATE USER SET authentication_string=PASSWORD('新密码')WHERE USER='用户名';# PASSWORD()函数为加密函数UPDATE user SET authentication_string = ...
12-分支结构,循环结构
分支结构IF函数12345678910111213141516# 流程控制结构/*顺序结构:程序自上而下依次执行分支结构:程序从两条或多条路径中选择一条去执行循环结构:程序在满足一定条件基础上,重复执行一段代码*/# 分支结构# IF(expr1,expr2,expr3)函数功能:实现简单的双分支语法:SELECT IF(expr1,expr2,expr3)执行顺序:如果表达式1成立,则执行表达式2,否则执行表达式3可以存储在程序任何地方
CASE结构12345678910111213141516171819202122232425262728293031323334353637# CASE结构语法:CASE case_value WHEN when_value THEN statement_list WHEN when_value THEN statement_list ... ELSE statement_listEND CASE;# 情况1:类似于Java中的switch语句,一般用于实现等值判断# 情况2:类似于Java中的多重IF语句,一般用于实现区间判断# 特点:可 ...
11-存储过程和函数
存储过程123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153# 存储过程和函数/*存储过程和函数:类似Java中的方法好处:1. 提高代码重用性2. 简化操作*/# 存储过程/*含义:一组预先编译好的SQL语句集合好处:1. 提高代码重用性2. 简化操作3. 减少编译次数4. 减少数据库服务器的连接次数,提高效率*/# 存储过程创建CREATE P ...
10-变量
系统变量12345678910111213141516171819202122232425262728293031323334353637383940414243444546# 变量/*系统变量 全局变量 会话变量自定义变量 用户变量 局部变量*/# 一。系统变量# 变量由系统提供,不由用户定义,属于服务器层面/*使用语法:(不写global,session默认使用会话变量)1. 查看所有系统变量SHOW GLOBAL VARIABLES; # 查看全局变量SHOW 【SESSION】 VARIABLES; # 查看会话变量2. 查看满足条件的部分系统变量SHOW GLOBAL VARIABLES LIKE 'CHAR';SHOW 【SESSION】 VARIABLES LIKE 'CHAR';3. 查看指定的某个系统变量SELECT @@global.系统变量名;SELECT @@【SESSION.】系统变量名;4. 为某个具体的系统变量赋值# 方式1SET 【session.】系统变量名=值; # 为会话变量赋值SE ...
9-视图
视图含义虚拟表,可以和普通表一样使用。MySQL5.1版本出现的新特性,是通过表动态生成的数据,也就是说行和列的数据都来自定义识图的查询中使用的表,只保存sql逻辑,不保存查询结果
类似于Java中包装一个方法/函数
应用场景
多个地方用到同样的查询结果
该查询结果使用的sql语句较为复杂
视图的创建视图的好处
有利于重用sql语句
简化复杂的sql操作,不必知道它的查询细节
保护数据,提高安全性
1234567891011121314151617181920212223242526272829303132333435# 视图的创建USE myemployees;/*语法:CREATE VIEW 视图名AS 查询语句;*/# 查询邮箱中包含a字符的员工名,部门名,和工种信息# 创建视图(这里使用的sql92连接查询方法,还可以使用sql99 JOIN ON)CREATE VIEW v1ASSELECT CONCAT(first_name,' ',last_name) 姓名, department_name 部门名,job_title 工种,email FROM ...