-
部署spring-boot 到服务器
mvn clean install -DskipTests
cd old/publication/target
java -jar bebase-old-publication-0.0.1-SNAPSHOT.jar
scp bebase-old-publication-0.0.1-SNAPSHOT.jar root@192.168.0.100:/opt/pub.jar
ssh root@192.168.0.100
service pub restart
tail -f /var/log/pub.log
-
遇到的问题
1、软连接pub没有指向这个bebase-old-publication-0.0.1-SNAPSHOT.jar
进入软连接文件夹
cd /etc/init.d
ll
发现pub -> /projects/pub.jar
于是删除pub
rm pub
创建新的软连接 指向对应的pub.jar
ln -s /opt/pub.jar /etc/init.d/pub
2、服务运行不起来
发现服务器上的配置自动识别的test-boot的环境,然而并不能成功启动
修改配置文件,pub.conf , 成功。
3、启动成功,但是外部访问测试环境的时候,不打印日志
手动在服务器上通过curl 来访问
curl http://api-online.test.boxfish.cn/user/me?access_token=admin 有返回结果,但是不打印日志
curl http://localhost:3200/user/me?access_token=admin 有返回结果,打印日志
分析一:有可能是本服务器的域名绑定对应不上???
原因:nginx 没有修改
cd /etc/nginx
ll
cd conf.d
vi api.conf
server {
listen 80;
server_name api-online.test.boxfish.cn api.online.test.boxfish.cn api.boxfish.cn api.test.boxfish.cn api.boxfishedu.com;
# location /bebase {
# proxy_pass http://127.0.0.1:8080/pub/bebase;
# index index.html index.htm;
# }
# location / {
# proxy_pass http://127.0.0.1:8080/pub/;
# index index.html index.htm;
# }
location / {
proxy_pass http://0.0.0.0:3200/;
proxy_http_version 1.1;
proxy_set_header Upgrade http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Hosthost;
proxy_cache_bypass http_upgrade; proxy_set_header x-forwarded-port 80; } location /bebase { proxy_pass http://0.0.0.0:3200/bebase; proxy_http_version 1.1; proxy_set_header Upgradehttp_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host host; proxy_cache_bypasshttp_upgrade;
proxy_set_header x-forwarded-port 80;
}
}
nginx -t
nginx -s reload
-
切换tomcat和springboot时,一定要改nginx
tomcat日志位置:
tail -1000f /usr/local/tomcat/logs/catalina-daemon.out
备注:
步骤二的排查解决过程的操作记录:
服务器端:
service tomcat7 stop
service pub restart
tail -f /var/log/pub.log
ps -ef|grep java
service tomcat7 status
cd /usr/local
ls
cd tomcat
ls
cd webapps
cd /etc/init.d
lsof -i:3200
service pub status
cd /root/projects
ll
cat pub.conf
cp pub.conf /opt
cd /etc/init.d
rm pub
ln -s /opt/pub.jar /etc/init.d/pub
cd /opt
vi pub.conf
service pub run
java -version
service pub run
cat pub.conf
vi pub.conf
service pub run
service pub start
service pub status
tail -f /var/log/pub.log
lsof -i:3200
本机:
java -jar bebase-old-publication-0.0.1-SNAPSHOT.jar
mv bebase-old-publication-0.0.1-SNAPSHOT.jar pub.jar
scp pub.jar root@xxx.xx.xx.209:/opt
java -jar pub.jar