I. Automated deployment of JDK ideas
A, you can use a Linux machine as an HTTP server, JDK version resources can be placed on the HTTP server, so that the unified use of wget to download the JDK.
The official JDK is downloaded directly using wget because there is no click Confirmation to accept the agreement, so the downloaded JDK does not install properly.
Second, install the HTTP server, prepare the initial environment
# install httpd yum -y install httpd# start HTTD server (Centos7 using: Systemctl start Httpd.service) Service httpd start# shut down firewall sudo systemctl stop Firewalld.service && sudo systemctl disable firewalld.service# switch directory CD /var/ www# Create a store app directory (upload JDK version to this directory remotely) mkdir soft# can use http: // [ip]/soft/ Whether the HTTP server was successfully accessed # generate a secret key ssh-keygen #其他机器如果没有expect命令, each machine needs to be installed yum -y install expect
Iii. Writing Automated Scripts
vi BOOT. SH
#!/bin/bashservers="node2 node3 node4 node5"PASSWORD=xXxbase_server=192.168.182.xxxauto_ssh_copy_id () {Expect-C"set timeout-1;SpawnSSH-copy-ID$1; Expect {* (yes/no) * {send--Yes\r;exp_continue;} *assword:* {send--$2\r;exp_continue;} EOF {Exit0;} }";}ssh_copy_id_to_all () { forSERVERinch$SERVERS Doauto_ssh_copy_id $SERVER $PASSWORD Done}ssh_copy_id_to_all forSERVERinch$SERVERS Do SCPInstall_jdk.SH[Email protected] $SERVER:/RootSSH[Email protected] $SERVER"/root/install_jdk.sh $BASE _server" Done
VI INSTALL_JDK. SH
#!/bin/BashYum Install-Ywgetwget$1/soft/jdk-8u161-linux-x64.Tar. GZTar-ZXVF jdk-8u161-linux-x64.Tar. gz-c/usr/LocalRM-RF jdk-8u161-linux-x64.Tar. GZsed-I.'/export java_home=\/usr\/local\/jdk1.8.0_161/'d/etc/ Profilesed-I.'/export path=\ $PATH: \ $JAVA _home\/bin/'d/etc/ ProfileCat>>/etc/profile <<Eofexport Java_home=/usr/local/jdk1.8. 0_161export PATH=\ $PATH: \ $JAVA _home/Bineofsource/etc/profile
A. Give execution permission
chmod +x boot. sh install_jdk. SH
b, only need to modify servers,password,base_server three belong to the value can be,
1, servers representative need to install the IP of the machine, multiple IPs separated by a space
2, password all machine password, the same as the password of all machines
3, Base_server is representative of the HTTP server ip
4, according to the download JDK version, need to modify the install_jdk.sh script
Third, testing
A, implementation./BOOT.SH Automated Deployment Completion
Yexiangyang
[Email protected]
Linux Automated Installation JDK