m5-第9周作业

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.sh
mkdir -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]# ll
total 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值