Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
5f1c39bb
"src/main/vscode:/vscode.git/clone" did not exist on "d70f2eb16bdb716ee89886fb99e320e6745fbe77"
Commit
5f1c39bb
authored
Jul 30, 2018
by
Junling Bu
Browse files
deploy再次调整
parent
13bd538a
Changes
11
Hide whitespace changes
Inline
Side-by-side
deploy/.gitignore
View file @
5f1c39bb
/litemall-admin/dist.tar
/litemall-db/litemall_schema.sql
/db/litemall.sql
/litemall-db/litemall_table.sql
/litemall/litemall.jar
/litemall-db/litemall_data.sql
/litemall-api/litemall-admin-api.jar
/litemall-api/litemall-wx-api.jar
\ No newline at end of file
deploy/README.md
View file @
5f1c39bb
## deploy
1.
项目进一步打包到deploy文件夹中:
### 项目打包
*
litemall-wx-api模块编译得到的litemall-wx-api-0.1.0-exec.jar 保存到deploy的litemall-api文件夹中,同时重命名成litemall-wx-api.jar
*
litemall-admin-api模块编译得到的litemall-admin-api-0.1.0-exec.jar 保存到deploy的litemall-api文件夹中,同时重命名成litemall-admin-api.jar
*
litemall-admin模块编译以后,把dist文件夹压缩,然后放到deploy的litemall-admin文件夹中。
*
litemall-db模块的sql文件拷贝到deploy的litemall-db文件夹中。
2.
使用FileZilla把deploy整个文件夹上传到云主机的/home/ubuntu文件夹中
1.
在主机或者开发机打包项目到deploy;
```
cd litemall
cat ./litemall-db/sql/litemall_schema.sql > ./deploy/db/litemall.sql
cat ./litemall-db/sql/litemall_table.sql >> ./deploy/db/litemall.sql
cat ./litemall-db/sql/litemall_data.sql >> ./deploy/db/litemall.sql
cd ./litemall-admin
cnpm install
cnpm run build:dep
cd ..
mvn clean package
cp -f ./litemall-all/target/litemall-all-*-exec.jar ./deploy/litemall/litemall.jar
```
这里的工作是:
1.
把数据库文件拷贝到deploy/db文件夹
2.
编译litemall-admin项目
3.
编译litemall-all模块,同时把litemall-admin编译得到的静态文件拷贝到
litemall-all模块的static目录
2.
修改litemall文件夹下面的
*
.yml外部配置文件,当litemall-all模块启动时会
加载外部配置文件,而覆盖默认jar包内部的配置文件。
例如,配置文件中一些地方需要设置成远程主机的IP地址
此时deploy部署包结构如下:
3.
使用PuTTY登录云主机
*
bin
4.
如果开发者没有部署litemall数据库,可以运行以下命令:
存放远程主机运行的脚本,包括deploy.sh脚本和reset.sh脚本
```bash
*
db
cd deploy
mysql -h localhost -u root -p123456
source ./litemall-db/litemall_schema.sql
use litemall;
source ./litemall-db/litemall_table.sql
source ./litemall-db/litemall_data.sql
```
注意,123456是开发者所设置的MySQL管理员密码
警告:
> litemall_schema.sql会尝试删除litemall数据库然后重建一个新的数据。
5.
运行脚本部署运行
存放litemall数据库文件
```bash
*
litemall
sudo ./deploy/bin/deploy.sh
```
存放远程主机运行的代码,包括litemall-all二进制可执行包和litemall外部配置文件
*
util
存放开发主机运行的脚本,包括package.sh脚本和lazy.sh脚本。
由于是本地开发主机运行,因此开发者可以不用上传到远程主机。
6.
测试部署是否成功
### 项目部署
请确保云主机的安全组已经允许相应的端口(见1.5.3.1);
然后测试是否部署成功(xxx.xxx.xxx.xxx是云主机IP):
1.
远程主机环境(MySQL和JDK1.8)已经安装好,请确保云主机的安全组已经允许相应的端口。
2.
导入db/litemall.sql
```
bash
cd
/home/ubuntu/deploy/db
mysql
-h
localhost
-u
$ROOT
-p
$PASSWORD
< litemall.sql
```
3.
启动服务
```
bash
sudo
service litemall stop
sudo ln
-f
-s
/home/ubuntu/deploy/litemall/litemall.jar /etc/init.d/litemall
sudo
service litemall start
```
```
http://xxx.xxx.xxx.xxx:8082/wx/index/index
4.
测试是否部署成功(xxx.xxx.xxx.xxx是云主机IP):
http://xxx.xxx.xxx.xxx:8083/admin/index/index
```
http://xxx.xxx.xxx.xxx:8080/wx/index/index
http://xxx.xxx.xxx.xxx:8080/admin/index/index
http://xxx.xxx.xxx.xxx:8080/#/login
http://xxx.xxx.xxx.xxx:8080/#/login
```
```
7.
部署
脚本
### 项目辅助
脚本
为了简化步骤1和步骤2,完成了deploy/util/package.sh上传脚本和deploy/util/lazy.sh部署脚本,
在前面的项目打包和项目部署中都是采用手动命令来部署。
这里可以写一些脚本简化:
注意:
> 1. 开发者需要在deploy/util/package.sh和deploy/util/lazy.sh中设置相应的云主机登录账号和密钥文件路径。
*
util/packet.sh
> 2. 开发者需要在deploy/bin/reset.sh设置云主机的MySQL的root登录账户。
> 3. 请先执行1.5.1中上述步骤,确保部署环境成功。
在开发主机运行可以自动项目打包
* package.sh
*
util/lazy.sh
在开发主机运行可以自动项目打包、项目上传远程主机、自动登录系统执行项目部署脚本。
该脚本会自动把当前项目Spring Boot项目打包和Vue项目打包工作,然后复制到deploy文件夹中。
注意:
> 1. 开发者需要在util/lazy.sh中设置相应的远程主机登录账号和密钥文件路径。
*
lazy.sh
> 2. 开发者需要在bin/reset.sh设置远程主机的MySQL的root登录账户。
该脚本会调用package.sh打包项目,然后上传deploy文件夹到云主机,最后ssh登录远程主机执行bin下面的deploy.sh脚本。
*
bin/deploy.sh
\ No newline at end of file
在远程主机运行可以自动部署服务
*
bin/reset.sh
在远程主机运行可以自动项目导入数据、删除本地上传图片、再执行bin/deploy.sh部署服务。
注意:
> 开发者需要在bin/reset.sh设置远程主机的MySQL的root登录账户。
总结,当开发者设置好配置信息以后,可以在本地运行lazy.sh脚本自动一键部署:
```
bash
cd
litemall
./deploy/util/lazy.sh
```
不过由于需要设置的信息会包含敏感安全信息,强烈建议开发者参考这里的deploy文件夹,
然后实现自己的deploy文件夹,妥善处置外部配置文件和脚本中的敏感安全信息!!!
\ No newline at end of file
deploy/bin/deploy.sh
View file @
5f1c39bb
#!/bin/bash
#!/bin/bash
# 请注意
# 本脚本的作用是停止当前Spring Boot应用,然后再次部署
# 1. 本脚本的作用是停止当前Spring Boot应用,然后再次部署
sudo
service litemall stop
# 2. 解压dist.tar到/home/ubuntu/deploy/litemall-admin/dist,
sudo ln
-f
-s
/home/ubuntu/deploy/litemall/litemall.jar /etc/init.d/litemall
# 而这个目录也正是tomcat或者nginx所配置静态文件目录的路径(见1.5.3.5节)
sudo
service litemall start
\ No newline at end of file
#部署litemall-admin静态文件应用
cd
/home/ubuntu/deploy/litemall-admin
rm
-rf
dist
mkdir
dist
tar
-zxvf
dist.tar
-C
dist
#部署三个Spring Boot应用
#如果服务已经启动,则尝试停止
sudo
service litemall-wx-api stop
sudo
service litemall-admin-api stop
#部署Spring Boot应用成服务
sudo ln
-f
-s
/home/ubuntu/deploy/litemall-api/litemall-wx-api.jar /etc/init.d/litemall-wx-api
sudo ln
-f
-s
/home/ubuntu/deploy/litemall-api/litemall-admin-api.jar /etc/init.d/litemall-admin-api
#启动服务
sudo
service litemall-wx-api restart
sudo
service litemall-admin-api restart
# 如果静态文件是通过tomcat来服务,则tomcat8服务最好也再启动
#sudo service tomcat8 stop
#sudo service tomcat8 start
\ No newline at end of file
deploy/bin/reset.sh
View file @
5f1c39bb
...
@@ -18,15 +18,12 @@ then
...
@@ -18,15 +18,12 @@ then
exit
-1
exit
-1
fi
fi
cd
/home/ubuntu/deploy/litemall-db
# 导入数据
cat
litemall_schema.sql
>
db.sql
cd
/home/ubuntu/deploy/db
cat
litemall_table.sql
>>
db.sql
mysql
-h
localhost
-u
$ROOT
-p
$PASSWORD
< litemall.sql
cat
litemall_data.sql
>>
db.sql
mysql
-h
localhost
-u
$ROOT
-p
$PASSWORD
< db.sql
rm
db.sql
# 删除storage文件夹内文件
# 删除storage文件夹内文件
cd
/home/ubuntu/deploy/litemall
-api
/storage
cd
/home/ubuntu/deploy/litemall/storage
rm
-f
./
**
rm
-f
./
**
# 重新部署服务
# 重新部署服务
...
...
deploy/litemall/application-admin.yml
0 → 100644
View file @
5f1c39bb
deploy/litemall/application-core.yml
0 → 100644
View file @
5f1c39bb
litemall
:
# 开发者应该设置成自己的wx相关信息
wx
:
app-id
:
wxa5b486c6b918ecfb
app-secret
:
e04004829d4c383b4db7769d88dfbca1
mch-id
:
111111
mch-key
:
xxxxxx
notify-url
:
http://122.152.206.172:8080/wx/order/pay-notify
#通知相关配置
notify
:
mail
:
# 邮件通知配置,邮箱一般用于接收业务通知例如收到新的订单,sendto 定义邮件接收者,通常为商城运营人员
enable
:
false
host
:
smtp.exmail.qq.com
username
:
ex@ex.com.cn
password
:
XXXXXXXXXXXXX
sendfrom
:
ex@ex.com.cn
sendto
:
ex@qq.com
# 短消息模版通知配置
# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
sms
:
enable
:
false
appid
:
111111111
appkey
:
xxxxxxxxxxxxxx
template
:
-
name
:
paySucceed
templateId
:
156349
-
name
:
captcha
templateId
:
156433
-
name
:
ship
templateId
:
158002
-
name
:
refund
templateId
:
159447
# 微信模版通知配置
# 微信模版用于通知客户或者运营者,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
wx
:
enable
:
false
template
:
-
name
:
paySucceed
templateId
:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
name
:
captcha
templateId
:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
name
:
ship
templateId
:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-
name
:
refund
templateId
:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# 快鸟物流查询配置
express
:
enable
:
false
appId
:
"
XXXXXXXXX"
appKey
:
"
XXXXXXXXXXXXXXXXXXXXXXXXX"
vendors
:
-
code
:
"
ZTO"
name
:
"
中通快递"
-
code
:
"
YTO"
name
:
"
圆通速递"
-
code
:
"
YD"
name
:
"
韵达速递"
-
code
:
"
YZPY"
name
:
"
邮政快递包裹"
-
code
:
"
EMS"
name
:
"
EMS"
-
code
:
"
DBL"
name
:
"
德邦快递"
-
code
:
"
FAST"
name
:
"
快捷快递"
-
code
:
"
ZJS"
name
:
"
宅急送"
-
code
:
"
TNT"
name
:
"
TNT快递"
-
code
:
"
UPS"
name
:
"
UPS"
-
code
:
"
DHL"
name
:
"
DHL"
-
code
:
"
FEDEX"
name
:
"
FEDEX联邦(国内件)"
-
code
:
"
FEDEX_GJ"
name
:
"
FEDEX联邦(国际件)"
# 对象存储配置
storage
:
# 当前工作的对象存储模式,分别是local、aliyun、tencent
active
:
local
# 本地对象存储配置信息
local
:
storagePath
:
storage
address
:
http://122.152.206.172:8080/wx/storage/fetch/
port
:
8081
# 阿里云对象存储配置信息
aliyun
:
endpoint
:
oss-cn-shenzhen.aliyuncs.com
accessKeyId
:
111111
accessKeySecret
:
xxxxxx
bucketName
:
xxxxxx
# 腾讯对象存储配置信息
# 请参考 https://cloud.tencent.com/document/product/436/6249
tencent
:
secretId
:
111111
secretKey
:
xxxxxx
region
:
xxxxxx
bucketName
:
xxxxxx
\ No newline at end of file
deploy/litemall/application-db.yml
0 → 100644
View file @
5f1c39bb
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
supportMethodsArguments
:
true
params
:
count=countSql
spring
:
datasource
:
druid
:
url
:
jdbc:mysql://localhost:3306/litemall?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&verifyServerCertificate=false&useSSL=false
driver-class-name
:
com.mysql.jdbc.Driver
username
:
litemall
password
:
litemall123456
initial-size
:
10
max-active
:
50
min-idle
:
10
max-wait
:
60000
pool-prepared-statements
:
true
max-pool-prepared-statement-per-connection-size
:
20
validation-query
:
SELECT 1 FROM DUAL
test-on-borrow
:
false
test-on-return
:
false
test-while-idle
:
true
time-between-eviction-runs-millis
:
60000
filters
:
stat,wall,log4j
deploy/litemall/application-wx.yml
0 → 100644
View file @
5f1c39bb
deploy/litemall/application.yml
0 → 100644
View file @
5f1c39bb
spring
:
profiles
:
active
:
db, core, admin, wx
message
:
encoding
:
UTF-8
server
:
port
:
8080
logging
:
level
:
root
:
ERROR
org.springframework
:
ERROR
org.mybatis
:
ERROR
org.linlinjava.litemall.core
:
ERROR
org.linlinjava.litemall.db
:
ERROR
org.linlinjava.litemall.admin
:
ERROR
org.linlinjava.litemall.wx
:
ERROR
org.linlinjava.litemall
:
ERROR
\ No newline at end of file
deploy/util/lazy.sh
View file @
5f1c39bb
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
# 本脚本的作用是
# 本脚本的作用是
# 1. 项目打包
# 1. 项目打包
# 2. 上传云主机
# 2. 上传云主机
# 3. 远程登录云主机并执行
deploy
脚本
# 3. 远程登录云主机并执行
reset
脚本
# 请设置云主机的IP地址和账户
# 请设置云主机的IP地址和账户
# 例如 ubuntu@122.152.206.172
# 例如 ubuntu@122.152.206.172
...
@@ -34,10 +34,12 @@ cd $LITEMALL_HOME
...
@@ -34,10 +34,12 @@ cd $LITEMALL_HOME
./deploy/util/package.sh
./deploy/util/package.sh
# 上传云主机
# 上传云主机
cd
$LITEMALL_HOME
scp
-i
$ID_RSA
-r
./deploy
$REMOTE
:/home/ubuntu/
scp
-i
$ID_RSA
-r
./deploy
$REMOTE
:/home/ubuntu/
# 远程登录云主机并执行
deploy
脚本
# 远程登录云主机并执行
reset
脚本
ssh
$REMOTE
-i
$ID_RSA
<<
eeooff
ssh
$REMOTE
-i
$ID_RSA
<<
eeooff
sudo ./deploy/bin/deploy.sh
cd /home/ubuntu
sudo ./deploy/bin/reset.sh
exit
exit
eeooff
eeooff
\ No newline at end of file
deploy/util/package.sh
View file @
5f1c39bb
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
# 请注意
# 请注意
# 本脚本的作用是把本项目编译的结果保存到deploy文件夹中
# 本脚本的作用是把本项目编译的结果保存到deploy文件夹中
# 1. 把项目数据库文件拷贝到
litemall-
db
# 1. 把项目数据库文件拷贝到
deploy/
db
# 2. 编译litemall-admin
,然后打包到litemall-admin
# 2. 编译litemall-admin
# 3. 编译
后台服务
模块,然后拷贝到litemall
-api
# 3. 编译
litemall-all
模块,然后拷贝到
deploy/
litemall
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
>
/dev/null
&&
pwd
)
"
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
>
/dev/null
&&
pwd
)
"
cd
$DIR
/../..
cd
$DIR
/../..
...
@@ -12,24 +12,17 @@ LITEMALL_HOME=$PWD
...
@@ -12,24 +12,17 @@ LITEMALL_HOME=$PWD
echo
"LITEMALL_HOME
$LITEMALL_HOME
"
echo
"LITEMALL_HOME
$LITEMALL_HOME
"
# 复制数据库
# 复制数据库
c
p
-f
.
/litemall-db/sql/litemall_schema.sql
./deploy/litemall-
db/litemall
_schema
.sql
c
at
$LITEMALL_HOME
/litemall-db/sql/litemall_schema.sql
>
$LITEMALL_HOME
/deploy/
db/litemall.sql
c
p
-f
.
/litemall-db/sql/litemall_table.sql
./deploy/litemall-
db/litemall
_table
.sql
c
at
$LITEMALL_HOME
/litemall-db/sql/litemall_table.sql
>>
$LITEMALL_HOME
/deploy/
db/litemall.sql
c
p
-f
.
/litemall-db/sql/litemall_data.sql
./deploy/litemall-
db/litemall
_data
.sql
c
at
$LITEMALL_HOME
/litemall-db/sql/litemall_data.sql
>>
$LITEMALL_HOME
/deploy/
db/litemall.sql
cd
.
/litemall-admin
cd
$LITEMALL_HOME
/litemall-admin
# 安装阿里node镜像工具
# 安装阿里node镜像工具
npm
install
-g
cnpm
--registry
=
https://registry.npm.taobao.org
npm
install
-g
cnpm
--registry
=
https://registry.npm.taobao.org
# 安装node项目依赖环境
# 安装node项目依赖环境
cnpm
install
cnpm
install
cnpm run build:dep
cnpm run build:dep
cd
..
# 压缩litemall-admin应用
tar
-zcvf
./deploy/litemall-admin/dist.tar
-C
./litemall-admin/dist
.
# 复制三个Spring Boot应用
cd
$LITEMALL_HOME
# 需要注意的是target目录里面存在两种jar,一种是当前模块纯编译代码的jar,另外一种是包含依赖库的可执行jar,
mvn clean package
# 这里我们需要的是可执行jar
cp
-f
$LITEMALL_HOME
/litemall-all/target/litemall-all-
*
-exec
.jar
$LITEMALL_HOME
/deploy/litemall/litemall.jar
mvn clean
\ No newline at end of file
mvn package
cp
-f
./litemall-wx-api/target/litemall-wx-api-
*
-exec
.jar ./deploy/litemall-api/litemall-wx-api.jar
cp
-f
./litemall-admin-api/target/litemall-admin-api-
*
-exec
.jar ./deploy/litemall-api/litemall-admin-api.jar
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment