vi /etc/hosts
[root@localhost ~]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.80.131 node1 192.168.80.132 node2 192.168.80.133 node3永久修改主机名(需要重启) vi /etc/hostname
[root@localhost ~]# vi /etc/hostname首先删除主机名默认值localhost.localdomain,然后修改为node1
[root@localhost ~]# cat /etc/hostname node1修改临时主机名(避免重启)
[root@localhost ~]# hostname node1这是只要重新打开一个Shell即可看到修改的临时主机名 XShell重新链接node1
即可发现主机名已经和永久主机名相同。
2017-06-29更新 可以通过命令hostnamectl set-hostname 永久修改主机名,无需编辑文件
[root@abc ~]# hostnamectl set-hostname node1 [root@abc ~]# hostname node1 [root@abc ~]# cat /etc/hostname node1打开阿里镜像http://mirrors.aliyun.com/
3)下载CentOS 7的repo文件 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo [root@node1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo --2017-05-07 09:21:28-- http://mirrors.aliyun.com/repo/Centos-7.repo Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 115.28.122.210, 112.124.140.210 Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|115.28.122.210|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2573 (2.5K) [application/octet-stream] Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’ 100%[==============================================================================>] 2,573 --.-K/s in 0s 2017-05-07 09:21:28 (279 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2573/2573]2018-08-11更新 如果没有安装wget,可以直接使用curl命令
[root@node1 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 102 2572 102 2572 0 0 499 0 0:00:05 0:00:05 --:--:-- 49461 [root@node1 ~]#4)更新镜像源
yum clean all:清除缓存
yum makecache:生成缓存
[root@node1 ~]# yum clean all Loaded plugins: fastestmirror Cleaning repos: base extras updates Cleaning up everything Cleaning up list of fastest mirrors [root@node1 ~]# yum makecache Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/12): base/7/x86_64/group_gz | 155 kB 00:00:00 (2/12): extras/7/x86_64/filelists_db | 770 kB 00:00:02 (3/12): extras/7/x86_64/primary_db | 151 kB 00:00:00 (4/12): extras/7/x86_64/other_db | 640 kB 00:00:07 (5/12): updates/7/x86_64/filelists_db .......省略执行命令: systemctl stop firewalld systemctl disable firewalld
[root@node1 ~]# systemctl stop firewalld [root@node1 ~]# systemctl disable firewalld Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.补充:CentOS 6 关闭防火墙
[root@node1 ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@node1 ~]# chkconfig iptables off执行命令: setenforce 0 vi /etc/selinux/config
[root@node1 ~]# setenforce 0 [root@node1 ~]# vi /etc/selinux/config修改:SELINUX=disabled
或者使用sed命令直接修改
[root@node1 ~]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config再次编辑bashrc,会发现vi实际上使用的vim
yum install -y openssh-clients
[root@node1 ~]# yum install -y openssh-clients1)首先在宿主机下载好JDK
2)通过Xftp上传JDK到虚拟机
[root@node1 ~]# ls anaconda-ks.cfg jdk-8u112-linux-x64.tar.gz将软件包解压缩到/opt目录 tar -zxvf jdk-8u112-linux-x64.tar.gz -C /opt
[root@node1 ~]# tar -zxvf jdk-8u112-linux-x64.tar.gz -C /opt [root@node1 ~]# ls /opt/jdk1.8.0_112/ bin COPYRIGHT db include javafx-src.zip jre lib LICENSE man README.html release src.zip THIRDPARTYLICENSEREADME-JAVAFX.txt THIRDPARTYLICENSEREADME.txt复制jdk的根目录/opt/jdk1.8.0_112,下面配置环境变量将使用到。 编辑环境变量 vi /etc/profile.d/custom.sh
[root@node1 ~]# vi /etc/profile.d/custom.sh [root@node1 ~]# cat /etc/profile.d/custom.sh #!/bin/bash #java path export JAVA_HOME=/opt/jdk1.8.0_112 export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib使生效 source /etc/profile.d/custom.sh
[root@node1 ~]# source /etc/profile.d/custom.sh查看JDK版本
[root@node1 ~]# java -version java version "1.8.0_112" Java(TM) SE Runtime Environment (build 1.8.0_112-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)