业务开发(四)—— 服务器

0x01、resin缓存、配置

/var/resin/resin-data
/etc/resin/resin.xml

查看resin的状态

service resin status

0x02、服务已经启动,不过一直报错,像是启动job一样

原因是shiro会持续访问redis,而redis并没有启动
启动本地redis

redis-server /etc/redis/6379.conf &

0x03、乱码问题

所有用户生效,/etc/profile.d中加入setlang.sh:
export LC_CTYPE=zh_CN.UTF-8
特定用户生效,~/.bash_profile中加入
export LC_CTYPE=zh_CN.UTF-8

0x04、Tomcat无法启动,关机重启都没有用

Server Tomcat v7.0 Server at localhost failed to start.
直接将tomcat文件夹删掉,重新换一个tomcat配置上去,解决问题。

0x05、resin卡住不动,而且不打印错误信息

当应用控制台不打印信息或找不到有用的报错信息的时候,可以看resin打印出的信息。

0x06、一台服务器上有两个项目,经常项目A能起来,项目B起不了,或者又变成项目A起不来,项目B能起来

停掉tomcat或resin,然后使用ps -ef命令,kill掉java虚拟机进程。

0x07、启动关闭mysql

service mysqld start
service mysqld stop

0x08、 Access denied

>mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
如果数据库的用户是xx,密码是yy则应该输入命令
>mysql -uxx -pyy

0x09、 启动redis

redis-server /etc/redis/6379.conf &

0x10、多个项目启动不成功

Error occurred during initialization of VM
Too small initial heap for new size specified

0x11、查看服务器内存大小

cat /proc/meminfo | grep MemTotal
3922532 kB

说明是3.9G也就是4G内存

0x12、resin配置

<cluster id="xxxx">

      <server-default>
                  <jvm-arg>-Xms1024m</jvm-arg>
                  <jvm-arg>-Xmx2048m</jvm-arg>
                  <jvm-arg>-Xmn512m</jvm-arg>
                  <jvm-arg>-XX:PermSize=256m</jvm-arg>
                  <jvm-arg>-XX:MaxPermSize=512m</jvm-arg>
                  <thread-max>512</thread-max>
                  <socket-timeout>100s</socket-timeout>
                  <keepalive-max>256</keepalive-max>
                  <keepalive-timeout>60s</keepalive-timeout>
      </server-default>

      <server id="server-xxxx" address="127.0.0.1" port="6801">
          <http id="" port="9001"/>
      </server>

      <host-default>
        <web-app-deploy path="/mnt/resin/webapps" expand-preserve-fileset="WEB-INF/work/**" />
      </host-default>


      <host-deploy path="hosts">
        <host-default>
          <resin:import path="host.xml" optional="true"/>
        </host-default>
      </host-deploy>

      <host id="" root-directory="/mnt/resin">
        <web-app id="/" root-directory="/mnt/resin/webapps/dw.cloudmanager"/>
        <stdout-log path="/mnt/resin/log/cm.log"
         rollover-size="5mb" rollover-period="1D"/>
      </host>

      <resin:if test="${resin_doc}">
        <host id="${resin_doc_host}" root-directory="${resin_doc_host}">
          <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>
        </host>
      </resin:if>

  </cluster>

0x13、redis

Protected-mode 是为了禁止公网访问redis cache,加强redis安全的
它启用的条件,有两个:
1) 没有bind IP
2) 没有设置访问密码

 redis.clients.jedis.exceptions.JedisDataException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

首先在配置文件中找

:/password
:/protect

然后重启

ps -ef | grep redis
kill redis进程

启动redis

0x14、resin配置有问题,无法启动

service resin status

查看resin配置哪里出了问题

0x15、知道服务器A的内外网地址,知道服务器B的内网地址,然后知道A和B在同一个局域网中

先用xshell登录到A服务器,再在A服务器上ssh B服务器的内网地址。
上传文件使用rz -be上传

0x16、删除多个文件

rm -rf *.log

0x17、快速查找日志

cat -n platform.log | grep "回调"

0x18、设置root密码

sudo  passwd root 

0x19、查看服务器位数

getconf LONG_BIT

0x20 查看服务器端口被哪个服务占用

lsof -i :端口号
posted @ 2016-10-16 17:04  清泉白石  阅读(433)  评论(0编辑  收藏  举报