【测试】华为 openEuler 镜像适应性测试(续1)

1. 系统中文乱码问题

上一篇文章中我忘记了说一下我使用的 openEuler 镜像版本了,如下图所示:

docker pull openeuler/openeuler:22.03-lts-sp2

这个镜像有一个问题…不支持中文,如下图所示:

[root@chain30 ~]# docker run -it openeuler/openeuler:22.03-lts-sp2 /bin/bash


Welcome to 3.10.0-862.el7.x86_64

System information as of time:  Thu Jul 27 06:23:08 UTC 2023

System load:    0.00
Processes:      5
Memory used:    5.6%
Swap used:      0%
Usage On:       12%
Users online:   0

[root@d155f55f1587 /]# mkdir 这是一个文件夹
[root@d155f55f1587 /]# ls
 afs   dev   home   lib64   mnt   proc   run    srv   tmp   var
 bin   etc   lib    media   opt   root   sbin   sys   usr  ''$'\350\277\231\344\346\230\257\344\270\200\344\270\252\346\226\207\344\273\266\345\244\271'
[root@d155f55f1587 /]# 

我们先通过“locale”看看系统的字符集配置。如下图:

[root@d155f55f1587 /]# locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

之后我们又实用“locale -a”命令看看目前支持那些字符集,如下图:

[root@d155f55f1587 /]# locale -a
C
C.utf8
POSIX

这…有C.utf8其实就是支持中文的呀,这个乱码问题只需要将原来的 POSIX 改为 C.utf8 就可以了。这就需要我们再修改一下 vi ~/.bashrc,使中文支持生效

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

export LC_ALL=C.utf8
export LANG=C.utf8

这里为什么不写在 /etc/profile 里面呢?这是因为我们使用的是镜像,写在 profile 里在重启容器后配置将不会生效,难道每次重启都要执行一次 source /etc/profile 么,既然这样还不如写在 .bashrc 文件里面。在编写完成后,我们就可以使用 exit 退出容器,然后通过 docker commit 打包一个新的镜像出来,之后再启动那个新镜像。如下图:

[root@d155f55f1587 /]# exit
exit
[root@chain30 ~]# docker ps -a
CONTAINER ID        IMAGE                                                                    COMMAND                  CREATED             STATUS                     PORTS                      NAMES
d155f55f1587        openeuler/openeuler:22.03-lts-sp2                                        "/bin/bash"              31 minutes ago      Exited (0) 3 seconds ago                              suspicious_euler
[root@chain30 ~]# docker commit d155f55f1587 euler-tmp:v1
sha256:9eec5db71c33d2713fb9fd336624c48dc737499fd8103c4462fda955725038a1

之后进入到新容器内部 mkdir 一个中文文件夹来验证一下,如下图:

[root@c8c7a83afabc /]# echo $LANG
C.utf8
[root@c8c7a83afabc /]# locale 
LANG=C.utf8
LC_CTYPE="C.utf8"
LC_NUMERIC="C.utf8"
LC_TIME="C.utf8"
LC_COLLATE="C.utf8"
LC_MONETARY="C.utf8"
LC_MESSAGES="C.utf8"
LC_PAPER="C.utf8"
LC_NAME="C.utf8"
LC_ADDRESS="C.utf8"
LC_TELEPHONE="C.utf8"
LC_MEASUREMENT="C.utf8"
LC_IDENTIFICATION="C.utf8"
LC_ALL=C.utf8
[root@c8c7a83afabc /]# ls
afs  bin  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@c8c7a83afabc /]# mkdir 我是文件夹
[root@c8c7a83afabc /]# ls
afs  bin  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  我是文件夹

2. java 项目验证码无法输出

有同事反映说,使用新镜像后原通过 redis 生成的 captcha 验证码出现无法输出的情况,如下图:

...
2023-07-27 08:01:29 | INFO  | main | org.apache.coyote.http11.Http11NioProtocol | Starting ProtocolHandler ["http-nio-8701"]
2023-07-27 08:01:29 | INFO  | main | cn.paohe.Application | Started Application in 19.913 seconds (JVM running for 20.669)
2023-07-27 08:01:29 | INFO  | scheduling-1 | cn.paohe.common.task.CacheTask | delete expired user
2023-07-27 08:01:29 | INFO  | main | cn.paohe.common.runner.StartedUpRunner |  __    ___   _      ___   _     ____ _____  ____ 
2023-07-27 08:01:29 | INFO  | main | cn.paohe.common.runner.StartedUpRunner | / /`  / / \ | |\/| | |_) | |   | |_   | |  | |_  
2023-07-27 08:01:29 | INFO  | main | cn.paohe.common.runner.StartedUpRunner | \_\_, \_\_/ |_|  | |_|   |_|__ |_|__  |_|  |_|__ 
2023-07-27 08:01:29 | INFO  | main | cn.paohe.common.runner.StartedUpRunner |                                                       
2023-07-27 08:01:29 | INFO  | main | cn.paohe.common.runner.StartedUpRunner | 启动完毕,时间:2023-07-27T08:01:29.585
2023-07-27 08:01:37 | INFO  | http-nio-8701-exec-1 | org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] | Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-07-27 08:01:37 | ERROR | http-nio-8701-exec-1 | cn.paohe.common.handler.GlobalExceptionHandler | 系统内部异常,异常信息:
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: sun.font.SunFontManager (initialization failure)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1054)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
...

通过 java 的输出看到报错的原因是找不到 sun.font.SunFontManager 类。看上去就是跟字体的支持有关,那么先安装字体库吧。如下图:

[root@9bdec7fad99d home]# yum install fontconfig
OS                                                                                                                                                           144 kB/s | 3.4 MB     00:24    
everything                                                                                                                                                   247 kB/s |  17 MB     01:08    
EPOL                                                                                                                                                         658 kB/s | 4.5 MB     00:07    
debuginfo                                                                                                                                                    3.6 MB/s | 4.0 MB     00:01    
source                                                                                                                                                       1.7 MB/s | 1.8 MB     00:01    
update                                                                                                                                                       2.3 MB/s | 2.5 MB     00:01    
update-source                                                                                                                                                 34 kB/s |  25 kB     00:00    
Dependencies resolved.
=============================================================================================================================================================================================
 Package                                           Architecture                            Version                                                 Repository                           Size
=============================================================================================================================================================================================
Installing:
 fontconfig                                        x86_64                                  2.13.94-2.oe2203sp2                                     OS                                  225 k
Installing dependencies:
 dejavu-fonts                                      noarch                                  2.37-2.oe2203sp2                                        OS                                  5.1 M
 fonts-filesystem                                  noarch                                  4.0.2-2.oe2203sp2                                       OS                                  7.3 k
 freetype                                          x86_64                                  2.12.1-2.oe2203sp2                                      OS                                  371 k

Transaction Summary
=============================================================================================================================================================================================
Install  4 Packages

Total download size: 5.6 M
Installed size: 20 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): fonts-filesystem-4.0.2-2.oe2203sp2.noarch.rpm                                                                                                         5.3 kB/s | 7.3 kB     00:01    
(2/4): fontconfig-2.13.94-2.oe2203sp2.x86_64.rpm                                                                                                             147 kB/s | 225 kB     00:01    
(3/4): freetype-2.12.1-2.oe2203sp2.x86_64.rpm                                                                                                                217 kB/s | 371 kB     00:01    
(4/4): dejavu-fonts-2.37-2.oe2203sp2.noarch.rpm                                                                                                              191 kB/s | 5.1 MB     00:27    
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                        211 kB/s | 5.6 MB     00:27     
retrieving repo key for OS unencrypted from http://repo.openeuler.org/openEuler-22.03-LTS-SP2/OS/x86_64/RPM-GPG-KEY-openEuler
OS                                                                                                                                                            16 kB/s | 3.0 kB     00:00    
Importing GPG key 0xB675600B:
 Userid     : "openeuler "
 Fingerprint: 8AA1 6BF9 F2CA 5244 010D CA96 3B47 7C60 B675 600B
 From       : http://repo.openeuler.org/openEuler-22.03-LTS-SP2/OS/x86_64/RPM-GPG-KEY-openEuler
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                     1/1 
  Installing       : fonts-filesystem-4.0.2-2.oe2203sp2.noarch                                                                                                                           1/4 
  Installing       : dejavu-fonts-2.37-2.oe2203sp2.noarch                                                                                                                                2/4 
  Installing       : freetype-2.12.1-2.oe2203sp2.x86_64                                                                                                                                  3/4 
  Running scriptlet: freetype-2.12.1-2.oe2203sp2.x86_64                                                                                                                                  3/4 
  Installing       : fontconfig-2.13.94-2.oe2203sp2.x86_64                                                                                                                               4/4 
  Running scriptlet: fontconfig-2.13.94-2.oe2203sp2.x86_64                                                                                                                               4/4 
  Verifying        : dejavu-fonts-2.37-2.oe2203sp2.noarch                                                                                                                                1/4 
  Verifying        : fontconfig-2.13.94-2.oe2203sp2.x86_64                                                                                                                               2/4 
  Verifying        : fonts-filesystem-4.0.2-2.oe2203sp2.noarch                                                                                                                           3/4 
  Verifying        : freetype-2.12.1-2.oe2203sp2.x86_64                                                                                                                                  4/4 

Installed:
  dejavu-fonts-2.37-2.oe2203sp2.noarch          fontconfig-2.13.94-2.oe2203sp2.x86_64          fonts-filesystem-4.0.2-2.oe2203sp2.noarch          freetype-2.12.1-2.oe2203sp2.x86_64         

Complete!

之后再进行调用就可以了,如下图:

...
2023-07-27 08:12:09 | INFO  | main | springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator | Generating unique operation named: importExcelsUsingPOST_1
2023-07-27 08:12:09 | INFO  | main | springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator | Generating unique operation named: findPageUsingGET_99
2023-07-27 08:12:09 | INFO  | main | springfox.documentation.spring.web.readers.operation.CachingOperationNameGenerator | Generating unique operation named: getInfoUsingGET_94
2023-07-27 08:12:09 | INFO  | main | org.apache.coyote.http11.Http11NioProtocol | Starting ProtocolHandler ["http-nio-8701"]
2023-07-27 08:12:09 | INFO  | main | cn.paohe.Application | Started Application in 21.94 seconds (JVM running for 22.637)
2023-07-27 08:12:09 | INFO  | scheduling-1 | cn.paohe.common.task.CacheTask | delete expired user
2023-07-27 08:12:09 | INFO  | main | cn.paohe.common.runner.StartedUpRunner |  __    ___   _      ___   _     ____ _____  ____ 
2023-07-27 08:12:09 | INFO  | main | cn.paohe.common.runner.StartedUpRunner | / /`  / / \ | |\/| | |_) | |   | |_   | |  | |_  
2023-07-27 08:12:09 | INFO  | main | cn.paohe.common.runner.StartedUpRunner | \_\_, \_\_/ |_|  | |_|   |_|__ |_|__  |_|  |_|__ 
2023-07-27 08:12:09 | INFO  | main | cn.paohe.common.runner.StartedUpRunner |                                                       
2023-07-27 08:12:09 | INFO  | main | cn.paohe.common.runner.StartedUpRunner | 启动完毕,时间:2023-07-27T08:12:09.493
2023-07-27 08:13:32 | INFO  | http-nio-8701-exec-2 | org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] | Initializing Spring DispatcherServlet 'dispatcherServlet'

【测试】华为 openEuler 镜像适应性测试(续1)_第1张图片

你可能感兴趣的:(Docker,docker,openEuler)