目錄
virtualbox的安裝(windows)
vagrant的下載下傳(windows)
使用vagrant在virtualbox中安裝centos7
配置虛拟機的ip位址
在linux當中安裝docker
配置docker阿裡雲的鏡像加速
Docker中安裝mysql
Docker中安裝redis
配置Maven的鏡像和使用jdk1.8版本進行編譯
lombok和mybatisx插件的安裝:
VSCode安裝:
git安裝與配置
項目結建構立和代碼送出碼雲:
virtualbox的安裝(windows)
下載下傳位址:Downloads – Oracle VM VirtualBox
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiI2EzX4xSZz91ZsAzNfRHLGZkRGZkRfJ3bs92YskTMfVmepNHLR1GT1gUYwVjWywUNrFHT1c3VZVTQClGVF5UMR9Fd4VGdsATNfd3bkFGazxSUhxGatJGbwhFT1Y0Mk9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL3gjZ0MTMxI2YlljM4kjNhdDZ0QDMxE2NjZmMzcjNkR2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
下載下傳windows版本,然後傻瓜式安裝就行了,安裝成功後,出現如下頁面
如果我們要使用centos7的話還要去下載下傳核心,比較麻煩,建議使用vagrant從倉庫中拉取鏡像
vagrant的下載下傳(windows)
下載下傳官網:Vagrant by HashiCorp
vagrant安裝也是一個傻瓜式的安裝
安裝完成後:輸入vagrant指令出現如下資訊則安裝成功:
vagrant鏡像的位址:Discover Vagrant Boxes - Vagrant Cloud
使用vagrant在virtualbox中安裝centos7
①初始化centos7檔案
此指令執行完,在對應的C:\WINDOWS\system32下可以找到Vagrantfile檔案 ,這是一個centos7的配置檔案,vagrant就是根據此檔案啟動centos7
②從倉庫中拉取鏡像
vagrant up
③連接配接虛拟機
vagrant ssh
預設是使用賬戶vagrant登入
配置虛拟機的ip位址
如果不固定虛拟機的ip涉及到一個網絡位址轉換-端口換發
以管理者身份打開cmd,輸入ipconfig
找到圖上内容
使用Notepad++打開位于C:\WINDOWS\system32檔案夾下的vagrantfile
找到第35行: # config.vm.network "private_network", ip: "192.168.33.10"
修改并儲存:
重新開機vagrant
vagrant reload
出現了以下問題:
解決方案:
解決Failed to open/create the internal network HostInterfaceNetworking-VirtualBox Host-Only Ethernet A_沐小肥的部落格-CSDN部落格
vagrant up時還出現如下問題:
There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.
Host path: /cygdrive/c/Windows/System32/
Guest path: /vagrant
Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--chmod=ugo=rwX" "--no-perms" "--no-owner" "--no-group" "--rsync-path" "sudo rsync" "-e" "ssh -p 2222 -o LogLevel=FATAL -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i 'C:/WINDOWS/System32/.vagrant/machines/default/virtualbox/private_key'" "--exclude" ".vagrant/" "/cygdrive/c/Windows/System32/" "[email protected]:/vagrant"
Error: rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/BBI": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/BBI.LOG1": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/BBI.LOG2": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/DEFAULT": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/DEFAULT.LOG1": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/DEFAULT.LOG2": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SAM": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SAM.LOG1": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SAM.LOG2": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SECURITY": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SECURITY.LOG1": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SECURITY.LOG2": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SOFTWARE": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SOFTWARE.LOG1": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SOFTWARE.LOG2": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SYSTEM": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SYSTEM.LOG1": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/SYSTEM.LOG2": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/systemprofile/AppData/Local/Microsoft/Windows/Notifications/WPNPRMRY.tmp": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/systemprofile/AppData/Local/Microsoft/Windows/WebCache/V01.log": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/systemprofile/AppData/Local/Microsoft/Windows/WebCache/WebCacheV01.dat": Device or resource busy (16)
rsync: [sender] send_files failed to open "/cygdrive/c/Windows/System32/config/systemprofile/AppData/Local/Microsoft/Windows/WebCache/WebCacheV01.jfm": Device or resource busy (16)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=3.2.3]
出現問題原因分析:
使用vagrant建立虛拟機時,預設會将vagrantfile同級下的所有檔案和目錄都複制到建立的centos7的vagrant目錄下,導緻虛拟機的硬碟爆滿
解決方案:
①打卡C:\WINDOWS\system32中的vagrantfile檔案
②在vagrantfile同級目錄中建立centos7檔案夾
③修改vagrantfile檔案中的配置
config.vm.base_mac = "5254004d77d3"
config.vm.synced_folder "./centos7 ", "/vagrant", type: "rsync"
④執行vagrant init centos/7 指令
⑤執行vagrant reload指令
vagrant reload
參考文章:window 10 使用vagrant 在virtualbox中安裝centos7_zh452647457的部落格-CSDN部落格
再次執行固定虛拟機ip步驟,然後再互相ping,看是否ping通:
在linux當中安裝docker
首先什麼是docker?例如我們在linux中安裝mysql、redis等應用程式需要先下載下傳安裝包,再解壓安裝包、編譯和安裝非常的麻煩,一旦linux作業系統出現什麼問題,我們這些步驟需要重新再來一次。docker是一種虛拟化容器技術,Docker是基于鏡像,可以秒級啟動各種容器。每一種容器都是一個完整運作的環境,容器之間互相隔離。
docker下載下傳位址: Empowering App Development for Developers | Docker
點選Developers->Docs
點選install on CentOS
裡面有安裝文檔,可以跟着安裝文檔走
不推薦使用這個下載下傳,下面有使用aliyun的鏡像下載下傳,下載下傳更快
①解除安裝舊版本的docker,如果之前沒安裝過此步驟可以跳過
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
②設定存儲倉庫
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
③安裝docker引擎
sudo yum install docker-ce docker-ce-cli containerd.io
由于鏡像在國外是以安裝的速度非常慢,可以使用aliyun的鏡像進行一個安裝(推薦使用這個安裝)
①解除安裝之前的版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
②設定存儲庫
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 //下載下傳安裝所需要的的依賴
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo //修改鏡像拉取的位址
③安裝dokcer
sudo yum install docker-ce docker-ce-cli containerd.io
④啟動docker
sudo systemctl start docker
⑤檢視本地已下載下傳的鏡像
sudo docker images
⑥配置docker開機自啟動
sudo systemctl enbale docker
重新開機虛拟機之後檢視确實開機自啟動了
docker鏡像倉庫的位址:Docker Hub
docker拉取鏡像都是從docker hub中拉取鏡像的,這是個國外網站拉取鏡像的速度會比較慢。是以,需要配置阿裡雲的鏡像加速
配置docker阿裡雲的鏡像加速
阿裡雲位址:阿裡雲-上雲就上阿裡雲
①登入(說明:沒有注冊過的需要先注冊一下)
②點選右上角控制台
③ 點選左上角橙色圖示
④在産品與服務中找到容器服務,點選容器服務中的容器鏡像服務
⑤點選鏡像工具中的鏡像加速器 ,點選centOS
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://k92cvpes.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
⑥執行上述指令
Docker中安裝mysql
①在docker hub中搜尋mysql鏡像,點選标簽(tags中有mysql的各個版本,我們下載下傳5.7的版本)
②下載下傳mysql鏡像檔案
③ 建立執行個體并啟動
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
參數說明:
docker首先需要從倉庫中拉取鏡像,然後以容器的方式運作鏡像,容器其實就是一個小的linux。是以,為了通路和配置的友善,需要将端口号和配置檔案進行一個映射。
映射都是從後往前映射,前是linux中的,後是容器中
-p 3306:3306 :将容器中的mysql端口号映射到linux中的端口号,這樣我們可以直接通過linux的端口通路
-v /mydata/mysql/log:/var/log/mysql :将容器中的日志檔案映射到linux中,通路/mydata/mysql/log就相當于通路容器中的:/var/log/mysql
-v /mydata/mysql/data:/var/lib/mysql :将容器中的日志檔案映射到linux中,通路/mydata/mysql/data相當于通路容器中的/var/lib/mysql
-v /mydata/mysql/conf:/etc/mysql :将容器中的日志檔案映射到linux中,通路/mydata/mysql/conf相當于通路/etc/mysql
-e MYSQL_ROOT_PASSWORD=root :初始化root使用者的密碼
-d mysql:5.7 :以mysql:5.7版本鏡像啟動
進入容器的bash界面:
docker exec -it 容器名/id /bin/bash
可以看出容器确實就是像一個小linux一樣,我們可以使用資料庫管理工具進行一個連接配接測試
④修改mysql的配置檔案
[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
⑤重新開機docker中的mysql容器
docker update mysql --restart=always
⑥docker啟動時自動啟動mysql容器
docker update mysql --restart=always
Docker中安裝redis
①拉取redis鏡像
②建立執行個體并啟動
說明:在容器的etc/redis下并沒有redis.conf檔案,是以,挂載的時候會認為mydata/redis/conf中redis.conf是個檔案,是以要先建立mydata/redis/conf中redis.conf檔案
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/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
進入redis的用戶端
docker exec -it redis redis-cli
redis預設不持久話,是以重新開機redis容器時,資料就不在了,進行一個redis的持久化配置
vi mydata/redis/conf/redis.conf
③設定docker啟動時啟動redis容器
docker update redis --restart=always
配置Maven的鏡像和使用jdk1.8版本進行編譯
①打開Maven安裝路徑下的conf檔案下的settings.xml
jar包的存儲位址:
配置阿裡雲的鏡像倉庫:
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
配置jdk1.8編譯:
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
②在idea中配置Maven
點選file->Settings->Build,Execution,Deployment->Build Tools ->Maven
lombok和mybatisx插件的安裝:
file->Settings->Plugins
VSCode安裝:
下載下傳網址:https://code.visualstudio.com/
點選擴充
安裝插件:
①Auto Close Tag ②Auto Rename Tag ③Chinese ④ESLint ⑤HTML CSS Support ⑥HTML Snippets ⑦JavaScript(ES6) code snippets ⑧Live Server ⑨Vetur ⑩Vue 2 Snippets ①open in browser
git安裝與配置
下載下傳位址:Git
①點選下載下傳
②注冊碼雲
位址:Gitee - 基于 Git 的代碼托管和研發協作平台
③配置git,進入git bash(點選滑鼠右鍵)
#配置使用者名
git config --global user.name "username"
#配置郵箱
git config --global user.email "郵箱位址"
④配置ssh免密登入
#生成秘鑰,連續三次回車
ssh-keygen -t rsa -C "[email protected]"
#檢視秘鑰
cat ~/.ssh/id_rsa.pub
⑤登入進入gitee,在設定裡面找到SSH KEY将秘鑰内容複制進去
⑥測試是否成功
項目結建構立和代碼送出碼雲:
①建立倉庫
②完成一下配置
③點選克隆下載下傳,複制HTTPS的URL
④idea中下載下傳git插件
⑤設定項目的版本控制,輸入複制的URL(父項目的設定)
⑥使用spring Initializr建立商品服務、訂單服務、會員服務、倉儲服務、優惠券服務
·微服務項目都需要web依賴,整合springmvc和内嵌servlet
·服務與服務之間的調用,設計openfeign依賴
使用的是阿裡雲的服務路徑,spring的在國外會通路不到
⑦添加父項目的pom檔案,并且在使用Maven管理
<modelVersion>4.0.0</modelVersion>
<groupId>com.atguigu.gulimall</groupId>
<artifactId>gulimall</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>gulimall</name>
<description>聚合服務</description>
<packaging>pom</packaging>
<modules>
<module>product</module>
<module>order</module>
<module>ware</module>
<module>member</module>
<module>coupon</module>
</modules>
⑧ 在父項目中的gitignore檔案中忽略不必要的傳輸檔案
**/mvnw
**/mvnw.cmd
**/.mvn
.idea
**/.gitignore
**/target/
⑨ 将項目push到碼雲倉庫中