---------------git 版本控制系统-------------------
git是一个版本控制系统node
1、什么是版本控制系统?
一、概念
版本控制是一种 记录一个或若干文件内容变化,以便未来查阅特定版本修订状况的系统。
(*)记录文件的全部历史变化
(*)随时可恢复到任何一个历史状态
(*)多人协做开发或修改
(*)错误恢复
(*)多功能并行开发
产品--> 新加功能A ---> 单独拉一个新分支 --> 开发完成后合并到master或者丢弃
二、分类
本地版本控制系统
集中化版本控制系统 SVN
分布式版本控制系统 Gitlinux
三、基本概念
repository 存放全部文件及其历史信息
checkout 取出或切换到执行版本的文件
version 表示一个版本
tag 记录标识一个主要版本。2.0 3.0。用来标识一个特定的version
四、不一样版本控制系统优缺点
本地:
优势:
简单,不少系统中内置。适合保存文本文件(配置文件、文章、信件)
缺点:
只支持管理少许的文件,不支持基于项目的管理
支持的文件类型单一
不支持网络,没法实现多人协做
集中式版本控制系统
优势:
适合多人团队协做开发
代码集中化管理
缺点:
单点故障
必须联网工做,没法单机工做
解决:
分布式版本控制系统
集合集中式版本控制系统优势
支持离线工做,先提交到本地仓库,再在某个时间上传到远程仓库
每一个计算机都是一个完整仓库:强备份。git
2、git分布式版本管理系统
由Linux创始人开发,做为Linux内核代码管理系统使用。
Git在设计时考虑了不少方面设计目标
速度
简单的设计
对非线性开发模式的强力支持(容许上千个并行开发的分支)
彻底分布式
有能力管理超大规模项目(挑战:速度和数据量)
Git原理:保存快照而非保存区别。
Git保存时,至关于保存了当下全部文件的一个总体快照。
因此,每一个版本都是独立的。随时想取某一个版本,能够很快取出来。
3、安装git
Git 的工做区域:
Git repository 最终肯定的文件保存到仓库,做为一个新的版本
staging area 暂存已经修改的文件
woking directory 工做目录
安装git
从 https://git-scm.com/ 下载windows版本git
全使用默认值,一直下一步
4、建立仓库和基本操做
git安装好后,须要一些基本设置
设置用户名:git config --global user.name "yibo"
设置邮箱:git config --global user.email "yibo_qa@163.com"
查看全部设置 git config --list
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2
$ git init
Initialized empty Git repository in C:/Users/vilibra/Desktop/tzkt_demo2/.git/github
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 (master)
$ ll -a
total 68
drwxr-xr-x 1 root 197121 0 4月 21 21:56 ./
drwxr-xr-x 1 root 197121 0 4月 21 21:55 ../
drwxr-xr-x 1 root 197121 0 4月 21 21:56 .git/
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 (master)
$ git status
On branch masterredis
Initial commitdocker
nothing to commit (create/copy files and use "git add" to track)
$ git status
On branch masterapache
Initial commitbootstrap
Untracked files:
(use "git add <file>..." to include in what will be committed)windows
READMEcentos
nothing added to commit but untracked files present (use "git add" to track)
新建文件,默认是未追踪的文件
$ git add README
warning: LF will be replaced by CRLF in README.
The file will have its original line endings in your working directory.
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 (master)
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README
git add 提交到了暂存区域
$ git commit -m "add README"
[master (root-commit) 6363356] add README
1 file changed, 1 insertion(+)
create mode 100644 README
提交到仓库
$ git commit -a -m "modify README"
warning: LF will be replaced by CRLF in README.
The file will have its original line endings in your working directory.
[master db6832b] modify README
1 file changed, 1 insertion(+)
删除文件
rm README
git rm README
git commit -m "delete README"
checkout 某个版本
$ git checkout db6832b5e55a506e29c1c920489208f8d3c881a4
Note: checking out 'db6832b5e55a506e29c1c920489208f8d3c881a4'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at db6832b... modify README
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 ((db6832b...))
$ ll
total 1
-rw-r--r-- 1 root 197121 24 4月 21 22:09 README
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 ((db6832b...))
$ cat README
Hello All
Hello world
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 ((db6832b...))
$ git checkout master
Previous HEAD position was db6832b... modify README
Switched to branch 'master'
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 (master)
$ ll
total 0
5、git远程仓库
实现代码共享
远程仓库实际保存了本地.git文件夹下的东西,内容几乎同样
git 远程仓库访问协议:
ssh协议
git协议
http https协议:通常用于开源项目
经常使用远程仓库实现:
一、github
二、本身搭建git仓库服务器 gitlab
举例:在本身的github中,关联本地仓库。
ssh-keygen -t rsa -C "email@email.com"命令 建立公钥
$ git remote add origin git@github.com:yibo4github/learnggit2.git
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 (master)
$ ll
total 1
-rw-r--r-- 1 root 197121 15 4月 21 22:13 README2
root@Lenovo MINGW32 ~/Desktop/tzkt_demo2 (master)
$ git push -u origin master
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (11/11), 816 bytes | 0 bytes/s, done.
Total 11 (delta 0), reused 0 (delta 0)
To github.com:yibo4github/learnggit2.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
----------------docker------------------------
2013年发布
1、环境配置难题
开发环境运行没有问题,生产不能用,由于生产缺少某些组件。
换一台机器,须要从新配置一遍。
能不能从根本上解决问题:安装的时候,把原始环境,如出一辙地安装一遍。
2、虚拟机
带环境安装的一种解决方案。
缺点:
占用资源多:虚拟机自己须要消耗资源,程序1M,环境几百MB。
冗余步骤多:虚拟机是完整的操做系统,一些系统级别的操做步骤,没法跳过,好比用户登陆。
启动慢:启动操做系统要多久,启动虚拟机就要多久。
3、Linux容器
针对虚拟机的缺点,Linux发展出另外的一种虚拟化技术:Linux容器。
Linux容器不是模拟完整的操做系统,而是对进程进行隔离。
即在正常进程的外面,套一个保护层,对于容器里面的进程来讲,它接触到的资源都是虚拟的,实现与底层系统的隔离。
优势:
启动快:容器里面的应用,直接就是底层系统中的一个进程,启动容器至关于启动本机的进程。而不是启动操做系统。
占用资源少:容器只占用须要的资源,不占用没有用到的资源。
体积小:只包含用到的组件,而虚拟机包含了整个操做系统。因此容器文件比虚拟机文件小的多。
4、Docker是什么?
Docker属于Linux容器的一种封装,提供了简单易用的容器使用接口。
Docker将应用程序与该程序的依赖,打包到一个文件里面,运行这个文件,就会产生一个虚拟容器。
程序在虚拟容器中运行,就好像运行在真正的物理机上同样。
Docker提供版本管理、复制、分享、修改等功能,就像管理普通代码同样管理Docker容器。
5、Docker的用途:
Docker的主要用途,目前有三大类。
一、提供一次性的环境:本地测试他人的软件程序。
二、提供弹性的云服务。Docker容器能够随开随关,很适合动态的扩容和缩容。
三、组建微服务架构。经过多个容器,一台机器能够跑多个服务,在本机就能够模拟出微服务架构。
6、Docker安装
一、Linux安装
Docker要求CentOS内核版本高于3.10
uname -r 查看内核版本
安装必要的系统工具:
yum install -y yum-utils device-mapper-persistent-data lvm2
添加软件源信息:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新 yum 缓存:
yum makecache fast
安装 Docker-ce:
yum -y install docker-ce
启动 Docker 后台服务
systemctl start docker
测试运行 hello-world
docker run hello-world
看到hello from docker证实安装成功。
二、windows安装
win10专业版,直接安装 docker for windows 便可。
win10普通版、win7 win8 ,须要安装 docker tool box
toolbox 配置:
右键 Docker Quickstart Terminal
"D:\Program Files (x86)\Git\bin\bash.exe" --login -i "C:\Program Files\Docker Toolbox\start.sh"
把这个位置配成你本机的git位置 修改后面这个脚本
DOCKER_MACHINE="C:\Program Files\Docker Toolbox\docker-machine.exe"
STEP="Looking for vboxmanage.exe"
VBOXMANAGE="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"
#if [ ! -z "$VBOX_MSI_INSTALL_PATH" ]; then
# VBOXMANAGE="${VBOX_MSI_INSTALL_PATH}VBoxManage.exe"
#else
# VBOXMANAGE="${VBOX_INSTALL_PATH}VBoxManage.exe"
#fi
7、image文件
Docker把应用程序及其依赖,打包在image文件里面,只有经过image文件,才能生成docker容器。
Docker能够根据image文件生成容器实例。
image文件能够继承。在实际开发中,一个image文件每每经过继承另外一个image文件,加上一些个性化的设置而生成。
启动容器
docker run hello-world
列出全部image文件
docker image ls
删除image文件
docker image rm image文件名
8、安装redis
一、搜索镜像:
docker search redis
二、拉取镜像
docker pull redis
三、启动redis
docker run --name myredis -p 6379:6379 -d redis redis-server
-d表示后台运行
-p表示端口号,左边的6379表示win10系统端口考,右边表示容器中redis端口号
--name表示运行redis镜像的实例名称
9、Kafka部署
前提:Zookeeper
官网下载安装包
http://kafka.apache.org/downloads
上传tar
解压
tar -zxvf ......
在kafka目录中,建立一个logs文件夹
若是不建立,默认放在 /tmp 目录下
修改 config/server.properties
broker.id=0
broker 的 全局惟一编号,不能重复
delete.topic.enable=true
容许删除topic
# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3
处理网络请求的线程数量
# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8
用来处理磁盘IO的线程数量
# A comma separated list of directories under which to store log files
log.dirs=/usr/local/kafka_2.11-2.1.1/logs
kafka运行日志存放的路径
zookeeper.connect=node3:2181,node4:2181,node5:2181
zookeeper相关信息
分发安装包
注意:要修改配置文件中 borker.id的值
broker id 不得重复
启动kafka集群
./bin/kafka-server-start.sh config/server.properties &
jps命令能够看Kafka进程
关闭命令:
bin/kafka-server-stop.sh stop
10、Kafka命令行操做
查看当前服务器中全部的topic
./bin/kafka-topics.sh --zookeeper node3:2181 --list
建立topic
./bin/kafka-topics.sh --zookeeper node3:2181 --create --replication-factor 3 --partitions 1 --topic second
删除topic
./bin/kafka-topics.sh --zookeeper node3:2181 --delete --topic second
发送消息
./bin/kafka-console-producer.sh --broker-list node3:9092 --topic second
消费消息
./bin/kafka-console-consumer.sh --bootstrap-server node3:9092 --from-beginning --topic second
消费者组消费:
修改 consumer.properties 配置文件
# consumer group id
group.id=tzkt
启动生产者
启动消费者
./bin/kafka-console-consumer.sh --bootstrap-server node3:9092 --topic second --consumer.config config/consumer.properties
CDH搭建:https://juejin.im/post/5a55814e518825734859d69a