1.Svn
1.Svn簡介
SVN是C/S架構,資料存放分成服務器端和客戶端,創建代碼庫一般指的是SVN服務器端的操作,這個庫隨便建在什么地方都可以;你要發布的線上代碼,這是存放在SVN的客戶端的,
SVN的服務器端和客戶端存放檔案的格式是不同的,所以不能直接訪問SVN服務器端的存盤路徑,只能通過SVN客戶端將服務器端的存盤內容checkout或者export出來,
2.搭建程序
1、先建立一個SVN服務器(可以專門安裝SVN服務器端安裝包,建立用http/https或svn協議訪問的SVN服務器;也可以簡單用TortoiseSVN創建本地的用files:///方式訪問的SVN服務器);
2、在服務器端建立一個空的版本庫,將你原有的www-web-專案 檔案夾 上傳到SVN服務器新建的版本庫中;
3、在你線上存放代碼的地方新建一個檔案夾,并將版本庫中的內容checkout到這個新檔案夾,設定這個檔案夾是以后線上發布代碼的檔案夾;
4、在你開發用的作業電腦上checkout一個檔案夾出來,平時在這個檔案夾修改代碼,修改完成后上傳到SVN服務器,然后在線上代碼對應的檔案夾那里更新得到上傳的新代碼,
這樣的話,你的整個作業就分成了3個存盤位置:1、服務器端,2、開發端,3、線上發布端,這就井井有條、互不干擾了,
2.部署Svn
準備兩臺機器,一臺做服務端,一臺做客戶端,
1.服務端搭建
[root@server ~]# yum -y install subversion #安裝軟體
[root@server ~]# mkdir -p /home/svn/test #創建版本庫目錄(自定義)
[root@server ~]# svnadmin create /home/svn/test #創建新的repository(版本庫)
[root@server ~]# cd /home/svn/test/conf
[root@server conf]# ls #創建版本庫后,會自動生成三個組態檔
authz passwd svnserve.conf
[root@server conf]# vim svnserve.conf
#進入組態檔,將下面5行注釋打開
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
realm = My First Repository
===================================================================================
anon-access: 控制非鑒權用戶訪問版本庫的權限,
auth-access: 控制鑒權用戶訪問版本庫的權限,
password-db: 指定用戶名口令檔案名,
authz-db:指定權限組態檔名,通過該檔案可以實作以路徑為基礎的訪問控制,
realm:指定版本庫的認證域,即在登錄時提示的認證域名稱,若兩個版本庫的認證域相同,建議使用相同的用戶名口令資料文
===================================================================================

[root@server conf]# vim passwd
#在users模塊里面添加一個用戶yjssjm,密碼是123

[root@server conf]# vim authz
[groups]
harry_and_sally = harry,sally
harry_sally_and_joe = harry,sally,&joe
yjssjm = yjssjm #定義組yjssjm,且里面只有一個用戶yjssjm,組名可以自定義,用戶名可以加多個,以逗號隔開
[test:/] #定義目錄,此目錄是專案test的根目錄
@yjssjm = rw #用戶可讀可寫
* = rw #其它用戶也可讀可寫
======================================================================
[root@server conf]# #svnserve –d –r /home/svn #啟動服務
[root@server conf]# lsof -i:3690 #默認埠號
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
svnserve 15464 root 3u IPv4 216724 0t0 TCP *:svn (LISTEN)
[root@server conf]# svnlook tree /home/svn/test/ --full-paths --show-ids #查看版本庫
--full-paths 顯示路徑
--show-ids 顯示版本號
2.客戶端測驗
[root@client ~]# yum -y install subversion
[root@client ~]# svn checkout svn://服務端ip/home/svn/test
如果報錯:
原因:svn服務未啟動或者是啟動的時候未指定svn倉庫路徑,svn默認倉庫路徑為/var/svn,所以我們需要手動指定為/home/svn/
解決方案:
ps -aux|grep svn #查找出來svn的pid,
kill -9 svn的pid行程號 #用kill殺掉行程
svnserver –d –r /home/svn/ #重啟服務
提交代碼檔案:
服務器上沒有的檔案,在客戶端需要先add預提交,再commit,如果服務器端已有的檔案,直接commit
svn add /root/davesvn/test
svn ci /root/davesvn/test -m "創建新檔案" //ci是commit的縮寫, -m是添加注釋
# 提交test.txt檔案
[root@client ~]# cd /root/davesvn/test
[root@client test]# vim test.txt #隨意寫入資料
[root@client test]# svn add test.txt
A test.txt
[root@client test]# svn commit test.txt -m "test-version1"
Authentication realm: My First Repository
Password for 'root': #輸入虛擬機root密碼
Authentication realm: My First Repository
Username: svn #輸入svn組態檔內創建的用戶
Password for 'svn': #輸入用戶密碼
------
ATTENTION! Your password for authentication realm:
\```
My First Repository
\```
can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
## '/root/.subversion/servers'.
Store password unencrypted (yes/no)? yes #輸入yes
Adding test.txt
Transmitting file data .
Committed revision 1.
你們的評論和點贊是我寫文章的最大動力,蟹蟹,
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/114362.html
標籤:Linux
上一篇:運行/bin/kibana報錯FATAL Error: listen EADDRNOTAVAIL 123.57.251.57:5601
下一篇:ELK搭建與使用詳解
