Red Hat中文字符集安装
在Linux下使用locale命令提示如下警告:
locale: Cannot set LC_CTYPE to default locale: No such file or directory
系统版本:
Red Hat Enterprise Linux release 8.2 (Ootpa)
[uessso@mylocal-host ~]$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="zh_CN.GBK"
LC_NUMERIC="zh_CN.GBK"
LC_TIME="zh_CN.GBK"
LC_COLLATE="zh_CN.GBK"
LC_MONETARY="zh_CN.GBK"
LC_MESSAGES="zh_CN.GBK"
LC_PAPER="zh_CN.GBK"
LC_NAME="zh_CN.GBK"
LC_ADDRESS="zh_CN.GBK"
LC_TELEPHONE="zh_CN.GBK"
LC_MEASUREMENT="zh_CN.GBK"
LC_IDENTIFICATION="zh_CN.GBK"
LC_ALL=zh_CN.GBK
[uessso@mylocal-host ~]$
[uessso@mylocal-host ~]$ cat .cshrc
source /home/uessso/apache-tomcat-7/cfg/cshrc
[uessso@mylocal-host ~]$ grep LC_ALL /home/uessso/apache-tomcat-7/cfg/cshrc
setenv LC_ALL zh_CN.GBK
原因是用户配置了zh_CN.GBK字符集,但系统并没有安装这个字符集,因此会报错。
用locale -a命令查看了系统安装的字符编码,未发现 zh_CN.GBK这个字符集。
配置好yum源安装中文字符集
dnf install glibc-langpack-zh.x86_64
或在阿里云下载对应软件包安装
[root@mylocal-host tmp]#wget https://mirrors.aliyun.com/centos-vault/8.2.2004/BaseOS/x86_64/kickstart/Packages/glibc-langpack-zh-2.28-101.el8.x86_64.rpm --no-check-certificate
[root@mylocal-host tmp]# rpm -ivh glibc-langpack-zh-2.28-101.el8.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:glibc-langpack-zh-2.28-101.el8 ################################# [100%]
查看glibc-langpack-zh软件包安装的文件
[root@mylocal-host tmp]# rpm -ql glibc-langpack-zh
/usr/lib/locale
/usr/lib/locale/zh_CN
/usr/lib/locale/zh_CN.gb18030
/usr/lib/locale/zh_CN.gb18030/LC_ADDRESS
/usr/lib/locale/zh_CN.gb18030/LC_COLLATE
/usr/lib/locale/zh_CN.gb18030/LC_CTYPE
/usr/lib/locale/zh_CN.gb18030/LC_IDENTIFICATION
/usr/lib/locale/zh_CN.gb18030/LC_MEASUREMENT
/usr/lib/locale/zh_CN.gb18030/LC_MESSAGES
/usr/lib/locale/zh_CN.gb18030/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_CN.gb18030/LC_MONETARY
/usr/lib/locale/zh_CN.gb18030/LC_NAME
/usr/lib/locale/zh_CN.gb18030/LC_NUMERIC
/usr/lib/locale/zh_CN.gb18030/LC_PAPER
/usr/lib/locale/zh_CN.gb18030/LC_TELEPHONE
/usr/lib/locale/zh_CN.gb18030/LC_TIME
/usr/lib/locale/zh_CN.gbk
/usr/lib/locale/zh_CN.gbk/LC_ADDRESS
/usr/lib/locale/zh_CN.gbk/LC_COLLATE
/usr/lib/locale/zh_CN.gbk/LC_CTYPE
/usr/lib/locale/zh_CN.gbk/LC_IDENTIFICATION
/usr/lib/locale/zh_CN.gbk/LC_MEASUREMENT
/usr/lib/locale/zh_CN.gbk/LC_MESSAGES
/usr/lib/locale/zh_CN.gbk/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_CN.gbk/LC_MONETARY
/usr/lib/locale/zh_CN.gbk/LC_NAME
/usr/lib/locale/zh_CN.gbk/LC_NUMERIC
/usr/lib/locale/zh_CN.gbk/LC_PAPER
/usr/lib/locale/zh_CN.gbk/LC_TELEPHONE
/usr/lib/locale/zh_CN.gbk/LC_TIME
/usr/lib/locale/zh_CN.utf8
/usr/lib/locale/zh_CN.utf8/LC_ADDRESS
/usr/lib/locale/zh_CN.utf8/LC_COLLATE
/usr/lib/locale/zh_CN.utf8/LC_CTYPE
/usr/lib/locale/zh_CN.utf8/LC_IDENTIFICATION
/usr/lib/locale/zh_CN.utf8/LC_MEASUREMENT
/usr/lib/locale/zh_CN.utf8/LC_MESSAGES
/usr/lib/locale/zh_CN.utf8/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_CN.utf8/LC_MONETARY
/usr/lib/locale/zh_CN.utf8/LC_NAME
/usr/lib/locale/zh_CN.utf8/LC_NUMERIC
/usr/lib/locale/zh_CN.utf8/LC_PAPER
/usr/lib/locale/zh_CN.utf8/LC_TELEPHONE
/usr/lib/locale/zh_CN.utf8/LC_TIME
/usr/lib/locale/zh_CN/LC_ADDRESS
/usr/lib/locale/zh_CN/LC_COLLATE
/usr/lib/locale/zh_CN/LC_CTYPE
/usr/lib/locale/zh_CN/LC_IDENTIFICATION
/usr/lib/locale/zh_CN/LC_MEASUREMENT
/usr/lib/locale/zh_CN/LC_MESSAGES
/usr/lib/locale/zh_CN/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_CN/LC_MONETARY
/usr/lib/locale/zh_CN/LC_NAME
/usr/lib/locale/zh_CN/LC_NUMERIC
/usr/lib/locale/zh_CN/LC_PAPER
/usr/lib/locale/zh_CN/LC_TELEPHONE
/usr/lib/locale/zh_CN/LC_TIME
/usr/lib/locale/zh_HK
/usr/lib/locale/zh_HK.utf8
/usr/lib/locale/zh_HK.utf8/LC_ADDRESS
/usr/lib/locale/zh_HK.utf8/LC_COLLATE
/usr/lib/locale/zh_HK.utf8/LC_CTYPE
/usr/lib/locale/zh_HK.utf8/LC_IDENTIFICATION
/usr/lib/locale/zh_HK.utf8/LC_MEASUREMENT
/usr/lib/locale/zh_HK.utf8/LC_MESSAGES
/usr/lib/locale/zh_HK.utf8/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_HK.utf8/LC_MONETARY
/usr/lib/locale/zh_HK.utf8/LC_NAME
/usr/lib/locale/zh_HK.utf8/LC_NUMERIC
/usr/lib/locale/zh_HK.utf8/LC_PAPER
/usr/lib/locale/zh_HK.utf8/LC_TELEPHONE
/usr/lib/locale/zh_HK.utf8/LC_TIME
/usr/lib/locale/zh_HK/LC_ADDRESS
/usr/lib/locale/zh_HK/LC_COLLATE
/usr/lib/locale/zh_HK/LC_CTYPE
/usr/lib/locale/zh_HK/LC_IDENTIFICATION
/usr/lib/locale/zh_HK/LC_MEASUREMENT
/usr/lib/locale/zh_HK/LC_MESSAGES
/usr/lib/locale/zh_HK/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_HK/LC_MONETARY
/usr/lib/locale/zh_HK/LC_NAME
/usr/lib/locale/zh_HK/LC_NUMERIC
/usr/lib/locale/zh_HK/LC_PAPER
/usr/lib/locale/zh_HK/LC_TELEPHONE
/usr/lib/locale/zh_HK/LC_TIME
/usr/lib/locale/zh_SG
/usr/lib/locale/zh_SG.gbk
/usr/lib/locale/zh_SG.gbk/LC_ADDRESS
/usr/lib/locale/zh_SG.gbk/LC_COLLATE
/usr/lib/locale/zh_SG.gbk/LC_CTYPE
/usr/lib/locale/zh_SG.gbk/LC_IDENTIFICATION
/usr/lib/locale/zh_SG.gbk/LC_MEASUREMENT
/usr/lib/locale/zh_SG.gbk/LC_MESSAGES
/usr/lib/locale/zh_SG.gbk/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_SG.gbk/LC_MONETARY
/usr/lib/locale/zh_SG.gbk/LC_NAME
/usr/lib/locale/zh_SG.gbk/LC_NUMERIC
/usr/lib/locale/zh_SG.gbk/LC_PAPER
/usr/lib/locale/zh_SG.gbk/LC_TELEPHONE
/usr/lib/locale/zh_SG.gbk/LC_TIME
/usr/lib/locale/zh_SG.utf8
/usr/lib/locale/zh_SG.utf8/LC_ADDRESS
/usr/lib/locale/zh_SG.utf8/LC_COLLATE
/usr/lib/locale/zh_SG.utf8/LC_CTYPE
/usr/lib/locale/zh_SG.utf8/LC_IDENTIFICATION
/usr/lib/locale/zh_SG.utf8/LC_MEASUREMENT
/usr/lib/locale/zh_SG.utf8/LC_MESSAGES
/usr/lib/locale/zh_SG.utf8/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_SG.utf8/LC_MONETARY
/usr/lib/locale/zh_SG.utf8/LC_NAME
/usr/lib/locale/zh_SG.utf8/LC_NUMERIC
/usr/lib/locale/zh_SG.utf8/LC_PAPER
/usr/lib/locale/zh_SG.utf8/LC_TELEPHONE
/usr/lib/locale/zh_SG.utf8/LC_TIME
/usr/lib/locale/zh_SG/LC_ADDRESS
/usr/lib/locale/zh_SG/LC_COLLATE
/usr/lib/locale/zh_SG/LC_CTYPE
/usr/lib/locale/zh_SG/LC_IDENTIFICATION
/usr/lib/locale/zh_SG/LC_MEASUREMENT
/usr/lib/locale/zh_SG/LC_MESSAGES
/usr/lib/locale/zh_SG/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_SG/LC_MONETARY
/usr/lib/locale/zh_SG/LC_NAME
/usr/lib/locale/zh_SG/LC_NUMERIC
/usr/lib/locale/zh_SG/LC_PAPER
/usr/lib/locale/zh_SG/LC_TELEPHONE
/usr/lib/locale/zh_SG/LC_TIME
/usr/lib/locale/zh_TW
/usr/lib/locale/zh_TW.euctw
/usr/lib/locale/zh_TW.euctw/LC_ADDRESS
/usr/lib/locale/zh_TW.euctw/LC_COLLATE
/usr/lib/locale/zh_TW.euctw/LC_CTYPE
/usr/lib/locale/zh_TW.euctw/LC_IDENTIFICATION
/usr/lib/locale/zh_TW.euctw/LC_MEASUREMENT
/usr/lib/locale/zh_TW.euctw/LC_MESSAGES
/usr/lib/locale/zh_TW.euctw/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_TW.euctw/LC_MONETARY
/usr/lib/locale/zh_TW.euctw/LC_NAME
/usr/lib/locale/zh_TW.euctw/LC_NUMERIC
/usr/lib/locale/zh_TW.euctw/LC_PAPER
/usr/lib/locale/zh_TW.euctw/LC_TELEPHONE
/usr/lib/locale/zh_TW.euctw/LC_TIME
/usr/lib/locale/zh_TW.utf8
/usr/lib/locale/zh_TW.utf8/LC_ADDRESS
/usr/lib/locale/zh_TW.utf8/LC_COLLATE
/usr/lib/locale/zh_TW.utf8/LC_CTYPE
/usr/lib/locale/zh_TW.utf8/LC_IDENTIFICATION
/usr/lib/locale/zh_TW.utf8/LC_MEASUREMENT
/usr/lib/locale/zh_TW.utf8/LC_MESSAGES
/usr/lib/locale/zh_TW.utf8/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_TW.utf8/LC_MONETARY
/usr/lib/locale/zh_TW.utf8/LC_NAME
/usr/lib/locale/zh_TW.utf8/LC_NUMERIC
/usr/lib/locale/zh_TW.utf8/LC_PAPER
/usr/lib/locale/zh_TW.utf8/LC_TELEPHONE
/usr/lib/locale/zh_TW.utf8/LC_TIME
/usr/lib/locale/zh_TW/LC_ADDRESS
/usr/lib/locale/zh_TW/LC_COLLATE
/usr/lib/locale/zh_TW/LC_CTYPE
/usr/lib/locale/zh_TW/LC_IDENTIFICATION
/usr/lib/locale/zh_TW/LC_MEASUREMENT
/usr/lib/locale/zh_TW/LC_MESSAGES
/usr/lib/locale/zh_TW/LC_MESSAGES/SYS_LC_MESSAGES
/usr/lib/locale/zh_TW/LC_MONETARY
/usr/lib/locale/zh_TW/LC_NAME
/usr/lib/locale/zh_TW/LC_NUMERIC
/usr/lib/locale/zh_TW/LC_PAPER
/usr/lib/locale/zh_TW/LC_TELEPHONE
/usr/lib/locale/zh_TW/LC_TIME
/usr/share/locale/zh_CN/LC_MESSAGES/libc.mo
/usr/share/locale/zh_TW/LC_MESSAGES/libc.mo
查看当前系统已安装的字符集已经有了我们需要的GBK字符集
[root@mylocal-host tmp]# locale -a
C
C.utf8
en_AG
en_AU
en_AU.utf8
en_BW
en_BW.utf8
en_CA
en_CA.utf8
en_DK
en_DK.utf8
en_GB
en_GB.iso885915
en_GB.utf8
en_HK
en_HK.utf8
en_IE
en_IE@euro
en_IE.utf8
en_IL
en_IN
en_NG
en_NZ
en_NZ.utf8
en_PH
en_PH.utf8
en_SC.utf8
en_SG
en_SG.utf8
en_US
en_US.iso885915
en_US.utf8
en_ZA
en_ZA.utf8
en_ZM
en_ZW
en_ZW.utf8
POSIX
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
zh_HK
zh_HK.utf8
zh_SG
zh_SG.gbk
zh_SG.utf8
zh_TW
zh_TW.euctw
zh_TW.utf8
对应 Red Hat Enterprise Linux release 8.3 (Ootpa)字符集似乎又和之前版本不同。
永远年轻,永远热泪盈眶