1.系统时间和时区不一致
1.1 查看系统时间:
[root@localhost sysconfig]# timedatectl
Local time: 一 2017-11-06 21:13:19 CST
Universal time: 一 2017-11-06 13:13:19 UTC
RTC time: 一 2017-11-06 13:13:19
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: noNTP synchronized: no
RTC in local TZ: no
DST active: n/a
1.2 查看系统时区:
[root@localhost sysconfig]# ls /usr/share/zoneinfo/
Africa Brazil Egypt GB-Eire HST Japan Navajo posixrules Turkey zone1970.tab
America Canada Eire GMT Iceland Kwaj
1.3 删除当前系统所处的分区:
[root@localhost sysconfig]# sudo rm /etc/localtime
1.4 从/usr/share/zoneinfo/中创建软连接以替换当前的时区信息,直接选择Universal::
[root@localhost sysconfig]# sudo ln -s /usr/share/zoneinfo/Universal /etc/localtime
1.5 再次查看系统时间:
[root@localhost sysconfig]# sudo timedatectl
Local time: 一 2017-11-06 13:14:32 UTC
Universal time: 一 2017-11-06 13:14:32 UTC
RTC time: 一 2017-11-06 13:14:32
Time zone: Universal (UTC, +0000)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
2.网络设置
2.1 进入虚拟机设置编辑三个文件(按顺序来)
vim /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
GATEWAY=192.168.50.2
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
NAME=ens33
BOOTPROTO=static
NM_CONTROLLED=yes
IPV6INIT=no
ONBOOT=yes
IPADDR=192.168.50.10
PREFIX0=32
NETMASK=255.255.255.0
DNS1=192.168.50.2
vim /etc/resolv.conf
nameserver 192.168.50.2
2.2 重启网络服务
systemctl restart network.service
3. 镜像源切换(阿里)
(1) 备份yum镜像源(cd /etc/yum.repos.d)
[root@slave2 yum.repos.d]#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
(2) 下载aliyun的yum配置文件到/etc/yum.repos.d
[root@slave2 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
(3) 运行yum生成缓存
[root@slave2 yum.repos.d]# yum makecache
(4)更新系统
[root@slave2 yum.repos.d]# yum -y update
4.卸载CENTOS系统自带的java
查看CentOS自带JDK是否已安装:
yum list installed |grep java
卸载JDK相关文件输入:
yum -y remove java-1.8.0-openjdk*
卸载tzdata-java输入:
yum -y remove tzdata-java.noarch
5.java环境变量配置
vim ~/.bashrc:
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
JAVA_HOME=/usr/local/src/jdk1.8.0_172
CLASSPATH=.:/usr/local/src/jdk1.8.0_172/bin
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi