最近工作中遇到的8个问题(2019-07-27)

# 工作问题
1.测试服务器,每次重启后时间不知为何时间都会重置,并且时区像是美国时间。

安装ntpdate工具
yum -y install ntp ntpdate

设置系统时间与网络时间同步
ntpdate cn.pool.ntp.org

将系统时间写入硬件时间
hwclock --systohc

2. 获得某个程序的端口号
ps -ef | grep system-release-1.0.0.jar | grep -v grep | awk '{print $2}'
第1步,ps -ef | grep system-release-1.0.0..jar
获得某个项目的线程信息。

grep -v grep
排除grep本身的

grep -v 可以实现 NOT 操作。 -v 选项用来实现反选匹配的( invert match)。如,可匹配得到除下指定pattern外的所有lines。
参考资料:https://www.jianshu.com/p/4ec50fdaf388

www       3142  2491 99 16:36 pts/0    00:01:15 java -jar system-release-1.0.0.jar
awk '{print $2}'
获得第2个参数,3142就是想要的线程数/进程数

3.如果项目中用了Shiro实现权限控制(虽然本人不喜欢用这玩意)

 //对swagger2相关接口放行,5个配置
    filterChainDefinitionMap.put("/doc.html", "anon");
    filterChainDefinitionMap.put("/swagger-ui.html", "anon");
    filterChainDefinitionMap.put("/swagger-resources/**", "anon");
    filterChainDefinitionMap.put("/v2/api-docs/**", "anon");
    filterChainDefinitionMap.put("/webjars/springfox-swagger-ui/**", "anon");
 

http://localhost:18004/swagger-ui.html   Swagger官方UI

http://localhost:18004/doc.html   第三方Bootstarp皮肤的UI

4.zookeeper启动占用8080端口
zookeeper最近的版本中有个内嵌的管理控制台是通过jetty启动,也会占用8080 端口。
通过查看zookeeper的官方文档,发现有3种解决途径:

(1).删除jetty。
(2)修改端口。
修改方法的方法有两种,一种是在启动脚本中增加 -Dzookeeper.admin.serverPort=你的端口号.一种是在zoo.cfg中增加admin.serverPort=没有被占用的端口号
(3)停用这个服务,在启动脚本中增加"-Dzookeeper.admin.enableServer=false"

5、vim显示行号
临时显示: set nu
永久显示
vim ~/.vimrc
(可能不存在)
增加 set nu。

6、linux显示文件大小
ll 默认用字节,太大了,没有直观的印象
ll -h 用M/G为单位

df -h,也不错,显示硬盘的使用iqngk
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       265G   42G  210G  17% /
tmpfs           127G   12K  127G   1% /dev/shm
/dev/sda1       283M   34M  235M  13% /boot
/dev/sdb1        19T  2.2T   17T  12% /opt


有2个超级大文件,55G和121G。
原因,MQ消费失败,抛出异常。
我司,MQ不断重试,1秒1次的样子,永不停止。
很坑的MQ。

消费失败,抛出异常,我觉得是合理的。
但是鉴于我司的MQ太坑,被某某改为:消费失败时,发送错误报警邮件,MQ消费返回成功,不会再重试。

7、SpringBoot集成Dubbo

        
            com.alibaba.spring.boot
            dubbo-spring-boot-starter
            2.0.0
        

这里dubbo用的是老版本2.6.0。
想用元数据,必须用2.7.0版本,但是各种配置发生了很大的变化。
没反应过来。
Dubbo已经从阿里移交到Apache里。
    
            org.apache.dubbo
            dubbo-spring-boot-starter
            2.7.1
        

        
         
            org.apache.dubbo
            dubbo
            2.7.1
        

        
        
            org.apache.dubbo
            dubbo-dependencies-zookeeper
            2.7.1
            pom
        

 dubbo admin显示元数据这个问题,还没搞定,很忧伤。
         下次再战。
        
8、mysql的连接useSSL=false
web应用中连接mysql数据库时后台会出现这样的提示:

Establishing SSL connection without server's identity verification is not recommended.
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be 
established by default if explicit option isn't set. 
For compliance with existing applications not using SSL 
the verifyServerCertificate property is set to 'false'. 
You need either to explicitly disable SSL by setting useSSL=false, 
or set useSSL=true and provide truststore for server certificate verification.

原因是MySQL在高版本需要指明是否进行SSL连接。解决方案如下:

在mysql连接字符串url中加入ssl=true或者false即可,如下所示。

url=jdbc:mysql://127.0.0.1:3306/framework?characterEncoding=utf8&useSSL=true    

你可能感兴趣的:(工作问题)