返回顶部

JDK 1.8 二进制安装

JDK 1.8 二进制安装

shell脚本安装

cd /usr/local/
wget https://repo.huaweicloud.com/java/jdk/8u201-b09/jdk-8u201-linux-x64.tar.gz
tar -xf jdk-8u201-linux-x64.tar.gz
ln -sv jdk1.8.0_201 jdk1.8
echo 'export JAVA_HOME=/usr/local/jdk1.8' >> /etc/profile 
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile 
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile 

source /etc/profile
cp /usr/local/jdk1.8/bin/* /bin/
java -version  && echo -e '\033[32m java部署成功\033[0m' || echo -e '\033[31m java部署失败\033[0m'

 

 

ansible-playbook安装

---
- hosts: h5
  remote_user: yunwei
  become: yes
  become_user: root
  become_method: sudo
  gather_facts: flase
  tasks:

  - name: 'package'
    shell: cd /usr/local/
    shell: wget https://repo.huaweicloud.com/java/jdk/8u201-b09/jdk-8u201-linux-x64.tar.gz
    shell: tar -xf jdk-8u201-linux-x64.tar.gz &> /dev/null
    shell: ln -sv jdk1.8.0_201 jdk1.8


  - name: 'export path'
    shell: echo 'export JAVA_HOME=/usr/local/jdk1.8' >> /etc/profile 
    shell: echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile 
    shell: echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile 

   - name: java path
    shell: cp /usr/local/jdk1.8/bin/* /bin/
    shell: source /etc/profile

  - name: check java version
    shell: java -version



$ansible-playbook -i h5 -C java.yaml

$ansible-playbook -i h5 java.yaml
 

 

posted @ 2022-08-18 13:11  九尾cat  阅读(113)  评论(0编辑  收藏  举报