天天看點

Linux叢集和自動化維3.6.1 Fabric的安裝

<b>3.6.1 fabric的安裝</b>

安裝fabric時,可以選擇采用python的pip、easy_install及源碼安裝方式,這些方式能夠很友善地解決包依賴關系。大家可以根據系統環境自行選擇最優的安裝方法,如果選擇pip或easy_install安裝方式,則其安裝指令如下(如果系統是最小化安裝,記得先提前安裝好gcc、gcc-c++、make這些基礎開發包和python-pip):

yum -y install

make gcc gcc++ python-devel python-pip

pip是安裝python包的工具,提供了安裝包、列出已經安裝的包、更新包及解除安裝包的功能,可以通過pip工具直接安裝fabric,指令如下:

pip install

fabric

這裡推薦源碼安裝,安裝步驟如下所示:

python-setuptools

cd

/usr/local/src

wget

https://pypi.python.org/packages/source/f/fabric/fabric-1.3.0.tar.gz

--no-check-certificate

tar xvf

fabric-1.3.0.tar.gz

cd fabric-1.3.0

python setup.py

install

安裝結果如下,如果出現以下資訊則表示fabric已經成功安裝:

downloading

https://pypi.python.org/packages/source/s/ssh/ssh-1.8.0.tar.gz#md5=bc4dd59ec0c7bdf78a3840652cac824e

processing

ssh-1.8.0.tar.gz

running

ssh-1.8.0/setup.py -q bdist_egg --dist-dir

/tmp/easy_install-cw9pkj/ssh-1.8.0/egg-dist-tmp-dkm93k

zip_safe flag

not set; analyzing archive contents...

adding ssh 1.8.0

to easy-install.pth file

installed

/usr/lib/python2.6/site-packages/ssh-1.8.0-py2.6.egg

searching for

pycrypto==2.6.1

best match:

pycrypto 2.6.1

adding pycrypto

2.6.1 to easy-install.pth file

using

/usr/lib64/python2.6/site-packages

finished

processing dependencies for fabric==1.3.0

下面檢查下fabric子產品是否正常安裝成功了,如果輸入import fabric沒有任何錯誤提示則表示已經成功安裝,指令如下所示:

python 2.6.6

(r266:84292, jul 23 2015, 15:22:56)

[gcc 4.4.7

20120313 (red hat 4.4.7-11)] on linux2

type

"help", "copyright", "credits" or

"license" for more information.

&gt;&gt;&gt;

import fabric

&gt;&gt;&gt;