练习:用 playbook 部署 zabbix 和 tidb

📅 2026/8/20 12:25:34
练习:用 playbook 部署 zabbix 和 tidb
1 部署zabbix-server[devopsserver1 ansible]$vimzabbix-server.yml前端可以访问新建目录将变量写进/home/devops/ansible/host_vars/server2下的vault文件并进行加密[devopsserver1 server2]$vimvault[devopsserver1 server2]$ ansible-vault encrypt vault将playbook中相应的变量替换[devopsserver1 server2]$cd../..[devopsserver1 ansible]$vimzabbix-server.yml[devopsserver1 ansible]$ ansible-playbook zabbix-server.yml --ask-vault-pass2 部署zabbix-agent首先尝试用 zabbix.zabbix 自动部署[devopsserver1 ~]$ ansible-galaxy collectioninstallzabbix.zabbix[devopsserver1 ansible]$vimzabbix-agent.yml[devopsserver1 ansible]$ ansible-playbook zabbix-agent.yml --ask-vault-pass排错[devopsserver1 ~]$ ansible-galaxy collection download ansible.netcommon:6.1.3 ansible.utils:4.1.0-p./collections[devopsserver1 ~]$ls-la/home/devops/collections/[devopsserver1 ~]$cd/home/devops/collections[devopsserver1 collections]$ ansible-galaxy collectioninstallansible-netcommon-6.1.3.tar.gz[devopsserver1 collections]$ ansible-galaxy collection list|grep-Enetcommon|utilsansible.netcommon6.1.3 ansible.utils4.1.0重新运行[devopsserver1 ansible]$vimzabbix-agent.yml[devopsserver1 ansible]$ ansible-playbook zabbix-agent.yml --ask-vault-passagent 软件在 server4 部署成功但 api 调用有问题经过多轮排错没有解决问题由于版本兼容性问题一直在换版本此时使用的服务版本号如下图3 部署 tidb在一台新的虚拟机server3上部署tidb添加用户进行提权还要对自己做免密连接[rootserver3 ~]# useradd devops[rootserver3 ~]# passwd devops[rootserver3 ~]# visudo[devopsserver1 ansible]$vimtidb.yml[devopsserver1 ansible]$ ansible-playbook tidb.yml在server3上查看[devopsserver1 ansible]$vimtidb-server3.yml[devopsserver1 ansible]$ ansible-playbook tidb-server3.yml --ask-vault-pass在server3上查看