1、选择时区
[root@slave2 ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
1) Afghanistan 18) Israel 35) Palestine
2) Armenia 19) Japan 36) Philippines
3) Azerbaijan 20) Jordan 37) Qatar
4) Bahrain 21) Kazakhstan 38) Russia
5) Bangladesh 22) Korea (North) 39) Saudi Arabia
6) Bhutan 23) Korea (South) 40) Singapore
7) Brunei 24) Kuwait 41) Sri Lanka
8) Cambodia 25) Kyrgyzstan 42) Syria
9) China 26) Laos 43) Taiwan
10) Cyprus 27) Lebanon 44) Tajikistan
11) East Timor 28) Macau 45) Thailand
12) Georgia 29) Malaysia 46) Turkmenistan
13) Hong Kong 30) Mongolia 47) United Arab Emirates
14) India 31) Myanmar (Burma) 48) Uzbekistan
15) Indonesia 32) Nepal 49) Vietnam
16) Iran 33) Oman 50) Yemen
17) Iraq 34) Pakistan
#? 9
Please select one of the following time zone regions.
1) Beijing Time
2) Xinjiang Time
#? 1
The following information has been given:
China
Beijing Time
Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Fri Feb 11 19:56:36 CST 2022.
Universal Time is now: Fri Feb 11 11:56:36 UTC 2022.
Is the above information OK?
1) Yes
2) No
#? 1
You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai
2、修改 ~/.bashrc ,并在文件最后添加时区设置
[root@slave2 ~]# vim ~/.bashrc
1 # .bashrc
2
3 # User specific aliases and functions
4
5 alias rm='rm -i'
6 alias cp='cp -i'
7 alias mv='mv -i'
8
9 # Source global definitions
10 if [ -f /etc/bashrc ]; then
11 . /etc/bashrc
12 fi
13
14
15 export JAVA_HOME=/usr/local/src/jdk1.8.0_271
16 export PATH=$PATH:$JAVA_HOME/bin
17
18 export HADOOP_HOME=/usr/local/src/hadoop-2.10.1
19 export HADOOP_CLASSPATH=/usr/local/src/hadoop-2.10.1/clp
20 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
21
22 export HADOOP_PID_DIR=$HADOOP_HOME/pid
23 export YARN_LOG_DIR=/data/hadoop-2.10.1/yarn/logs
24
25 export SPARK_HOME=/usr/local/src/spark-2.4.7-bin-hadoop2.7
26 export PATH=$PATH:$SPARK_HOME/bin:$SPARK_HOME/sbin
27
28 export HIVE_HOME=/usr/local/src/apache-hive-3.1.2-bin
29 export PATH=$HIVE_HOME/bin:$PATH
30
31 export HBASE_HOME=/usr/local/src/hbase-2.3.3
32 export PATH=$HBASE_HOME/bin:$PATH
33
34 export SQOOP_HOME=/usr/local/src/sqoop-1.4.7.bin__hadoop-2.6.0
35 export PATH=$SQOOP_HOME/bin:$PATH
36 export ACCUMULO_HOME=/data/sqoop/accumulo
37
38 export GRADLE_HOME=/usr/local/src/gradle/gradle-6.8.3
39 export PATH=$GRADLE_HOME/bin:$PATH
40
41 export ANT_HOME=/usr/local/src/apache-ant-1.9.15
42 export PATH=$ANT_HOME/bin:$PATH
43
44 # set time zone
45 export TZ='Asia/Shanghai'
3、刷新 环境变量
[root@slave2 ~]# source ~/.bashrc
[root@slave2 ~]#
解决 java(jvm) 的时区问题,没有实时生效的就重启下linux。
系统版本,请对号入座
[root@slave2 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"