博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
m5-第9周作业
阅读量:6452 次
发布时间:2019-06-23

本文共 3672 字,大约阅读时间需要 12 分钟。

1 写出ansible部署rsync服务的playbook剧本内容

[root@m01 playbook]# cat /etc/ansible/hosts[rsync_server]172.16.1.41  [rsync_client]172.16.1.31  事先准备好rsyncd.conf、password等文件[root@m01 server]# tree /server/conf//server/conf/└── rsync_conf    ├── rsync_client.password    ├── rsyncd.conf    └── rsync.password  剧本内容[root@m01 playbook]# vim /server/playbook/rsync.yml - hosts:rsync_server  tasks:    - name: s01:install rsync      yum: name=rsync state=installed    - name: s02:create rsync user      user: name=rsync state=present createhome=no shell=/sbin/nologin    - name: s03:create backup dir      file: dest=/backup state=directory owner=rsync group=rsync    - name: s04:create auth file      copy: src=/server/conf/rsync_conf/rsync.password dest=/etc/ mode=600    - name: s05:edit rsync conf file      copy: src=/server/conf/rsync_conf/rsyncd.conf dest=/etc/      - name: s06:start rsync server      shell: rsync --daemon creates=/var/run/rsyncd.pid          - hosts: rsync_client  tasks:    - name: s01:install rsync      yum: name=rsync state=installed    - name: s02:create auth file      copy: src=/server/conf/rsync_conf/rsync_client.password dest=/etc/rsync.password mode=600

 

2 通过ansible剧本部署nfs客户端与服务端

要求

服务端分享/data目录
客户端backup服务器把/data目录挂载到/nfsbackup目录中

[root@m01 playbook]# cat nfs.yml - hosts: 172.16.1.31  tasks:    - name: s01:install nfs-utils rpcbind      yum: name=nfs-utils,rpcbind state=installed    - name: s02:start rpcbind      service: name=rpcbind state=started    - name: s02:start nfs      service: name=nfs state=started      - name: s03:auto start nfs      shell: chkconfig nfs on    - name: s03:auto start rpcbind      shell: chkconfig rpcbind on    - name: s04:share to machine      shell: echo "/data 172.16.1.0/24(rw,sync)" >> /etc/exports    - name: s05:create data dir      file: dest=/data state=directory owner=nfsnobody group=nfsnobody    - name: s06:nfs reload        shell: /etc/init.d/nfs reload       - hosts: 172.16.1.41  tasks:    - name: s01:install nfs-utils rpcbind      yum: name=nfs-utils,rpcbind state=installed    - name: s01:start rpcbind       service: name=rpcbind state=started    - name: s02:auto start      shell: chkconfig rpcbind on    - name: s02:auto start nfs      shell: chkconfig nfs off    - name: s03:create nfsbackup dir      file: dest=/nfsbackup state=directory     - name: s04:mount data to nfsbackup      command: mount -t nfs 172.16.1.31:/data /nfsbackup

3 通过剧本部署配置sersync数据同步服务

nfs端ip 172.16.1.31 [root@m01 playbook]#cat /server/playbook/sersync.yml - hosts: 172.16.1.31  tasks:     - name: s01:install inotify-tools      yum: name=epel-release,inotify-tools state=installed    - name: s02:install sersync       script: /server/scripts/sersync.sh    - name: s03:edit sersync conf      copy: src=/server/conf/sersync_conf.xml dest=/usr/local/sersync/confxml.xml     - name: s04: run sersync      shell: sersync -d -r -o /usr/local/sersync/confxml.xml        sersync.sh安装脚本内容     [root@m01 playbook]# cat /server/scripts/sersync.shmkdir -p /home/oldboy/tools &&cd /home/oldboy/tools  &&wget https://raw.githubusercontent.com/orangle/sersync/master/release/sersync2.5.4_64bit_binary_stable_final.tar.gz  &&tar zxf sersync2.5.4_64bit_binary_stable_final.tar.gz  &&mv GNU-Linux-x86/ /usr/local/sersync /server/conf/sersync_conf.xml 的内容不再列出 backup 备份服务器端rsync 服务前面已经配置过了   测试 [root@nfs01-clone data]# touch ansible_to_install_sersync.txt[root@nfs01-clone data]# lltotal 0-rw-r--r--. 1 root root 0 Aug 19 09:55 ansible_to_install_sersync.txt   [root@backup-clone ~]# ll /nfsbackup/total 0-rw-r--r--. 1 root root 0 Aug 19 09:55 ansible_to_install_sersync.txt

  

 

 

 

转载于:https://www.cnblogs.com/wenyule/articles/10529779.html

你可能感兴趣的文章
Webstorm常用快捷键备忘
查看>>
js滚动加载到底部
查看>>
关于mac远程链接window服务器以及实现共享文件
查看>>
Redis慢查询,redis-cli,redis-benchmark,info
查看>>
Virtualbox 虚拟机网络不通
查看>>
java概念基础笔记整理
查看>>
self parent $this关键字分析--PHP
查看>>
CC_UNUSED_PARAM 宏含义的解释
查看>>
leetcode124二叉树最大路径和
查看>>
AngularJS笔记整理 内置指令与自定义指令
查看>>
shell与正则表达式
查看>>
第三篇:白话tornado源码之请求来了
查看>>
表示数值的字符串
查看>>
JQUERY AJAX请求
查看>>
html css 伪样式
查看>>
超级账本Fabric区块链用弹珠游戏Marbles 部署
查看>>
整理Java基础知识--选择与判断
查看>>
Linux查看程序端口占用情况
查看>>
jar包冲突案例分析.md
查看>>
控制圈复杂度的9种重构技术总结
查看>>