安装常用工具
- Ubuntu/Debian
- Centos
sudo apt update && sudo apt install -y wget vim mtr curl telnet lsof git
sudo yum install -y yum-utils wget vim mtr curl telent lsof git
安装jdk
官网下载 https://jdk.java.net/archive/
1、上传到服务器 /opt目录下
#解压缩并重命名
tar -zxvf openjdk-21.0.1_linux-x64_bin.tar.gz
2、配置环境变量
#配置环境变量
vi /etc/profile
#在文件的最后配置如下内容:
export JAVA_HOME=/opt/jdk-21.0.1
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#使配置文件生效
source /etc/profile
#验证
java -version
如果不正确,可能需要退出重新登录
安装maven
官网下载:https://maven.apache.org/download.cgi
1、上传到服务器 /opt目录下
#解压
tar -xzvf apache-maven-3.9.6-bin.tar.gz
2、配置环境变量
#配置环境变量
vi /etc/profile
#在文件的最后配置如下内容(增加MAEN_HOME并修改path)
export M2_HOME=/opt/apache-maven-3.9.6
export PATH=$M2_HOME/bin:$PATH
#使配置文件生效
source /etc/profile
#验证
mvn -v
配置maven私服
vim /opt/apache-maven-3.9.6/conf/settings.xml
在mirrors节点中新增mirror节点:
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
在profiles节点中新增一个profile节点:
<profile>
<id>alimaven</id>
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
在activeProfiles节点中新增一个activeProfile 节点:
<activeProfiles>
<activeProfile>alimaven</activeProfile>
</activeProfiles>
注意:以上代码不要写到注释里,请仔细检查!
API启动
作为规范,我们约定源码全部放在 /opt/source 目录中,jar 放在 /opt/server 中,以下会对目录结构做详细说明。
#创建必要文件夹
mkdir -p /opt/source
#存放源码文件夹
cd /opt/source
- shoptnt
- s2b2c
#克隆后端API源码
git clone https://gitee.com/bbc-se/shoptnt.git
#克隆配置中心
git clone https://gitee.com/bbc-se/config.git
修改配置
启动前,需要修改配置,配置文件位于源码同级的 config 目录: 具体请参考:配置中心指南
cd /opt/source/config
vim /opt/source/config/application-dev.yml
请根据实际环境配置 MySQL、Elasticsearch、Redis、RabbitMQ 等基础服务连接信息。
进入脚本文件夹中:
cd /opt/source/shoptnt
使用默认配置,执行一下启动脚本,即可完成启动
如需个性化部署,请参考脚本启动参数说明:start.sh说明
bash start.sh install
运行目录
源码位置:/opt/source/shoptnt
jar包位置:/opt/server
配置位置:/opt/source/config
日志位置:/opt/server/logs
#克隆源码
git clone https://gitee.com/bbc-se/api.git
#下载config配置文件
git clone https://codeup.aliyun.com/shoptnt/product/sbc/cluster/config.git
#初次编译
cd /opt/source/api
mvn clean install -DskipTests -f pom.xml
验证
当配置中心启动成功后,需要访问以下网址查看配置文件是否有误,(ip替换为物理机IP)
http://ip:8888/a/dev
全部启动成功后,通过以下网址检查API是否成功。
http://ip:7001/doc.html
http://ip:7002/doc.html
http://ip:7003/doc.html
http://ip:7004/doc.html
监控检查各服务节点状态
http://ip:7006
默认用户名密码:admin/admin