首页 > 代码库 > 学习杂记20170801
学习杂记20170801
没有系统化,想到哪里就写到哪里
centos6.5_x64下修改root和普通用户的ulimit 值
cat /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
[hehe@centos65-1-43 ~]$ ulimit -n
65535
[hehe@centos65-1-43 ~]$
centos7.2_x64下也是修改相同位置,不过貌似要重启系统
最近在用ansible,被控端为centos7.2。下面的命令执行都是ok的,现在要将他们转换成playbooks模板,即后缀为yml的文件。
ansible webservers -m shell -a "yum -y install crontabs"
ansible webservers -m shell -a "/bin/systemctl start crond.service"
ansible webservers -m shell -a "rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm"
ansible webservers -m shell -a "yum install zabbix-agent -y"
ansible webservers -m shell -a "mkdir -p /etc/zabbix/scripts"
ansible webservers -m copy -a "src=http://www.mamicode.com/root/webservers.py dest=/etc/zabbix/scripts/ owner=root group=root mode=0755"
ansible webservers -m copy -a "src=http://www.mamicode.com/root/weifuwu.sh dest=/etc/zabbix/scripts/ owner=root group=root mode=0755"
ansible webservers -m copy -a "src=http://www.mamicode.com/root/zabbix_agentd.conf dest=/etc/zabbix/zabbix_agentd.conf"
ansible webservers -m shell -a "/usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf"
ansible webservers -m cron -a "minute=‘*/5‘ job=‘/usr/bin/python /etc/zabbix/scripts/webservers.py >/dev/null 2>&1‘"
写了很多次都是失败的
[root@centos65-1-43 ~]# cat /etc/ansible/hosts
[webservers]
192.168.1.62
- name: zabbix_client
hosts: webservers
user: root
tasks:
- name: install crontabs
yum: pkg=crontabs state=latest
notify:
- restart crontabs
tasks:
- name: install zabbix_epel
command: rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
- name: install zabbix_agentd
yum: pkg=zabbix-agent state=latest
- name: mkdir
command: mkdir -p /etc/zabbix/scripts
- name: copy files
copy: src=http://www.mamicode.com/root/webservers.py dest=/etc/zabbix/scripts/
- name: start zabbix-agentd
command: /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
- name: make crontab
cron: minute=‘*/5‘ job=‘/usr/bin/python /etc/zabbix/scripts/webservers.py >/dev/null 2>&1‘
handlers:
- name: restart crontabs
service: name=crond state=restarted
经常因为网络不好找不到yum源导致执行的失败而跳出
TASK [install zabbix_agentd] ******************************************************************************************************************************
fatal: [192.168.1.62]: FAILED! => {"changed": true, "failed": true, "msg": "http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-agent-3.2.7-1.el7.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found\nTrying other mirror.\nTo address this issue please refer to the below knowledge base article \n\nhttps://access.redhat.com/articles/1320623\n\nIf above article doesn‘t help to resolve this issue please create a bug on https://bugs.centos.org/\n\n\n\nError downloading packages:\n zabbix-agent-3.2.7-1.el7.x86_64: [Errno 256] No more mirrors to try.\n\n", "rc": 1, "results": ["Loaded plugins: fastestmirror, langpacks\nLoading mirror speeds from cached hostfile\n * epel: mirrors.ustc.edu.cn\nResolving Dependencies\n--> Running transaction check\n---> Package zabbix-agent.x86_64 0:3.2.7-1.el7 will be installed\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n================================================================================\n Package Arch Version Repository Size\n================================================================================\nInstalling:\n zabbix-agent x86_64 3.2.7-1.el7 zabbix 345 k\n\nTransaction Summary\n================================================================================\nInstall 1 Package\n\nTotal download size: 345 k\nInstalled size: 1.3 M\nDownloading packages:\n"]}
to retry, use: --limit @/root/0801.retry
学习杂记20170801