ansible生产案例

1.一键安装配置MQ:
1.1.上传IBM MQ介质到root下面:
1.2上传MQ配置文件到root下面:
QM1配置文件详解
cat /root/QM1.txt
DEFINE QL('MSGCCPC_1') MAXDEPTH(999999999) MAXMSGL(9194304) DEFPSIST(YES) REPLACE
DEF QL('DEADQ') MAXDEPTH(290000) DEFPSIST(yes) REPLACE
ALTER QMGR DEADQ(DEADQ)
DEF LISTENER(LSNRPMTS) TRPTYPE(TCP) PORT(1414) BACKLOG(0) CONTROL(QMGR)
START LISTENER(LSNRPMTS)
DEF QL(XM2900A) USAGE(XMITQ) MAXDEPTH(290000) TRIGGER TRIGTYPE(FIRST) INITQ(SYSTEM.CHANNEL.INITQ) DEFPSIST(yes) MAXMSGL(10240000) TRIGDATA(QM1) REPLACE
DEF CHL(QM1) CHLTYPE(SDR) LOCLADDR(10.160.1.236) CONNAME('10.160.1.39(1414)') XMITQ(XM2900A) TRPTYPE(tcp) MAXMSGL(10240000) DISCINT(0) SHORTRTY(10000) SHORTTMR(30) LONGTMR(300) LONGRTY(999999999) BATCHSZ(50) REPLACE
START CHL(QM1)
DEF QR(MSGCCPC_2) RNAME(MSGCCPC_BANK_1) RQMNAME(QM2) XMITQ(XM2900A) DEFPSIST(yes) REPLACE
DEF CHL(QM2) CHLTYPE(RCVR) TRPTYPE(tcp) MAXMSGL(10240000) REPLACE
DEFINE CHANNEL(QM1.SVRCONN) CHLTYPE(SVRCONN) REPLACE
cat /root/QM1.txt
DEFINE QL('MSGCCPC_1') MAXDEPTH(999999999) MAXMSGL(9194304) DEFPSIST(YES) REPLACE
DEF QL('DEADQ') MAXDEPTH(290000) DEFPSIST(yes) REPLACE
ALTER QMGR DEADQ(DEADQ)
DEF LISTENER(LSNRPMTS) TRPTYPE(TCP) PORT(1414) BACKLOG(0) CONTROL(QMGR)
START LISTENER(LSNRPMTS)
DEF QL(XM2900A) USAGE(XMITQ) MAXDEPTH(290000) TRIGGER TRIGTYPE(FIRST) INITQ(SYSTEM.CHANNEL.INITQ) DEFPSIST(yes) MAXMSGL(10240000) TRIGDATA(QM1) REPLACE
DEF CHL(QM1) CHLTYPE(SDR) LOCLADDR(10.160.1.236) CONNAME('10.160.1.39(1414)') XMITQ(XM2900A) TRPTYPE(tcp) MAXMSGL(10240000) DISCINT(0) SHORTRTY(10000) SHORTTMR(30) LONGTMR(300) LONGRTY(999999999) BATCHSZ(50) REPLACE
START CHL(QM1)
DEF QR(MSGCCPC_2) RNAME(MSGCCPC_BANK_1) RQMNAME(QM2) XMITQ(XM2900A) DEFPSIST(yes) REPLACE
DEF CHL(QM2) CHLTYPE(RCVR) TRPTYPE(tcp) MAXMSGL(10240000) REPLACE
DEFINE CHANNEL(QM1.SVRCONN) CHLTYPE(SVRCONN) REPLACE
QM2配置文件详解
[root@oldboy1 ~]# cat /root/QM2.txt
DEFINE QL('MSGCCPC_BANK_1') MAXDEPTH(999999999) MAXMSGL(9194304) DEFPSIST(YES) REPLACE
DEF QL('DEADQ') MAXDEPTH(290000) DEFPSIST(yes) REPLACE
ALTER QMGR DEADQ(DEADQ)
DEF LISTENER(LSNRPMTS) TRPTYPE(TCP) PORT(1414) BACKLOG(0) CONTROL(QMGR)
START LISTENER(LSNRPMTS)
DEF QL(XM2900A) USAGE(XMITQ) MAXDEPTH(290000) TRIGGER TRIGTYPE(FIRST) INITQ(SYSTEM.CHANNEL.INITQ) DEFPSIST(yes) MAXMSGL(10240000) TRIGDATA(QM2) REPLACE
DEF CHL(QM2) CHLTYPE(SDR) LOCLADDR(10.160.1.39) CONNAME('10.160.1.236(1414)') XMITQ(XM2900A) TRPTYPE(tcp) MAXMSGL(10240000) DISCINT(0) SHORTRTY(10000) SHORTTMR(30) LONGTMR(300) LONGRTY(999999999) BATCHSZ(50) REPLACE
START CHL(QM2)
DEF QR(MSGCCPC_2) RNAME(MSGCCPC_BANK_1) RQMNAME(QM1) XMITQ(XM2900A) DEFPSIST(yes) REPLACE
DEF CHL(QM1) CHLTYPE(RCVR) TRPTYPE(tcp) MAXMSGL(10240000) REPLACE
DEFINE CHANNEL(QM2.SVRCONN) CHLTYPE(SVRCONN) REPLACE
1.3 配置ansible hosts文件
[root@oldboy1 ~]# cat /etc/ansible/hosts
[oldboy]
10.160.1.39 ansible_ssh_user=root ansible_ssh_pass=123456
10.160.1.236 ansible_ssh_user=root ansible_ssh_pass=123456
[QM1]
10.160.1.236 ansible_ssh_user=mqm ansible_ssh_pass=Ma17636013821
[QM2]
10.160.1.39 ansible_ssh_user=mqm ansible_ssh_pass=Ma17636013821
1.4 ansible-playbook详解:
cat /etc/ansible/yaml/oldboy.yaml

  • hosts: oldboy
    tasks:

    • name: copy文件
      copy: src=/root/IBM_MQ_9.2.1_LINUX_X86-64.tar.gz dest=/root/IBM_MQ_9.2.1_LINUX_X86-64.tar.gz backup=yes
    • name: 解压mq文件
      shell: tar xf /root/IBM_MQ_9.2.1_LINUX_X86-64.tar.gz
    • name: mq接受license
      shell: /root/MQServer/mqlicense.sh -accept
    • name: 安装mq
      shell: rpm -ivh /root/MQServer/MQSeries*
    • name: 修改mqm密码
      user: name=mqm password=Ma17636013821
  • hosts: QM1
    tasks:

    • name: 创建QM1队列管理器
      shell: /opt/mqm/bin/crtmqm QM1
    • name: 启动QM1队列管理器
      shell: /opt/mqm/bin/strmqm QM1
    • name: cp队列通道文件
      copy: src=/root/QM1.txt dest=/var/mqm/QM1.txt backup=yes
    • name: 将队列信息导入mq
      shell: /opt/mqm/bin/runmqsc QM1
  • hosts: QM2
    tasks:

    • name: 创建QM1队列管理器
      shell: /opt/mqm/bin/crtmqm QM2
    • name: 启动QM1队列管理器
      shell: /opt/mqm/bin/strmqm QM2
    • name: cp队列通道文件
      copy: src=/root/QM2.txt dest=/var/mqm/QM2.txt backup=yes
    • name: 将队列信息导入mq
      shell: /opt/mqm/bin/runmqsc QM2 1.5 执行ansible-playbook文件命令:
      ansible-playbook oldboy.yaml

你可能感兴趣的:(ansible生产案例)