ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.3.2
tar -xvf pssh-2.3.1.tar.gz
cd pssh-2.3.1
python setup.py install
创建所有服务器列表txt文件allhosts vim allhosts>>192.168.3.1-15
创建java目录
pssh -i -h allhosts "mkdir /usr/local/java"
拷贝jdk文件到所有服务器
pscp -h allhosts jdk-7u45-linux-x64.tar.gz /usr/local/java
解压jdk目录
pssh -i -h allhosts "tar -zxvf /usr/local/java/jdk-7u45-linux-x64.tar.gz -C /usr/local/java"
环境变量生效
pssh -i -h /root/allhosts "source /etc/profile"
查看java是否生效
pssh -i -h /root/allhosts "java -version"
拷贝tomcat安装包
pscp -h allhosts apache-tomcat-7.0.77.tar.gz /usr/local/java
解压tomcat
pssh -i -h allhosts "tar -zxvf /usr/local/java/apache-tomcat-7.0.77.tar.gz -C /usr/local/java/"
启动tomcat服务
pssh -i -h allhosts "/usr/local/java/apache-tomcat-7.0.77/bin/startup.sh"
查看服务是否启动
pssh -i -h allhosts "netstat -antup | grep 80"
本文转自 rm_rf_db 51CTO博客,原文链接:http://blog.51cto.com/12185273/1979036,如需转载请自行联系原作者