Article directory
1. Modify the host
1. Modify the host of the virtual machine
vim /etc/hostname
我起的名字叫julytemp
2. Configure the mapping address
vim /etc/hosts
前两行不要删除,在后边新增内容,刚刚起名的julytemp,对应的ip地址是多少就填多少
If you forget your IP address, use the following command
ifcfg-en(名字不固定按一下tab键补全)
cat /etc/sysconfig/network-scripts/ifcfg-en*****
3. Modify the windows mapping
进入目录C:\Windows\System32\drivers\etc ,建议修改前复制一份,防止修改出问题后,直接还原原来的文件
增加如下内容,和在虚拟机增加的内容一致
4. Modify windows settings (optional, you don’t need to match the content, but the address is not automatically obtained here)
网关在之前的教程有讲过,在那个en***文件中也有。这里我没有配置。
2. Register authorized users and create corresponding directories
1. Add a user, add july user
useradd july
passwd july
因为我之前设置好过了,所以显示的更改。和当初设置的root一样,密码不会显示,设置好,进行回车,再次确认密码。我设置的是a12345678,,它会提示说,密码过于简单,但是是可以设置成功的
2. Set july permissions
vim /etc/sudoers
Enter the content, be careful to put it below this, don’t put it wrong.
%wheel ALL=(ALL) ALL
july ALL=(ALL) NOPASSWD:ALL
keep
wq!
3. Create the directory and modify the owner and group to July
Create a directory
mkdir /opt/module
mkdir /opt/software
Change to july user
chown july:july /opt/module
chown july:july /opt/software
Check if successful
cd /opt/
ll
最后一步,删除镜像中自带的jdk!!!!!
rpm -qa | grep -i java | xargs -n1 rpm -e --nodeps
3. Clone the configured virtual machine
1. Follow the steps below to configure the virtual machine
克隆位置自己选择好就行
2. The second virtual machine is configured as follows. Refer to the first and second of this chapter
Configure the ip as a static ip, related to the corresponding ip address.
Configure the host.
Configure the july user.
Create a directory.
4. Use xftp to upload jdk compressed package
先设置一下编码方式,防止右侧乱码
Follow the steps below
Find the downloaded compressed package on the Windows page on the left and drag it to the right
1. Unzip and configure environment variables
tar -zxvf jdk-8u212-linux-x64.tar.gz -C /opt/module/
Create a new /etc/profile.d/my_env.sh file
sudo vim /etc/profile.d/my_env.sh
enter something
#JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_351
export PATH=$PATH:$JAVA_HOME/bin
Make environment variables effective
source /etc/profile
Validate java variables
java -version
5. Configure cluster distribution
前提是两台虚拟机的host和权限都是july设置好了,目录创建好了
scp -r /opt/module/jdk1.8.0_351 july@july64:/opt/module
The difference between rsync and scp: using rsync to copy files is faster than scp. rsync only updates the difference files. scp copies all files.
第一次操作的时候,需要输入yes,然后输入你之前设置july用户的密码a12345678
Go to the july64 virtual machine to see if the transfer is successful.
1.xsync cluster distribution script
cd /home/july
mkdir bin
cd bin
vim xsync
The input content is as follows
#!/bin/bash
#1. 判断参数个数
if [ $# -lt 1 ]
then
echo Not Enough Arguement!
exit;
fi
#2. 遍历集群所有机器
for host in july64 july65 july66 july67 july68
do
echo ==================== $host ====================
#3. 遍历所有目录,挨个发送
for file in $@
do
#4. 判断文件是否存在
if [ -e $file ]
then
#5. 获取父目录
pdir=$(cd -P $(dirname $file); pwd)
#6. 获取当前文件的名称
fname=$(basename $file)
ssh $host "mkdir -p $pdir"
rsync -av $pdir/$fname $host:$pdir
else
echo $file does not exists!
fi
done
done
Create custom environment variables
Upload the downloaded compressed package to /opt/module
and uninstall the original jdk first.
rpm -qa | grep -i java | xargs -n1 rpm -e --nodeps
Unzip
tar -zxvf jdk-8u351-linux-x64.tar.gz
sudo vim /etc/profile.d/my_env.sh
Enter the following
#JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_351
export PATH=$PATH:$JAVA_HOME/bin
Update an environment variable
source /etc/profile
chmod +x xsync
sudo cp xsync /bin/
cd ~
sudo ./bin/xsync /etc/profile.d/my_env.sh
test script
xsync /home/july/bin
2.SSH passwordless login configuration
ssh-copy-id 对应的host主机名称
cd /home/july/.ssh
If there is no such directory, ssh the host set by host.
for example
ssh julytemp
ssh-keygen -t rsa
ssh-copy-id julytemp
ssh-copy-id july6***
Summarize
This method refers to the course of Shang Silicon Valley. The course uses VMware15, and I use VMware 16. Some places may be different, but they are similar. If there is something you don’t understand, you can search for Hadoop courses in Shang Silicon Valley and there are corresponding video explanations.