ansible安装过程中常遇到的错误

1.安装完成后允许命令报错 Traceback (most recent call last): File "/usr/bin/ansible", line 197, in (runner, results) = cli.run(options,...
继续阅读 »
1.安装完成后允许命令报错
Traceback (most recent call last):
File "/usr/bin/ansible", line 197, in
(runner, results) = cli.run(options, args)
File "/usr/bin/ansible", line 163, in run
extra_vars=extra_vars,
File "/usr/lib/python2.6/site-packages/ansible/runner/__init__.py", line 233, in __init__
cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib64/python2.6/subprocess.py", line 639, in __init__
errread, errwrite)
File "/usr/lib64/python2.6/subprocess.py", line 1228, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
解决方法:
# yum install openssh-clients
2.出现Error: ansible requires a json module, none found!
SSH password:
10.0.1.110 | FAILED >> {
"failed": true,
"msg": "Error: ansible requires a json module, nonefound!",
"parsed": false
}
解决方法:
python版本过低,要不升级python要不就升级安装python-simplejson。
3.安装完成后连接客户端服务器报错
FAILED => Using a SSH password insteadof a key is not possible because Host Key checking is enabled and sshpass doesnot support this.  Please add this host'sfingerprint to your known_hosts file to manage this host.
解决方法:
在ansible 服务器上使用ssh 登陆下/etc/ansible/hosts 里面配置的服务器。然后再次使用ansible 去管理就不会报上面的错误了!但这样大批量登陆就麻烦来。因为默认ansible是使用key验证的,如果使用密码登陆的服务器,使用ansible的话,要不修改ansible.cfg配置文件的ask_pass = True给取消注释,要不就在运行命令时候加上-k,这个意思是-k, --ask-pass ask for SSH password。再修改:host_key_checking= False即可
4.如果客户端不在know_hosts里将会报错
paramiko: The authenticity of host '192.168.24.15'can't be established.
The ssh-rsa key fingerprint is397c139fd4b0d763fcffaee346a4bf6b.
Are you sure you want to continueconnecting (yes/no)?

解决方法:
需要修改ansible.cfg的#host_key_checking= False取消注释
5.出现FAILED => FAILED: not a valid DSA private key file
解决方法:
需要你在最后添加参数-k
6.openssh升级后无法登录报错
PAM unable todlopen(/lib64/security/pam_stack.so): /lib64/security/pam_stack.so: cannot openshared object
file: No such file or directory
解决方法:
sshrpm 升级后会修改/etc/pam.d/sshd 文件。需要升级前备份此文件最后还原即可登录。
7.第一次系统初始化运行生成本机ansible用户key时报错
failed: [127.0.0.1] =>{"checksum": "f5f2f20fc0774be961fffb951a50023e31abe920","failed": true}
msg: Aborting, target uses selinux but pythonbindings (libselinux-python) aren't installed!
FATAL: all hosts have already failed –aborting
解决方法:
# yum install libselinux-python -y
收起阅读 »

make[1]: *** [objs/addon/nginx_tcp_proxy_module-master/ngx_tcp_upstream.o] Error 1

nginx 添加tcp_proxy_module 首先需要执行如下操作:patch -p1 < /path/to/nginx_tcp_proxy_module/tcp.patch
nginx 添加tcp_proxy_module 首先需要执行如下操作:
patch -p1 < /path/to/nginx_tcp_proxy_module/tcp.patch

Linux 命令集合

工作中收集了一些Linux shell命令 便于参考 mpstat用于报告多路CPU主机的每颗CPU活动情况,以及整个主机的CPU情况。下边的命令可以隔2秒报告一次处理器的活动情况,执行3次 [root@localhost ~]# mpstat 2 3如下命令...
继续阅读 »
工作中收集了一些Linux shell命令 便于参考
mpstat用于报告多路CPU主机的每颗CPU活动情况,以及整个主机的CPU情况。
下边的命令可以隔2秒报告一次处理器的活动情况,执行3次
[root@localhost ~]# mpstat 2 3
如下命令每隔1秒显示一次多路CPU主机的处理器活动情况,执行3次

[root@localhost ~]# mpstat -P ALL 1 3
在当前目录下列出所有的扩展名
[root@localhost ~]# find . -type f | awk -F'.' '{print $NF}' | sort| uniq -c | sort -g
批量替换php中的关键字    
for I in `find . -name "*.php"`; do sed -i "s/old name/new name/g" $I; done
 
快速的将当前目录中所有的.php扩展名修改给.html   
[root@localhost ~]# for i in *.php; do mv $i ${i%.php}.html; done
用备份的superblock来挂载文件系统  
[root@localhost ~]# mount -o sb=98340 /dev/sda1 /mnt/data1/
 
删除B目录中与A目录同名的文件   
[root@localhost ~]# for file in A/*; do rm B/`basename $file`; done
找出10个大文件
[root@localhost ~]# du -sh * | sort -rh | head


 
寻找非html的文件 
[root@localhost ~]# find . -type f ! -name "*html"


用脚本获取eth0上的IPv4地址
[root@localhost ~]# ip addr show eth0 |grep 'inet\b' |awk '{print $2}' |sed -r -e 's/\/.*?//g'
 
以html的形式获取服务器的硬件配置报告 
[root@localhost ~]# lshw -html >hardware.html
统计服务器上已经建立的TCP的链接 
[root@localhost ~]# netstat -an | awk '$1 ~ /[Tt][Cc][Pp]/ && $NF ~ /ESTABLISHED/{i++}END{print "Connected:\t", i}'


限制传输速率
[root@localhost ~]# cat /dev/urandom | pv -L 3m | dd bs=1M count=100 iflag=fullblock > /dev/null
 
上一条命令的快捷方式   
[root@localhost ~]# alias foo="!!"


备份制定后缀的文件并且打包到根目录下  
[root@localhost opt]# tar --exclude=".??*" -zcvf ./home_backup_2008.tar.gz my_home
 
替换:将hh文件下的内容192替换成193   
[root@localhost opt]# for I in "hh"; do sed -i "s/192/193/g" $I; done
Linux 限制传输速率    
# cat /dev/urandom | pv -L 3m | dd bs=1M count=100 iflag=fullblock > /dev/null
 
格式化另一个日期  
date --date=yesterday +%Y%m%d
合并多个文件到一个文件中 
cat file1 . . . fileN > NEWFile
 
递归删除所有的htm  
[root@localhost opt]# find . -type f -name '*.htm' -delete
列出并删除一岁的文件  
[root@localhost zhiwen]# find <目录路径> -mtime +365 -and -not -type d -delete


 
查找日志中的所有问题   
[root@localhost opt]# grep -2 -iIr "err\|warn\|fail\|crit" /var/log/*
寻找最大的10个文件夹 
[root@localhost ~]# find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {} | sort -rn
检查端口是否开放   
[root@localhost ~]#nmap -p 80 hostname
 
显示命令的输出值到file.txt文件中     
[root@localhost opt]# command | sed '/file.txt/q'
保存man页面为pdf文件    
[root@localhost opt]# man -t awk | ps2pdf - awk.pdf
 
列出所有zip压缩包里边的文件并解压    
[root@localhost opt]# find . -name "[i].tgz" -or -name "[/i].zip" | while read file; do echo "$file:"; unzip $file; done
显示所有目录内容   
[root@localhost opt]# while read f;do echo "$f";done < <(find .)
 
Linux 查找指定的某个目录  
[root:/usr/sbin Master] # find / -name 目录名 -type d
在/var/log/secure 里针对某个IP扫描了多少次
[root:~ Slave] # cat /var/log/secure |grep 192.168.83.40 | wc -l
对其中的secure获取其中的ip地址和数量:
[root:~ Slave] # grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /var/log/secure | sort | uniq -c
收起阅读 »

关于我们

OpenSkill中国技术极客IT技术问答、内容分享社区之一,为技术极客提供了乐点的一个写作、分享的平台,在这里你可以分享你的技术见解与疑问。 社区产品形态为问答和文章,问答专注于分享探讨技术问题,从而获取问题的解决方法。文章是一个基于内容分享的模块,主要为技...
继续阅读 »

OpenSkill中国技术极客IT技术问答、内容分享社区之一,为技术极客提供了乐点的一个写作、分享的平台,在这里你可以分享你的技术见解与疑问。

社区产品形态为问答和文章,问答专注于分享探讨技术问题,从而获取问题的解决方法。文章是一个基于内容分享的模块,主要为技术工作者提供一个知识共享、经验积累、资源分享的环境。

社区创建的出发点是基于社区发起人本身是做技术出身,平常工作经常会遇到一些技术问题和错误,但是经常需要借助Google、百度等搜索引擎去寻找答案,非常痛苦,寻找过程就算了,最可悲的是再次遇到相同的问题,又需要再一次的去搜索,所以基于这个痛点,OpenSkill开源技术社区就建立起来了!

如果你热爱写作和分享,这是一个自由的写作、技术分享的社区,让我们一起分享工作中遇到的问题一起探讨,分享解决问题的文章,共享你的技术资源!

The open skill sharing Geek ! 

关注我们:

合作联系QQ:986978241
微信号:crhins  添加请备注原由
QQ群:948510543  欢迎加入互相学习
微信公众号:后场技术    ID:opstalk
微博:http://weibo.com/openskill

收起阅读 »