发表于: 2017-07-31 23:52:52

2 1016


今天完成的事情:

1. 学习把项目打成war包

2.分别用TomCat,jetty,resin运行


明天计划的事情:

1.让代码能在正确服务器运行起来

2. 学习脚本语言


遇到的问题:

1. 服务器的mysql这两天光出毛病,今天终于GG了,死活启动不了

查看mysql日志文件
less /var/log/mysqld.log
2017-07-31T05:18:26.775662Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2017-07-31T05:18:26.775674Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2017-07-31T05:18:26.775688Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-07-31T05:18:26.775702Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-07-31T05:18:26.775707Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-07-31T05:18:26.775712Z 0 [ERROR] Failed to initialize plugins.
2017-07-31T05:18:26.775716Z 0 [ERROR] Aborting


内存不足不能分配缓存空间
看一下内存情况

free


试了下,mysql和resin只开一个就有380M左右内存,如果同时开启,只剩5M,没办法,在买一个服务器,原来的就当成数据库使用



2. 在服务器不能运行项目,同样的代码,同样的配置文件,同样的容器resin和版本,在本地就就可以,查看是因为,服务器运行时不会生成work文件夹,

    只有在默认目录下运行才生成work文件夹,不能指定文件目录,同样的配置文件在本地就行。百思不得其解



3. 还是同样的代码,在jetty执行修改的url,   操作后不能自动跳转到成功页面,但代码和数据库却成功执行操作,而resin同样的请求方式和数据,  却接受不到数据,为空。

在插入数据时,jetty可以执行判断是否已经存在数据的代码,但resin却不执行,返回错误信息,显示数据库已经有了该信息。

明天计划独立安装jetty和tomcat,尝试运行war包比对。



收获:

1. 学习把项目打成war包

project structure-->artifact-->左上角加号-->web application artifact-->选择bulid on make,  OK



2. 配置resin在指定目录运行项目

在etc/resin得resin.xml文件中配置如下

    <host-default>
      <!-- creates the webapps directory for .war expansion -->
      <web-app-deploy path="webapps"
                      expand-preserve-fileset="WEB-INF/work/**"
                      multiversion-routing="${webapp_multiversion_routing}"
                      path-suffix="${elastic_webapp?resin.id:''}"/>
                    <character-encoding>UTF-8</character-encoding><!-- 设置编码为UTF-8 -->
    </host-default>
    <!-- auto virtual host deployment in hosts/foo.example.com/webapps -->
    <host-deploy path="hosts">
      <host-default>
        <resin:import path="host.xml" optional="true"/>
      </host-default>
    </host-deploy>
    <!-- the default host, matching any host name -->
    <host id="" root-directory=".">
      <!--
         - webapps can be overridden/extended in the resin.xml
        -->
      <web-app id="/" root-directory="webapps/ROOT"/>
      <web-app id="/task3" root-directory="/data/task3-home/springmvcweb"/>
    </host>



红色的为关键配置

最后的红色中root-directory="/data/task3-home/springmvcweb" 为war包解压的路径,自定义的路径

运行时的url为:http://你的ip:端口/task3/代码中的接口路径


 

参考资料:

在linux查看内存的大小




PS:这两天就坑到这了,为什么同样的代码,配置文件容器,本地和服务器运行效果就不一样。

同样的代码,请求方式和数据,不同的容器结果也不同



返回列表 返回列表
评论

    分享到