日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
CentOS7使用Ansible發(fā)布多個Tomcat服務(wù)

1,使用ansible

2,比如發(fā)布兩個tomcat

發(fā)布一個手機端,web的和admin的tomcat。
tomcat-mobile
tomcat-web
tomcat-admin
假設(shè)分別在 3個服務(wù)器上面
192.168.100.101
192.168.100.102
192.168.100.103
tomcat 線上的目錄是:
/data/tomcat-mobile
/data/tomcat-web
/data/tomcat-admin

配置/etc/ansible/hosts

[tomcat-mobile]
tomcat-mobile-01 ansible_ssh_host=192.168.100.101 ansible_ssh_port=22 ansible_ssh_user=root
[tomcat-web]
tomcat-web-01 ansible_ssh_host=192.168.100.101 ansible_ssh_port=22 ansible_ssh_user=root
[tomcat-admin]
tomcat-admin-01 ansible_ssh_host=192.168.100.101 ansible_ssh_port=22 ansible_ssh_user=root

3,創(chuàng)建一個通用的tomcat.yml

tomcat部署模板。其中tomcat_root 和 war_file是變量。
在每一個類型的部署yml中定義。

- name: stop tomcat. command: /bin/sh {{ tomcat_root }}/../../bin/catalina.sh stop -force ignore_errors: yes async: 10 - name: rm ROOT. file: state: absent dest: "{{ tomcat_root }}" - name: mkdir ROOT. file: state: directory dest: "{{ tomcat_root }}" - name: unzip war. unarchive: src: "{{ war_file }}" dest: "{{ tomcat_root }}" copy: yes - name: rm war. file: state: absent dest: "{{ war_file }}" - name: start tomcat. command: /bin/sh {{ tomcat_root }}/../../bin/catalina.sh start ignore_errors: yes async: 10

然后創(chuàng)建 3 個yml
tomcat-mobile.yml

---
- name: install tomcat-mobile
  hosts: tomcat-mobile
  sudo: False
  vars:
    war_file: /data/build/tomcat-mobile.war
    tomcat_root: /data/tomcat-mobile/webapps/ROOT
  tasks:
    - name: Include local facts tasks
      include: tomcat.yml

tomcat-web.yml:

---
- name: install tomcat-web
  hosts: tomcat-web
  sudo: False
  vars:
    war_file: /data/build/tomcat-web.war
    tomcat_root: /data/tomcat-web/webapps/ROOT
  tasks:
    - name: Include local facts tasks
      include: tomcat.yml

tomcat-admin.yml:

---
- name: install tomcat-admin
  hosts: tomcat-admin
  sudo: False
  vars:
    war_file: /data/build/tomcat-admin.war
    tomcat_root: /data/tomcat-admin/webapps/ROOT
  tasks:
    - name: Include local facts tasks
      include: tomcat.yml

4,總結(jié)

執(zhí)行部署:
/usr/bin/ansible-playbook tomcat-mobile.yml。
ansible 使用include的解決了腳本的重復(fù)編寫問題。
將變量設(shè)置,可以同時部署多個tomcat。并且根據(jù)hosts的分組配置。當(dāng)tomcat-web部署多臺之后,將ssh打通后配置即可。非常簡單的就按組進行擴展部署了。


網(wǎng)站標(biāo)題:CentOS7使用Ansible發(fā)布多個Tomcat服務(wù)
瀏覽路徑:http://www.dlmjj.cn/article/djdsedo.html