1. 程式人生 > 其它 >MySQL --- 讀書筆記 --- 查詢優化

MySQL --- 讀書筆記 --- 查詢優化

ansible安裝

yum -y install ansible
#如果是內網安裝,外網機相同環境機器,執行
yum -y install ansible --downloadonly --downloaddir=/root/ansible

ansible預設模組為command,可以根據需要修改為shell

vim /etc/ansible/ansible.cfg
#開啟log日誌
log_path = /var/log/ansible.log
#將預設模組由command修改為shell
module_name = shell
#取消密碼驗證確認(如果不設定該選項,使用ansible進行連線從未連線的主機時,會報錯)
host_key_checking = False

接下來設定主機清單

vim /etc/ansible/hosts
#新增主機清單
[name]
ip
#例項
[test1]
192.168.221.151
如果使用密碼連線(埠22可忽略ansible_ssh_port)
[test1]
192.168.221.151 ansible_ssh_user=root ansible_ssh_pass=123456 ansible_ssh_port=22
#如果使用ssh免密登入,需要生成ssh證書
[root@ansible_servcie ~]# ssh-keygen
[root@ansible_servcie ~]# ssh-copy-id ip地址

主機清單設定完成後,可通過ping模組檢視

#-m ping為呼叫ping模組
ansible test1 -m ping

ansible常用模組
可通過ansible-doc -s 模組名稱 檢視具體命令

command 預設模組
shell 執行被控端機器的指令碼
script 執行本機指令碼在被控端生效
copy 將本機檔案複製到被控端
fetch 將被控端檔案複製到本機
file 控制被控端檔案或資料夾
unarchive 解壓本機檔案道被控端或解壓被控端檔案
cron 設定被控端機器定時任務
setup 檢視被控端配置(filter)篩選
yum 被控端安裝檔案
user 被控端使用者管理
group 被控端使用者組管理
service 服務管理模組

列舉最簡單的一個copy的playbook指令碼

cat test.yml
---
#This is a yml to copy file to host
- hosts: test1
  remote_user: root

  tasks:
    - name: copy file to host
      unarchive: src=/root/1.sh dest=/root