主服务器完成迁移工作

Frank
Frank
发布于 2021-01-22 / 20 阅读
0
0

主服务器完成迁移工作

由于以后的生活重心不在中国,所以提前将服务器整体从香港阿里云迁出,方便日后的生活工作。
经过了一周的折腾,终于完成了服务器的整体的迁移工作。这中间遇到了许许多多的问题,在这里记录下,以便以后遇到同样的Bug还要问Google。

搭建环境:

1.我使用的是Ubuntu 20.4 。由20.4版本默认不支持rpm包安装,所以在JDK无法安装运行。要先安装RPM

apt install rpm

2.宝塔的JAVA启动管理器之类的千万别用,权限设置乱,配置文件乱,Bug更是让你崩溃。本来是一个方便运维的工具,结果我花了三天的时间来测试他的功能性,最后果断放弃。

3.时区问题。因为很多软件包括JDK安装都会默认匹配服务器时区,这就会导致很多有时间戳的存档因为时区问题导致错误。所以在架设完环境后,先调整时区。

sudo tzselect

然后建立软链接

sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

timedatectl

如果一开始忘记了,那就要修改 Tomcat/bin/catalina.sh 文件

export JAVA_OPTS="$JAVA_OPTS -Duser.timezone=Asia/shanghai"

image.png

4.Tomcat多项目部署

在tomcat目录下创建多个webapps目录,删除webapps目录下的java项目,并删除webapps1目录下原有项目,添加新项目

修改tomcat/conf/server.xml

<!--The connectors can use a shared executor, you can define one or more named thread pools-->

<Connector port="8081" protocol="HTTP/1.1"  
connectionTimeout="20000"  
redirectPort="8443" />

<!-- A "Connector" using the shared thread pool-->

<Engine name="Catalina1" defaultHost="localhost">

<!-- Use the LockOutRealm to prevent attempts to guess user passwords  
           via a brute-force attack -->

<Realm className="org.apache.catalina.realm.LockOutRealm">  
 <!-- This Realm uses the UserDatabase configured in the global JNDI  
             resources under the key "UserDatabase". Any edits  
             that are performed against this UserDatabase are immediately  
             available for use by the Realm. -->  
 <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
               resourceName="UserDatabase"/>  
 </Realm>

<Host name="localhost"  appBase="webapps1"  
unpackWARs="true" autoDeploy="true">
<Context path="/" docBase="Bolo" />  #如果是反代这里要指定Webapps里的目录

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
prefix="localhost_access_log" suffix=".txt"  
pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
</Engine>
</Service>

对于我这种10几年没搞过网络的人,这是一次艰难的迁移过程。所以在这里再次感谢在迁移过程中帮助我的小伙伴。

Bolo作者 adlered
技术大神 大袋鼠


评论