IP:192.168.0.139
Admin@!@#$%^
环境:centos7.5,svnserve
1.检查是否已经安装
rpm -qa | grep subversion
如果已经安装过会有如下显示:
2.通过yum命令安装svnserve
yum -y install subversion
3.检查是否安装成功
svnserve --version
4.创建仓库根目录
mkdir -p /home/svn/svnrepos
mkdir : 如果存在上级目录不存在的情况,会无法创建下级目录, 会提出ERROR
mkdir -p :递归创建目录,即使上级目录不存在,会按目录层级自动创建目录
5.创建一个svn仓库
svnadmin create /home/svn/svnrepos/documents
6.查看新建好的仓库目录
仓库目录说明:
hooks目录:放置hook脚步文件的目录
locks目录:用来放置subversion的db锁文件和db_logs锁文件的目录,用来追踪存取文件库的客户端
format目录:是一个文本文件,里边只放了一个整数,表示当前文件库配置的版本号
conf目录:是这个仓库配置文件(仓库用户访问账户,权限)db目录:仓库数据目录
7.修改SVN服务配置文件
vim svnserve.conf
去掉以下配置项的##注释,并且注意顶行不要有空格
anon-access = read # 匿名用户可读,改成none,禁止匿名访问
auth-access = write # 授权用户可写
password-db = passwd # 使用哪个文件作为账号文件
authz-db = authz # 使用哪个文件作为权限文件### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.apache.org/ for more information.
[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = read ###注意前面不要有空格
auth-access = write ###注意前面不要有空格
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd ###注意前面不要有空格
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file. If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz ###注意前面不要有空格
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
realm = My First Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above. Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none
[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 2568.配置账户密码文件
vim passwd
新建一个用户账户:langzhe,密码为langzhe
9.配置访问权限文件
vim authz
新建研发分组DEV_GROUP并且为用户langzhe和DEV_GROUP组配置访问权限
10.修改svnserve的配置文件,指定版本库的路径
vim /etc/sysconfig/svnserve
用来明确-r参数的确切仓库位置
11.启动svn服务
svnserve -d -r /home/svn/svnrepos/document
12.查看SVN服务状态是否正常
ps -ef | grep svn
ps
-e : 显示所有进程
-f : 全格式输出
-a : 显示所有进程
-u : by effective user ID (supports names)
-x : processes w/o controlling ttys netstat -antpl | grep svnserve
netstat常见参数
-a或--all:显示所有选项,默认不显示LISTEN相关
-t或--tcp:仅显示tcp相关选项
-u或--udp:仅显示udp相关选项
-n或--numeric:直接使用ip地址,而不通过域名服务器(拒绝显示别名,能显示数字的全部转化成数字)
-l或--listening:仅列出有在 Listen (监听) 的服務状态
-p或--programs:显示建立相关链接的程序名
-r或--route:显示路由信息,路由表
-e或--extend:显示扩展信息,例如uid等
-s或--statistice:显示网络工作信息统计表(按各个协议进行统计)
-c或--continuous:每隔一个固定时间,执行该netstat命令。
提示:LISTEN和LISTENING的状态只有用-a或者-l才能看到13.确认服务无误后,访问通过客户端访问SVN服务
svn://192.168.0.139/documents
notice:本次部署软件版本仅针对具体项目使用,本文档仅提供单机安装操作命令支撑,具体集群服务部署以及相关配置不包含在本文档范围
部署清单
| 安装软件 | 版本 |
|---|---|
| 操作系统 | Centos7.5 |
| Mysql | 5.7 |
| Redis | 3.2 |
| Nginx | 1.0 |
| RabbitMQ | 3.7.15 |
1.添加yum源
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo2.查看版本库
3.安装docker
sudo yum install docker-ce4.启动docker
sudo systemctl start docker5.开启开机自动启动
sudo systemctl enable docker6.查看docker版本,是否安装成功
docker version1.下载MySQL镜像
docker pull mysql:5.72.使用docker命令启动
docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7参数说明:
-p 3306:3306:将容器的3306端口映射到主机的3306端口
-v /mydata/mysql/conf:/etc/mysql:将配置文件夹挂在到主机
-v /mydata/mysql/log:/var/log/mysql:将日志文件夹挂载到主机
-v /mydata/mysql/data:/var/lib/mysql/:将数据文件夹挂载到主机
-e MYSQL_ROOT_PASSWORD=root:初始化root用户的密码3.进入运行MySQL的容器
docker exec -it mysql /bin/bash4.使用mysql命令打开客户端
mysql -uroot -proot --default-character-set=utf85.创建数据库
create database mall character set utf86.安装上传下载文件插件,并将mall.sql文件上传到Linux服务器上
yum -y install lrzsz7.将mall.sql文件拷贝到mysql容器的/目录下
docker cp mydata/mall.sql mysql:/8.将sql文件导入到数据库
use mall;
source /mall.sql;
9.创建一个anyuan帐号并修改权限,使得任何ip都能访问
grant all privileges on *.* to 'anyuan' @'%' identified by 'saas';
1.下载redis3.2镜像
docker pull redis:3.22.使用docker命令启动
docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-d redis:3.2 redis-server --appendonly yes3.进入redis容器使用redis-cli命令进行连接
docker exec -it redis redis-cli1.下载nginx1.0的镜像
docker pull nginx:1.102.先运行一次容器(为了拷贝配置文件)
docker run -p 80:80 --name nginx \
-v /mydata/nginx/html:/usr/share/nginx/html \
-v /mydata/nginx/logs:/var/log/nginx \
-d nginx:1.103.将容器内的配置文件拷贝到指定目录
docker container cp nginx:/etc/nginx /mydata/nginx/4.修改文件名称
mv nginx conf5.终止并删除容器
docker stop nginx
docker rm nginx6.使用docker命令启动
docker run -p 80:80 --name nginx \
-v /mydata/nginx/html:/usr/share/nginx/html \
-v /mydata/nginx/logs:/var/log/nginx \
-v /mydata/nginx/conf:/etc/nginx \
-d nginx:1.101.下载rabbitmq3.7.15的docker镜像
docker pull rabbitmq:3.7.152.使用docker命令启动
docker run -d --name rabbitmq \
--publish 5671:5671 --publish 5672:5672 --publish 4369:4369 \
--publish 25672:25672 --publish 15671:15671 --publish 15672:15672 \
rabbitmq:3.7.153.进入容器并开启管理功能
docker exec -it rabbitmq /bin/bash
rabbitmq-plugins enable rabbitmq_management4.开启防火墙
firewall-cmd --zone=public --add-port=15672/tcp --permanent
firewall-cmd --reload5.访问地址查看是否安装成功:http://localhost:15672/
默认用户名密码:guest/guest
netstat常见参数
-a或--all:显示所有选项,默认不显示LISTEN相关
-t或--tcp:仅显示tcp相关选项
-u或--udp:仅显示udp相关选项
-n或--numeric:直接使用ip地址,而不通过域名服务器(拒绝显示别名,能显示数字的全部转化成数字)
-l或--listening:仅列出有在 Listen (监听) 的服務状态
-p或--programs:显示建立相关链接的程序名
-r或--route:显示路由信息,路由表
-e或--extend:显示扩展信息,例如uid等
-s或--statistice:显示网络工作信息统计表(按各个协议进行统计)
-c或--continuous:每隔一个固定时间,执行该netstat命令。
提示:LISTEN和LISTENING的状态只有用-a或者-l才能看到用例:查看redis端口服务
ps
-e : 显示所有进程
-f : 全格式输出
-a : 显示所有进程
-u : by effective user ID (supports names)
-x : processes w/o controlling ttys 用例:查看Java或者tomcat相关进程
vim打开文档,命令模式下,输入/加上需要搜索的关键词.例如查找"user"字符串,直接在命令模式下:
/user
按小写字母n键查找下一个匹配项
按大写字母N键查找上一个匹配项
?user从下往上搜索Linux/Unix下一般如果想让某个程序在后台运行,很多都是使用&在程序结尾来让程序自动运行的。比如我们想要让mysql运行在后台:
/usr/local/mysql/bin/mysqld_safe --user=mysql &但是我们很多程序并不象mysqld一样可以做成守护进程,可能我们的程序只是普通程序而已,一般这种程序即使使用 & 结尾,如果终端关闭,那么程序也会被关闭。为了能够后台运行,我们需要使用nohup这个命令,比如我们有个start.sh需要在后台运行,并且希望在后台能够一直运行,那么就使用nohup
nohup /root/start.sh & 1在shell中回车后提示:
[~]$ appending output to nohup.out 1原程序的的标准输出被自动改向到当前目录下的nohup.out文件,起到了log的作用。
**注意:**当shell中提示了nohup成功后还需要按终端上键盘任意键退回到shell输入命令窗口,然后通过在shell中输入exit来退出终端.如果每次在nohup执行成功后直接点关闭程序按钮关闭终端,这时候会断掉该命令所对应得到session,导致nohup对应的进程被通知需要一起shutdown。
docker ps
-a :显示所有的容器,包括未运行的。
-f :根据条件过滤显示的内容。
--format :指定返回值的模板文件。
-l :显示最近创建的容器。
-n :列出最近创建的n个容器。
--no-trunc :不截断输出。
-q :静默模式,只显示容器编号。
-s :显示总的文件大小。docker imagesdocker rm + 容器iddocker rmi + 镜像iddocker exec
-d :分离模式: 在后台运行
-i :即使没有附加也保持STDIN 打开
-t :分配一个伪终端实例:在容器 elasticsearch 中开启一个交互模式的终端
docker exec -it elasticsearch /bin/bash| 技术栈 | 版本号 |
|---|---|
| SpringBoot | 2.2.4.RELEASE |
| Mybatis Generator | 1.3.3 |
| Druid | 1.1.10 |
| PagerHelper | 1.2.10 |
| Swagger-UI | 2.7.0 |
Swagger-UI是HTML, Javascript, CSS的一个集合,可以动态地根据注解生成在线API文档。常用注解
- @Api:用于修饰Controller类,生成Controller相关文档信息
- @ApiOperation:用于修饰Controller类中的方法,生成接口方法相关文档信息
- @ApiParam:用于修饰接口中的参数,生成接口参数相关文档信息
- @ApiModelProperty:用于修饰实体类的属性,当实体类是请求参数或返回结果时,直接生成相关文档信息
整合Swagger-UI
1.添加项目依赖
<!--Swagger-UI API文档生产工具-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>2.添加Swagger-UI的配置
注意:Swagger对生成API文档的范围有三种不同的选择
- 生成指定包下面的类的API文档
- 生成有指定注解的类的API文档
- 生成有指定注解的方法的API文档
/**
* Swagger2API文档的配置
*/
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Bean
public Docket createRestApi(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包下controller生成API文档
.apis(RequestHandlerSelectors.basePackage("com.macro.mall.tiny.controller"))
//为有@Api注解的Controller生成API文档
//.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
//为有@ApiOperation注解的方法生成API文档 //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("SwaggerUI演示")
.description("mall-tiny")
.contact("macro")
.version("1.0")
.build();
}
}3.Controller添加Swagger注解
/**
* 品牌管理Controller
* Created by macro on 2019/4/19.
*/
@Api(tags = "PmsBrandController", description = "商品品牌管理")
@Controller
@RequestMapping("/brand")
public class PmsBrandController {
@Autowired
private PmsBrandService brandService;
private static final Logger LOGGER =LoggerFactory.getLogger(PmsBrandController.class);
@ApiOperation("获取所有品牌列表")
@RequestMapping(value = "listAll", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<PmsBrand>> getBrandList() {
return CommonResult.success(brandService.listAllBrand());
}4.运行项目,访问Swagger-UI接口文档地址
接口地址:http://localhost:8080/swagger-ui.html
RPC:
IPC (进程间通信) ,是在多任务操作系统或联网的计算机之间运行的程序和进程所用的通信技术。有两种类型的进程间通信(IPC)。 LPC(本地过程调用),LPC用在多任务操作系统中,使得同时运行的任务能互相会话。这些任务共享内存空间使任务同步和互相发送信息。 RPC类似于LPC,只是在网上工作。
RPC,即 Remote Procedure Call(远程过程调用),是一个计算机通信协议。 其调用协议通常包含传输协议和序列化协议。该协议允许运行于一台计算机的程序调用另一台计算机的子程序,而程序员无需额外地为这个交互作用编程。说得通俗一点就是:A计算机提供一个服务,B计算机可以像调用本地服务那样调用A计算机的服务。
RPC按传输协议: 可以分为基于HTTP的、基于TCP等。如著名的 [gRPC](grpc / grpc.io) 使用的 http2 协议,也有如dubbo一类的自定义报文的tcp协议。
RPC按报文协议: 可以分为基于XML文本的、基于JSON文本的,二进制的。
**RPC按是否跨平台语言:**可以分为平台专用的,平台中立的。
补充: WebService一般属于基于HTTP的、XML文本的、跨平台(平台中立)的RPC协议。功能完善、体系成熟、支持事务、支持安全机制,广泛应用在金融电信(中国电信一个省级分公司就有几千个WS),传统企业的业务系统,ESB/SOA体系等。缺点:过于复杂,性能不是最优的,互联网用的较少。
HTTP:
Http(超文本传输协议),是一种应用层协议。规定了网络传输的请求格式、响应格式、资源定位和操作的方式等。但是底层采用什么网络传输协议,并没有规定,不过现在都是采用TCP协议作为底层传输协议。
HTTP和RPC的选用:
速度来看,RPC要比http更快,虽然底层都是TCP,但是http协议的信息往往比较臃肿。所谓的效率优势是针对http1.1协议来讲的,http2.0协议已经优化编码效率问题,像grpc这种rpc库使用的就是http2.0协议。http容器的性能测试单位通常是kqps,自定义tpc协议则通常是10kqps到100kqps。
难度来看,RPC实现较为复杂,http相对比较简单。RPC需要满足像调用本地服务一样调用远程服务,也就是对调用过程在API层面进行封装。Http协议没有这样的要求,因此请求、响应等细节需要我们自己去实现。
- 优点:RPC方式更加透明,对用户更方便。Http方式更灵活,没有规定API和语言,跨语言、跨平台
- 缺点:RPC方式需要在API层面进行封装,限制了开发的语言环境。调用端和服务端需要使用相同的技术,要么都hessian,要么都dubbo。
总结:成熟的rpc库相对http容器,更多的是封装了“服务发现”,"负载均衡",“熔断降级”一类面向服务的高级特性。可以这么理解,rpc框架是面向服务的更高级的封装。如果把一个http servlet容器上封装一层服务发现和函数代理调用,那它就已经可以做一个rpc框架了。















