在推動ansible用於配置管理與自動部署,其中一個很困擾的問題是建立ssh通道很慢,雖然ansible在同一個task裏面是並行的控制多臺受控端.可是每個task都須要和受控端建立ssh通道,很是影響效率.今天決定把它解決了.node
看了一下官網,說起到了openssh的ControlPersist特性能夠優化,查了一下,其實就是持久化socket,一次驗證屢次通訊.而且只須要修改ssh client就好了.app
支持這個特性須要比較新的openssh,那須要本身編譯一個,那咱們來本身弄個RPM包吧.ssh
mkdir -pv /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS,TMP} yum -y install tcp_wrappers tcp_wrappers-devel tcp_wrappers-libs openssl
cd /root/rpmbuild/SOURCES/. wget http://mirror.team-cymru.org/pub/OpenBSD/OpenSSH/portable/openssh-6.6p1.tar.gz wget http://mirror.team-cymru.org/pub/OpenBSD/OpenSSH/portable/openssh-6.6p1.tar.gz.asc cd ../SPECS/ tar xfz ../SOURCES/openssh-6.6p1.tar.gz openssh-6.6p1/contrib/redhat/openssh.spec mv openssh-6.6p1/contrib/redhat/openssh.spec openssh-6.6p1.spec rm -rf openssh-6.6p1 sed -i -e "s/%define no_gnome_askpass 0/%define no_gnome_askpass 1/g" openssh-6.6p1.spec sed -i -e "s/%define no_x11_askpass 0/%define no_x11_askpass 1/g" openssh-6.6p1.spec sed -i -e "s/BuildPreReq/BuildRequires/g" openssh-6.6p1.spec chown 74:74 openssh-6.6p1.spec rpmbuild -ba openssh-6.6p1.spec
[root@compiler SPECS]# ll ../RPMS/x86_64/openssh-* -rw-r--r-- 1 root root 417244 Jul 12 12:39 ../RPMS/x86_64/openssh-6.6p1-1.x86_64.rpm -rw-r--r-- 1 root root 547696 Jul 12 12:39 ../RPMS/x86_64/openssh-clients-6.6p1-1.x86_64.rpm -rw-r--r-- 1 root root 17020 Jul 12 12:39 ../RPMS/x86_64/openssh-debuginfo-6.6p1-1.x86_64.rpm -rw-r--r-- 1 root root 374256 Jul 12 12:39 ../RPMS/x86_64/openssh-server-6.6p1-1.x86_64.rpm
rpm -qa |grep openssh |xargs rpm -e --nodeps --justdb #先卸載舊的openssh rpm -ivh /tmp/openssh-*