在工作中有些时候需要搭建Elasticsearch数据库提供搜索功能或者结合logstash与kibana实现日志的收集与绘制工作。如果在工作中仅实现业务搜索功能,则只要搭建好数据库给开发使用即可。预备知识:
1、linux操作系统基本概念
2、熟悉linux命令行操作
3、熟悉linux基本命令
实施要求:
搭建Elasticsearch,能保证正常运行,能进行增删改查等操作即可
(1) 在管理设备上安装Ansible软件 yum install -y ansiblewget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
(2) 生成密钥对,并将密钥对分发到受控端上,即所有被管理的设备ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsassh-copy-id -i ~/.ssh/id_rsa.pub root@10.0.0.15注意:如果没有进行以上操作,那么后面在编辑主机清单时需要指定ssh密码等信息(4) 配置主机清单,将被管理设备都添加到client这个组中(5) 编写playbook,定义hosts、tasks、handlers等,期间需要使用到yum、copy、service等模块. yum: name=httpd state=installed - name: configure httpd.conf copy: src=/etc/httpd/conf/httpd.conf dest=/etc/httpd/conf/httpd.conf notify: Restart httpd service - name: start httpd service service: name=httpd state=started enabled=yes - name: Restart httpd service service: name=httpd state=restarted(6) 使用ansible-playbook -C命令验证playbook是否能正常执行ansible-playbook -C http.yaml(7) 使用ansible-playbook palybook-name执行剧本完成需求ansible-palyboox http.yamlansible client -m shell -a "ss -lntup|grep http"本项目案例由学师堂洪鸽老师设计,如果需要查看更详细的项目提示和在线指导,可登录我们的在线学习社区系统(www.52LAB.com.cn)学习。
