ansible

netstat -an查看到大量的TIME_WAIT状态的解决办法

老子叫甜甜 提交于 2020-01-07 18:46:53
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> netstat -an |grep 1521 |wc -l 6688 netstat -an |grep 1521 tcp 0 0 11.0.15.88:1521 11.0.15.66:57297 TIME_WAIT 状态全是 time_wait netstat下time_wait状态的tcp连接: 1.这是一种处于连接完全关闭状态前的状态; 2.通常要等上4分钟(windows server)的时间才能完全关闭; 3.这种状态下的tcp连接占用句柄与端口等资源,服务器也要为维护这些连接状态消耗资源; 4.解决这种time_wait的tcp连接只有让服务器能够快速回收和重用那些TIME_WAIT的资源 在LINUX下得处理: vi /etc/sysctl.conf 新增如下内容: net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_syncookies=1 使内核参数生效: [root@web02 ~]# sysctl -p readme: net.ipv4.tcp_syncookies=1 打开TIME-WAIT套接字重用功能,对于存在大量连接的Web服务器非常有效。 net.ipv4.tcp_tw_recyle=1 net

Ansible配合Virtualenv安装配置

岁酱吖の 提交于 2020-01-07 18:41:51
Ansible的两种安装模式(Centos7) 1.Yum包管理安装 #yum -y install ansible 2.Git源代码安装[推荐] git clone https://github.com/ansible/ansible.git ​ ​ ​ 演示 新安装一个虚拟机,可以使用xshell连接,使用git bash连接 ssh root@192.168.96.188 安装准备工作,关闭防火墙,关闭selinux安全策略 安装python #wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz 解压 #tar xf Python-3.6.5.tgz 配置编译 #./configure --prefix=/usr/local/ --with-ensurepip=install --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" --with-ssl 编译 #make && make altinstall 查看pip的路径 #which pip3.6 给pip做一个软链接 #ln -s /usr/local/bin/pip3.6 /usr/local/bin/pip 安装virtualenv工具 # yum install openssl-devel -y

ansible配置与说明

跟風遠走 提交于 2020-01-07 12:44:27
一、ansibles配置与测试 1、ansible的安装配置 利用公钥批量管理 [root@LB02 ~]# ssh-keygen -t rsa #创建公钥 [root@LB02 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.11.206 #将公钥拷贝到管理主机中.ssh/authorized_keys文件中,实现免密码登录远程管理主机 [root@LB02 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.11.207 #将公钥拷贝到管理主机中.ssh/authorized_keys文件中,实现免密码登录远程管理主机 注: 如果在生成密钥的时候设置了密码,ansible每次执行命令的时候,都会提示输入密钥密码,可通过下面的命令记住密码。 ssh-agent bsh ssh-add ~/.ssh/id_rsa 2、控制端安装ansible程序 在线安装: [root@LB02 ~]# yum install epel-release -y [root@LB02 ~]# yum install ansible -y 离线安装: [root@LB02 ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release

Ansible: apply when to complete loop

 ̄綄美尐妖づ 提交于 2020-01-07 07:25:40
问题 I want to combine a loop in ansible with a when-statement applied to it. When-statements are applied to each loop iteration however, which takes away the possibility to apply one to the complete loop. Does anyone know how to do this? I've run into this problem before, but in this specific case it concerns a variable that might or might not exist. What I would want to do is something like: - name: Loop debug: msg: "{{ item }}" with_items: x.y|default([]) but-only-run-this-loop-when: x is

Ansible: apply when to complete loop

ⅰ亾dé卋堺 提交于 2020-01-07 07:25:09
问题 I want to combine a loop in ansible with a when-statement applied to it. When-statements are applied to each loop iteration however, which takes away the possibility to apply one to the complete loop. Does anyone know how to do this? I've run into this problem before, but in this specific case it concerns a variable that might or might not exist. What I would want to do is something like: - name: Loop debug: msg: "{{ item }}" with_items: x.y|default([]) but-only-run-this-loop-when: x is

Change variable in Ansible template based on group with children?

时光总嘲笑我的痴心妄想 提交于 2020-01-07 05:23:48
问题 I found Change variable in Ansible template based on group. However how do I extend the answer in groups with children? If I extend the group vars file in the link above to [host0] host0.my-network.com [host1] host1.my-network.com [es-masters:children] host0 host1 How can I extend the above post's answer (shown below) to make it work with the group vars file above? Simply putting the FQDN in the jinja2 statement does not work. {% if ansible_fqdn in groups['es-masters'] %} node_master=true {%

Change variable in Ansible template based on group with children?

纵然是瞬间 提交于 2020-01-07 05:23:04
问题 I found Change variable in Ansible template based on group. However how do I extend the answer in groups with children? If I extend the group vars file in the link above to [host0] host0.my-network.com [host1] host1.my-network.com [es-masters:children] host0 host1 How can I extend the above post's answer (shown below) to make it work with the group vars file above? Simply putting the FQDN in the jinja2 statement does not work. {% if ansible_fqdn in groups['es-masters'] %} node_master=true {%

How to get the installed apt packages with Ansible?

你。 提交于 2020-01-07 04:10:28
问题 I am trying to list all installed packages on my Debian 7/8/9 machines. There are easy ways dealing with it using apt or dpkg but I could not find a proper way to do this with ansible out of the box. Is there a nice and smooth way to do this? For RHEL machines I found this Post: How to get the installed yum packages with Ansible? 回答1: It doesn't look like Ansible provides any modules that would support this. You'll have to use shell or command . - name: Get packages shell: dpkg-query -f '$

How to use wildcard with variable [duplicate]

社会主义新天地 提交于 2020-01-07 03:46:11
问题 This question already has answers here : Ansible Command module says that '|' is illegal character (2 answers) Closed last year . I want to list the files as per the host name.But problem is i not able to use the wildcard with variable properly.Can someone suggest me on this. --- - hosts: local become_user: yes vars: filename: /root/stuff tasks: - name: list files action: command ls -lrt {{ filename }}/'*{{ansible_hostname}}' register: listfiles - debug: var=listfiles 回答1: If your question is

How to make a list of pairs unique in Jinja?

主宰稳场 提交于 2020-01-07 01:22:09
问题 I have a dictionary with array values coming from an Ansible vars file. ipfilter: zone1: - { application: "app 1", local_ip: 1.1.1.1 } - { application: "app 1", local_ip: 1.1.1.1 } - { application: "app 2", local_ip: 2.2.2.2 } zone2: - { application: "app 3", local_ip: 3.3.3.3 } - { application: "app 4", local_ip: 4.4.4.4 } - { application: "app 4", local_ip: 4.4.4.4 } The problem is, that the tuple of application and local_ip is not unique, because the objects contain additional data, which