業務需求:
1, 美國同事kun需要我們這邊的svn資料記錄,以便查閱代碼修改情況!
2, 我們提供資料放在開放伺服器A上給予下載。
3, kun下載安裝到本地機器
背景:
1, 開放伺服器A 和 svn伺服器B 在同一區域網路中。
2, A 按需 向 B 索取 資料!
初步方案:
1,觸發svn做匯出動作,執行匯出指令碼
這步可以利用svn倉庫下hook中的post-commit來做
2,在B上,匯出svn最後一次增量(&data)!
利用
svnadmin dump /svnrepo/ -r HEAD
--incremental > test.dump
3,A 取 B test.dump檔案
這邊有兩種方法
1) scp 2)smbget
4,下載
wget url
5, 安裝匯入
svnadmin load
/usr/local/share/svn/project <
test.dump
實現:
1,編輯觸發匯出指令碼(在B機器上)
cd
/var/svn/repo/hooks
cp post-commit.tmpl post-commit
chmod a+x post-commit
vi post-commit
添加以下內容:
svnadmin dump
/svnrepo/ -r HEAD --incremental > /home/share/test.dump
註:B機器上利用smb服務開啟區域網路下/home/share 的訪問
這樣每次提交代碼後就會觸發這條命令
2,A機器取 test.dump
方法1,
smbget -a smb://networkname/xxx/test.dump -o
//var/www/publish/test.dump
注意:是var前兩個反斜線
方法2,
scp
root@192.168.0.112:/home/share/test.dump
/var/www/publish/test.dump
提示輸入密碼:輸入B機root密碼
********
附1 提供了避免以後在輸入密碼的方法
3,下載
wget url
4,安裝匯入
/usr/local/share/svn/project <
test.dump
附1(轉)
1.
在機器Client上root使用者執行ssh-keygen命令,產生建立安全信任關係的認證。
[root@Client root]# ssh-keygen -b 1024 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no
passphrase):
<-- 直接輸入斷行符號
Enter same passphrase
again:
<-- 直接輸入斷行符號
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
49:9c:8a:8f:bc:19:5e:8c:c0:10:d3:15:60:a3:32:1c root@Client
[root@Client root]#
注意:在程式提示輸入passphrase時直接輸入斷行符號,表示無認證密碼。
上述命令將產生私密金鑰認證id_rsa和密鑰憑證id_rsa.pub,存放在使用者家目錄的.ssh子目錄中。
2. 將密鑰憑證id_rsa.pub複製到機器Server的root家目錄的.ssh子目錄中,同時將檔案名稱更換為authorized_keys。
[root@Client root]# scp -p .ssh/id_rsa.pub
root@192.168.3.206:/root/.ssh/authorized_keys
root@192.168.3.206's password:
<-- 輸入機器Server的root使用者密碼
id_rsa.pub 100%
|**************************|
218 00:00
[root@Client root]#
在執行上述命令時,兩台機器的root使用者之間還未建立安全信任關係,所以還需要輸入機器Server的root使用者密碼。
經過以上2步,就在機器Client的root和機器Server的root之間建立安全信任關係。下面我們看看效果:
[root@Client root]# scp -p text
root@192.168.3.206:/root
text
100% |**************************|
19 00:00
[root@Client root]#
成功 !