原創:一鍵化部署百台伺服器級別後端伺服器

来源:http://www.cnblogs.com/dsab/archive/2017/09/11/7503702.html
-Advertisement-
Play Games

在管理端一鍵部署nfs rsync 並且實時同步 實現非密碼非互動式一鍵部署 還會繼續增加新的東西 未完待續 ip:管理 61 nfs 131 rsync 141 web 108 管理端 : 齊天大聖的總的腳本 [root@m01 tools]# cat quanwang.sh#!/bin/bash ...


在管理端一鍵部署nfs  rsync 並且實時同步  實現非密碼非互動式一鍵部署

還會繼續增加新的東西 未完待續

ip:管理 61 nfs 131 rsync 141 web 108

管理端 :

齊天大聖的總的腳本

[root@m01 tools]# cat quanwang.sh
#!/bin/bash
sh /server/scripts/piliangceshimiyao.sh
ansible-playbook /server/tools/rsyncpiliang.yml
ansible-playbook /server/tools/nfspiliang.yml
ansible-playbook /server/tools/quanwang.yml

齊天大聖的分腳本

1./server/scripts/piliangceshimiyao.sh

 

[root@m01 tools]# cat /server/scripts/piliangceshimiyao.sh
#!/bin/bash
#生成密鑰
\rm -f /root/.ssh/id_dsa*
ssh-keygen -t dsa -f /root/.ssh/id_dsa -P "" -q


#發送密鑰
for ip in 61 108 131 141
do
echo "==== 現在分發 172.16.1.$ip=========="
sshpass -p123456 ssh-copy-id -i /root/.ssh/id_dsa.pub "-o StrictHostKeyChecking=no [email protected].$ip"
echo "==============end======="
echo
echo
done

 

2.ansible-playbook /server/tools/rsyncpiliang.yml

 

[root@m01 tools]# cat ansible-playbook /server/tools/rsyncpiliang.yml
cat: ansible-playbook: No such file or directory
- hosts: 172.16.1.141 #服務端
tasks:
- name: yum
shell: yum install -y rsync #安裝rsync
- name: yunm
shell: yum -y install sshpass #安裝密鑰的軟體
- name: chuangjianmulu
shell: mkdir -p /server/tools/ #創建所在配置的文件
- name: peizhi
copy: src=/server/tools/peizhi.sh dest=/server/tools/peizhi.sh
- name: yunxing
script: /server/tools/peizhi.sh #運行腳本
- name: guanliyunhu
shell: useradd -s /sbin/nologin -M rsync #創建rsync虛擬用戶
- name: anquanwenjian
shell: echo "rsync_backup:oldboy123" >/etc/rsync.password #設置密碼文件
- name: quanxian
shell: chmod 600 /etc/rsync.password #給予許可權
- name: beifenmulu
shell: mkdir -p /backup && chown -R rsync.rsync /backup
- name: qidong
shell: rsync --daemon #運行rsync
- hosts: 172.16.1.108
tasks:
- name: yum
shell: yum install -y rsync # 客戶端
- name: chuangjianmulu
shell: mkdir -p /server/tools/
- name: mimawenjian
shell: echo "oldboy123" >/etc/rsync.password && chmod 600 /etc/rsync.password
- hosts: 172.16.1.131
tasks:
- name: yum
shell: yum install -y rsync #客戶端
- name: chuangjianmulu
shell: mkdir -p /server/tools/
- name: mimawenjian
shell: echo "oldboy123" >/etc/rsync.password && chmod 600 /etc/rsync.password

 

 

3.ansible-playbook /server/tools/nfspiliang.yml

 

- hosts: 172.16.1.131 #服務端
tasks:
- name: yum
shell: yum install -y nfs-utils rpcbind #安裝nfs
- name: yunm
shell: yum -y install sshpass #安裝密鑰的軟體
- name: chuangjianmulu
shell: mkdir -p /server/tools/ #創建所在配置的文件
- name: peizhi
copy: src=/server/tools/nfspeizhi.sh dest=/server/tools/nfspeizhi.sh
- name: yunxingjiaoben
script: /server/tools/nfspeizhi.sh #運行腳本
- name: guanlimulu
shell: mkdir -p /data && chown -R nfsnobody.nfsnobody /data
- name: qidong
shell: /etc/init.d/rpcbind start && /etc/init.d/nfs start #啟動
- name: kaijiqidong
shell: chkconfig rpcbind on && chkconfig nfs on
#設置密碼文件
- hosts: 172.16.1.108
tasks:
- name: yum
shell: yum install -y nfs-utils rpcbind # 客戶端
# - name: gui
# shell: umount -f /mnt
- name: guazai
shell: mount -t nfs 172.16.1.131:/data /mnt
- hosts: 172.16.1.141
tasks:
- name: yumh
shell: yum install -y nfs-utils rpcbind #客戶端
# - name: guih
# shell: umount -f /mnt
- name: guazaih
shell: mount -t nfs 172.16.1.131:/data /mnt

 

4.ansible-playbook /server/tools/quanwang.yml

 

 

- hosts: 172.16.1.61
tasks:
# - name: anzhuangrsync
# shell: /server/scripts/piliangceshimiyao.sh
# - name: anzhuangrsync
# shell: /server/tools/rsyncpiliang.yml
# - name: anzhuangnfs
# shell: /server/tools/nfspiliang.yml
- hosts: 172.16.1.141
tasks:
- name: chuangjianmulu141
shell: mkdir -p /server/tools/ #創建所在配置的文件
- name: peizhi141
copy: src=/server/tools/quanwangrsync.sh dest=/server/tools/quanwangrsync.sh
- name: rsyncdajian141
script: /server/tools/quanwangrsync.sh
- hosts: 172.16.1.108
tasks:
- name: chuangjianmulu108
shell: mkdir -p /server/tools/ #創建所在配置的文件
- name: peizhi108
copy: src=/server/tools/quanwangweb.sh dest=/server/tools/quanwangweb.sh
- name: quanwangweb108
script: /server/tools/quanwangweb.sh
- hosts: 172.16.1.131
tasks:
- name: chuangjianmulu131
shell: mkdir -p /server/tools/ #創建所在配置的文件
- name: peizhi131
copy: src=/server/tools/quanwangnfs.sh dest=/server/tools/quanwangnfs.sh
- name: quanwangnfs.sh131
script: /server/tools/quanwangnfs.sh

 

經歷的錯誤

是因為在劇本里運行劇本的原因

 

 

 是以為我創建了rsync這個用戶  所以報錯沒辦法創建

 

 

 是因為我沒有給61管理端也發密鑰

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • [20170909]為什麼是12秒.txt--//在開發程式時我一般會強調開發儘量不要寫一些自定義函數,往往可能導致CPU忙。--//例子很像這樣:CREATE OR REPLACE FUNCTION get_dept (p_deptno dept.deptno%TYPE) RETURN dept. ...
  • 出現這種錯誤明顯就是 mysql_connect 之後忘記 mysql_close;當大量的connect之後,就會出現Too many connections的錯誤,mysql預設的連接為100個,而什麼情況下會出現這種錯誤呢?正常的mysql_connect 之後調用 mysql_close() ...
  • 我用的是phpstudy安裝的mysql資料庫,但是在服務中沒有mysql的啟動項(不影響使用),原因是在安裝mysql的時候沒有安裝mysql 服務 解決辦法如下: 1. 用管理員身份運行cmd.exe(註意管理員身份!) 2. 進入mysql的bin目錄 3. 安裝mysql服務 安裝服務:my ...
  • 1、查詢工資為2500到4000的人數 方式一: select count(*) from emp where sal>=2500 and sal<=4000; 方式二: select count(*) from emp where sal between 2500 and 4000; 2、查詢每個 ...
  • 本文出處:http://www.cnblogs.com/wy123/p/7501261.html (保留出處並非什麼原創作品權利,本人拙作還遠遠達不到,僅僅是為了鏈接到原文,因為後續對可能存在的一些錯誤進行修正或補充,無他) 資料庫在處理併發事物的過程中,在不同的隔離級別下有不同的鎖表現,在非可序列 ...
  • MySQL事務: 1.MySQL事務控制語句 (1).開啟事務 begin; (2).提交事務 commit; (3).回滾事務 rollback; (4).設置事務是否自動提交 set autocommit = {0 | 1}; // 0不自動提交,1自動提交 例如: begin;// 開啟事務 ...
  • 1、連接池概念 用池來管理Connection,這樣可以重覆使用Connection。有了池,我們就不用自己來創建Connection,而是通過池來獲取Connection對象。當使用完Connection後,調用Connection的close()方法也不會真的關閉Connection,而是把Co ...
  • 命名規範: 命令中的選項和參數: ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...