Chinaunix首页 | 论坛 | 博客
  • 博客访问: 189734
  • 博文数量: 33
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 182
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-17 17:57
个人简介

IT运维工程师

文章分类

全部博文(33)

文章存档

2015年(20)

2014年(13)

我的朋友

分类: LINUX

2014-09-19 10:38:33

1、安装python
1>>使用CentOS yum源(安装的是最新版的)
yum install python*
2>>使用tar.gz包安装(选择安装的是python-2.5)
python2.5下载

tar -zxvf Python-2.5.tgz 
cd Python-2.5
./configure 
make
make install
[root@mongo01 Python-2.5]# python --version
Python 2.5


2、pssh下载

[root@szlnmp01 tmp]# tar -zxvf pssh-1.4.3.tar.gz
[root@szlnmp01 pssh-1.4.3]# ls
AUTHORS  bin  BUGS  build  ChangeLog  COPYING  dist  doc  INSTALL  Makefile  PKG-INFO  pssh.egg-info  psshlib  setup.cfg  setup.py  test  TODO
[root@szlnmp01 pssh-1.4.3]# python setup.py install
Traceback (most recent call last):
  File "setup.py", line 1, in
    from setuptools import setup, find_packages
ImportError: No module named setuptools
报错,无法安装,缺少setuptools模块
查阅http://suzy8802.blog.163.com/blog/static/2124020642013126105845273/
解决如下:
[root@szlnmp01 tmp]# wget
--2014-09-19 09:54:45--  
Resolving pypi.python.org... 103.245.222.223
Connecting to pypi.python.org|103.245.222.223|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: [following]
--2014-09-19 09:54:45--  
Connecting to pypi.python.org|103.245.222.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 256862 (251K) [application/octet-stream]
Saving to: “setuptools-0.6c11.tar.gz”


100%[=======================================================================================================================================>] 256,862      209K/s   in 1.2s    
2014-09-19 09:54:46 (209 KB/s) - “setuptools-0.6c11.tar.gz” saved [256862/256862
3、安装setuptools
[root@szlnmp01 tmp]# ls
setuptools-0.6c11.tar.gz 
[root@szlnmp01 tmp]# tar -zxvf setuptools-0.6c11.tar.gz
[root@szlnmp01 tmp]# cd setuptools-0.6c11
[root@szlnmp01 setuptools-0.6c11]# ls
api_tests.txt    EasyInstall.txt  launcher.c  pkg_resources.py   README.txt  setup.cfg  setuptools           setuptools.txt  tests    version.dat        wikiup.cfg
easy_install.py  ez_setup.py      PKG-INFO    pkg_resources.txt  release.sh  setup.py   setuptools.egg-info  site.py         version  virtual-python.py
[root@szlnmp01 setuptools-0.6c11]# python setup.py build
[root@szlnmp01 setuptools-0.6c11]# python setup.py install
[root@szlnmp01 pssh-1.4.3]# pssh
Usage: pssh [OPTIONS] -h hosts.txt prog [arg0] ..


  -h --hosts   hosts file (each line "host[:port] [user]")
  -l --user    username (OPTIONAL)
  -p --par     max number of parallel threads (OPTIONAL)
  -o --outdir  output directory for stdout files (OPTIONAL)
  -e --errdir  output directory for stderr files (OPTIONAL)
  -t --timeout timeout (secs) (-1 = no timeout) per host (OPTIONAL)
  -O --options SSH options (OPTIONAL)
  -v --verbose turn on warning and diagnostic messages (OPTIONAL)
  -P --print   print output as we get it (OPTIONAL)
  -i --inline  inline aggregated output for each server (OPTIONAL)


Example: pssh -h nodes.txt -l irb2 -o /tmp/foo uptime

[root@szlnmp01 ~]# pscp
Usage: pscp [OPTIONS] -h hosts.txt local remote


  -r --recursive recusively copy directories (OPTIONAL)
  -h --hosts     hosts file (each line "host[:port] [login]")
  -l --user      username (OPTIONAL)
  -p --par       max number of parallel threads (OPTIONAL)
  -o --outdir    output directory for stdout files (OPTIONAL)
  -e --errdir    output directory for stderr files (OPTIONAL)
  -t --timeout   timeout (secs) (-1 = no timeout) per host (OPTIONAL)
  -v --verbose   turn on warning and diagnostic messages (OPTIONAL)
  -O --options   SSH options (OPTIONAL)
Example: pscp -h hosts.txt -l irb2 foo.txt /home/irb2/foo.txt


4、使用
管理服务器:192.168.11.55--szlnmp01
客户服务器:192.168.11.51--mongo01
管理服务器上面生成密钥:
[root@szlnmp01 tmp]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
............
[root@szlnmp01 tmp]# cd /root/.ssh/
authorized_keys  id_rsa           id_rsa.pub       known_hosts    
复制密钥到远程服务器:  
[root@szlnmp01 tmp]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.11.51
root@192.168.11.51's password: 
Now try logging into the machine, with "ssh 'root@192.168.11.51'", and check in:
  .ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
不输入密码,ssh到远程服务器:
[root@szlnmp01 tmp]# ssh 192.168.11.51
Last login: Fri Sep 19 09:24:11 2014 from 192.168.27.88

[root@szlnmp01 ~]# more hostsfile.txt 
192.168.11.51
[root@szlnmp01 ~]# pssh -h hostsfile.txt rm -rf /tmp/pssh-1.4.3
[1] 11:20:30 [SUCCESS] 192.168.11.51 22
[root@szlnmp01 ~]# pscp -r -h hostsfile.txt /tmp/pssh-1.4.3 /tmp
[1] 11:23:46 [SUCCESS] 192.168.11.51 22

到此,pssh批量处理软件已经安装完成!
参考资料:
http://suzy8802.blog.163.com/blog/static/2124020642013126105845273/
阅读(4752) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~