赞
踩
下载、安装Virtual Box https://www.virtualbox.org/wiki/Downloads
下载、安装Vagrant https://www.vagrantup.com/downloads.html
2. vagrant:查看是否安装成功
img
3. vagrant init centos/7:初始化
这里有各种 Linux 镜像 https://app.vagrantup.com/boxes/search,选择自己需要的版本下载即可
初始化后,在当前用户文件夹下会有一个 Vagrantfile 文件
4. vagrant up:启动虚拟机
(第一次运行会下载)
vagrant 下载很慢
使用迅雷下载,然后执行
vagrant box add centos/7 /Users/taylor/personal/setups/CentOS-7-x86_64-Vagrant-1905_01.VirtualBox.box
然后再执行 vagrant up即可,启动完成看到下面的内容,就可以愉快的vagrant ssh登录了
image-20200404210510030
5.修改VB网络地址
创建一个网卡
image-20200404210656606
2.修改Vagrantfile,使在一个网段,比如改成56.10
配置镜像加速器
针对Docker客户端版本大于 1.10.0 的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
第一步```java
sudo mkdir -p /etc/docker
第二步
sudo tee /etc/docker/daemon.json <<-‘EOF’
{
“registry-mirrors”: [“https://lg4db837.mirror.aliyuncs.com”]
}
EOF
第三步
sudo systemctl daemon-reload
第四步
sudo systemctl restart docker
然后宿主机和虚拟机互ping通即可 ping -c 3 xxx.xxx.xxx.xxx 6.docker 安装mysql sudo docker pull mysql:5.7 ```java docker run -p 3306:3306 --name mysql \ -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 \ -d mysql:5.7
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld]
init_connect=’ SET collation_connection = utf8_unicode_ci’
init_connect=’ SET NAMES utf8’
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
7.docker 安装redis
docker pull redis
mkdir -p /mydata/redis/conf
docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf
开发环境
maven配置
搭建工程
添加模块
配置.ignore
数据库设计
Mac上的数据库设计工具
DBeaver
Docker上开机启动
sudo docker update mysql --restart=always
renren-fast数据库
前端环境准备
安装nodejs
image-20200405161809174
npm config set registry http://registry.npm.taobao.org/
image-20200405161858004
报错
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: gyp
failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/Users/arproject/renren-fast-vue/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:311:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command “/usr/local/bin/node” “/Users/arproject/renren-fast-vue/node_modules/node-gyp/bin/node-gyp.js” “rebuild” “–verbose” “–libsass_ext=” “–libsass_cflags=” “–libsass_ldflags=” “–libsass_library=”
gyp ERR! cwd /Users/arproject/renren-fast-vue/node_modules/node-sass
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
https://zhuanlan.zhihu.com/p/105526835
1.安装xcode
2.删除node_modules
3.删除高版本nodejs,安装10.X版本,10.19.0是没问题的
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man//node.}
4.npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
5.npm install
代码生成器
80端口被占用
sudo lsof -n -P | grep :80
sudo apachectl stop
谷粒框架
image-20200406011419045
Nacos配置启动
报错
https://juejin.im/entry/5cd39b4de51d453a59418b8e
删除报错信息中的’/data/nacos/data/derby-data’目录,重新启动。
注册中心 服务发现
1.添加pom依赖
放在gulimall-common中,作为公共服务
com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery2.在application.yml中添加nacos配置
image-20200406172113014
3.将服务注册的注册中心
配置中心
com.atguigu.gulimall.coupon.GulimallCouponApplication
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
命名空间
在nacos界面添加新命名空间
默认使用public命名空间
修改使用命名空间
image-20200406181100706
image-20200406181128637
Feign远程调用
com.atguigu.gulimall.member.GulimallMemberApplication
image-20200406175610142
调用方
com.atguigu.gulimall.member.controller.MemberController
image-20200406175658034
image-20200406172954644
image-20200406175250497
服务方
com.atguigu.gulimall.coupon.controller.CouponController
image-20200406175829343
网关
性能对比
image-20200406191638203
引入common时排除数据库相关
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
报错
spring initializr error
取消代理即可
image-20200406221702649
包冲突
image-20200406221402005
网上查是gateway和web包冲突,解决方案:common的pom替换掉
<?xml version="1.0" encoding="UTF-8"?>
gulimall
com.atguigu.gulimall
0.0.1-SNAPSHOT
4.0.0
<artifactId>gulimall-common</artifactId> <description>每一个微服务公共的依赖,bean,工具类等</description> <dependencies> <!-- mybatis-plus--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.2.0</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.8</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.12</version> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> <!-- 导入mysql驱动 --> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.17</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency> <!-- 服务注册/发现--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <!-- 配置中心来做配置管理--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>2.0.1.Final</version> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>2.1.0.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
路由示例
image-20200407002155467
前端学习
image-20200407002329992
image-20200407002343508
image-20200407002421689
image-20200407002438242
image-20200407002507460
网关路由与路径重写
跨域问题
端口及之前的内容【协议、域名、端口】有任何不同,就不允许获取数据
image-20200407003836180
解决方案
通过Nginx反向代理,转化为同一个域
image-20200407004335000
通过gateway的filter
image-20200407005119095
分类: 分布式高并发实践
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。