生活随笔
收集整理的這篇文章主要介紹了
Subversion基本操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Top
NSD OPERATION DAY06
案例1:Subversion基本操作案例2:使用Subversion協同工作案例3:制作nginx的RPM包 1 案例1:Subversion基本操作
1.1 問題
本案例要求先快速搭建好一臺Subversion服務器,并測試該版本控制軟件:
- 創建版本庫
- 導入初始化數據
- 檢出數據至用戶本地副本
- 對本地副本進行增刪改查等操作
1.2 方案
使用YUM安裝subversion軟件,使用svn客戶端工具連接svnserver服務器并測試版本控制軟件。
使用svn命令測試svnserver服務時可以使用的命令列表如表-1所示。
表-1 svn命令列表
1.3 步驟
實現此案例需要按照如下步驟進行。
步驟一:安裝Subversion服務器
1)YUM安裝subversion軟件
[root@web1 ~]# yum -y install subversion[root@web1 ~]# rpm -q subversion 2)創建版本庫
[root@web1 ~]# mkdir /var/svn/ [root@web1 ~]# svnadmin create /var/svn/project[root@web1 ~]# ls /var/svn/project/conf/ db/ format hooks/ locks/ README.txt 3)本地導入初始化數據
[root@web1 ~]# cd /usr/lib/systemd/system/ [root@web1 ~]# svn import . file: 4)修改配置文件,創建賬戶與密碼
[root@web1 ~]# vim /var/svn/project/conf/svnserve.conf[general]### These options control access to the repository for unauthenticated### and authenticated users. Valid values are "write", "read",### and "none". The sample settings below are the defaults.anon-access = noneauth-access = write### The password-db option controls the location of the password### database file. Unless you specify a path starting with a /,### the file's location is relative to the directory containing### this configuration file.### If SASL is enabled (see below), this file will NOT be used.### Uncomment the line below to use the default password file.password-db = passwd//密碼文件### The authz-db option controls the location of the authorization### rules for path-based access control. Unless you specify a path### starting with a /, the file's location is relative to the the### directory containing this file. If you don't specify an### authz-db, no path-based access control is done.### Uncomment the line below to use the default authorization file.authz-db = authz//ACL訪問控制列表文件### This option specifies the authentication realm of the repository.### If two repositories have the same authentication realm, they should### have the same password database, and vice versa. The default realm### is repository's uuid.# realm = My First Repository [root@web1 ~]# vim /var/svn/project/conf/passwd … …[users]harry = passtom = pass [root@web1 ~]# cat /var/svn/project/conf/authz [/]????????????????????????????????//定義ACL訪問控制harry = rw????????????????????????tom = rw* = r???????????????????????????? 5)啟動服務
[root@web1 ~]# svnserve -d -r /var/svn/project1[root@web1 ~]# netstat -nutlp |grep svnservetcp 0 0 0.0.0.0:3690????0.0.0.0:*????LISTEN 4043/svnserve 步驟二:客戶端測試(192.168.2.200)
1)將服務器上的代碼下載到本地
[root@web2 ~]# cd /tmp[root@web2 ~]# svn --username harry --password pass \co svn: -----------------------------------------------------------------------ATTENTION! Your password for authentication realm: <svn: can only be stored to disk unencrypted! You are advised to configureyour system so that Subversion can store passwords encrypted, ifpossible. See the documentation for details. You can avoid future appearances of this warning by setting the valueof the 'store-plaintext-passwords' option to either 'yes' or 'no' in'/root/.subversion/servers'.-----------------------------------------------------------------------Store password unencrypted (yes/no)? yes???????????? [root@web2 ~]# cd /tmp/code[root@web2 code]# ls[root@web2 code]# vim user.slice ????????????????[root@web2 code]# svn ci -m "modify user"???????? [root@web2 code]# svn update????????????????????[root@web2 code]# svn info???? svn:[root@web2 code]# svn log???? svn: [root@web2 code]# echo "test" > test.sh????????[root@web2 code]# svn ci -m "new file"????????????[root@web2 code]# svn add test.sh????????????????[root@web2 code]# svn ci -m "new file"???????????? [root@web2 code]# svn mkdir subdir????????????????[root@web2 code]# svn rm timers.target????????????[root@web2 code]# svn ci -m "xxx"???????????????? [root@web2 code]# vim umount.target????????????[root@web2 code]# svn diff ????????????????????[root@web2 code]# svn diff umount.target????????[root@web2 code]# svn cat svn: [root@web2 code]# sed -i 'd' tmp.mount????????????[root@web2 code]# svn revert tmp.mount???????????? [root@web2 code]# rm -rf *.target????????????????[root@web2 code]# svn update???????????????????? [root@web2 code]# sed -i '1a #test###' tuned.service[root@web2 code]# svn ci -m "xxx"[root@web2 code]# svn merge -r7:2????tuned.service???? 2 案例2:使用Subversion協同工作
2.1 問題
沿用練習一,通過svn工具,對subversion版本庫進行多人協同工作測試,要求如下:
- 該版本庫支持多個賬戶同時協作編輯文件
- 測試演示多人協作編輯的具體操作
- 手動解決版本沖突問題
- 備份版本庫數據
2.2 方案
使用svn客戶端工具連接subversion服務器并測試多人協同工作以及如何手動解決沖突問題,賬戶名稱分別為harry和tom,最后使用svnadmin dump指令對版本庫進行備份工作。
2.3 步驟
實現此案例需要按照如下步驟進行。
步驟一:多人協同工作
1)遠程連接兩個終端,每個人下載代碼本地副本,注意web1(192.168.2.100)和web2(192.168.2.200)代表了兩個不同的主機,看清楚操作是在哪一臺計算機上執行!
[root@web1 ~]# cd /tmp[root@web1 ~]# svn --username harry --password pass \> co svn:[root@web2 ~]# cd /tmp[root@web2 ~]# svn --username tom --password pass \> co svn:[root@web1 ~]# cd mycode[root@web2 ~]# cd mycode 2) harry和tom修改不同的文件
[root@web1 mycode]# sed -i "3a ###harry modify#####" tmp.mount[root@web1 mycode]# svn ci -m "has modified"[root@web2 mycode]# sed -i "3a ###tom modify#####" umount.target[root@web2 mycode]# svn ci -m "has modified"[root@web2 mycode]# svn update[root@web1 mycode]# svn update 3)harry和tom修改相同文件的不同行
[root@srv5 ~]# cd harry[root@web1 mycode]# sed -i "3a ###harry modify#####" user.slice[root@web1 mycode]# svn ci -m "modified"[root@web2 mycode]# sed -i "6a ###tom modify#####" user.slice[root@web2 mycode]# svn ci -m "modified"????????Sending svnserveTransmitting file data .svn: Commit failed (details follow):svn: File '/user.slice' is out of date(過期)[root@web2 mycode]# svn update????????????????????[root@web2 mycode]# svn ci -m "modified"????????Sending user.sliceTransmitting file data . 4) harry和tom修改相同文件的相同行
[root@web1 mycode]# sed -i '1c [UNIT]' tuned.service[root@web1 mycode]# svn ci -m "modified"[root@web2 mycode]# sed -i '1c [unit]' tuned.service[root@web2 mycode]# svn ci -m "modified"Sending tuned.serviceTransmitting file data .svn: Commit failed (details follow):svn: File '/tuned.service' is out of date(過期)[root@web2 mycode]# svn update????????????????????Conflict discovered in 'tuned.service'.Select: (p) postpone, (df) diff-full, (e) edit,(mc) mine-conflict, (tc) theirs-conflict,(s) show all options:p????????????????????[root@web2 mycode]# lstuned.service tuned.service.mine????????tuned.service.r10????tuned.service.r9[root@web2 mycode]# mv tuned.service.mine tuned.service[root@web2 mycode]# rm -rf tuned.service.r10 tuned.service.r9[root@web2 mycode]# svn ci -m "modified"???? 步驟二:使用dump指令備份版本庫數據
[root@web1 ~]# svnadmin dump /var/svn/project > project.bak * Dumped revision 0.* Dumped revision 1.* Dumped revision 2.* Dumped revision 3.* Dumped revision 4.* Dumped revision 5.* Dumped revision 6.* Dumped revision 7.* Dumped revision 8.* Dumped revision 9.* Dumped revision 10.* Dumped revision 11.[root@web1 ~]# svnadmin load /var/svn/project2 < project.bak???? 3 案例3:制作nginx的RPM包
3.1 問題
本案例使用nginx-1.12.2版本的源碼軟件,生產對應的RPM包軟件,具體要求如下:
- 軟件名稱為nginx
- 軟件版本為1.12.2
- RPM軟件包可以查詢描述信息
- RPM軟件包可以安裝及卸載
3.2 方案
安裝rpm-build軟件包,編寫SPEC配置文件,創建新的RPM軟件包。
配置文件中的描述信息如表-2:
表-2 SPEC描述信息
3.3 步驟
實現此案例需要按照如下步驟進行。
步驟一:安裝rpm-build軟件
1)安裝rpm-build軟件包
[root@web1 ~]# yum -y install rpm-build 2)生成rpmbuild目錄結構
[root@web1 ~]# rpmbuild -ba nginx.spec????????????????[root@web1 ~]# ls /root/rpmbuild????????????????????BUILD BUILDROOT RPMS SOURCES SPECS SRPMS 3)準備工作,將源碼軟件復制到SOURCES目錄
[root@web1 ~]# cp nginx-1.12.2.tar.gz /root/rpmbuild/SOURCES/ 4)創建并修改SPEC配置文件
[root@web1 ~]# vim /root/rpmbuild/SPECS/nginx.spec Name:nginx????????Version:1.12.0Release:????10Summary: Nginx is a web server software.???? License:GPL????URL:????www.test.com????Source0:nginx-1.12.2.tar.gz #BuildRequires:????#Requires:???? %descriptionnginx [engine x] is an HTTP and reverse proxy server. %prep%setup –q???????????????????????????? %build./configuremake %{?_smp_mflags} %installmake install DESTDIR=%{buildroot}cp /root/rpmbuild/SPECS/nginx.sh %{buildroot}/usr/local/nginx/ ## %files%doc/usr/local/nginx 步驟二:使用配置文件創建RPM包
1)安裝依賴軟件包
[root@web1 ~]# yum –y install gcc pcre-devel zlib-devel openssl-devel 2)rpmbuild創建RPM軟件包
[root@web1 ~]# rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec[root@web1 ~]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm[root@web1 ~]# rpm -qpi RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm Name : nginx????????Relocations: (not relocatable)Version : 1.12.2????????Vendor: (none)Release : 10????????????Build Date: Mon 02 May 2016 02:30:53 AM PDTInstall Date: (not installed)????????????Build Host: localhostGroup : Applications/Internet????????Source RPM: nginx-1.8.0-1.src.rpmSize : 721243????????????????????License: GPLSignature : (none)URL : www.nginx.orgSummary : Nginx is a web server software.Description :nginx [engine x] is an HTTP and reverse proxy server.[root@web1 ~]# rpm -qpl nginx-1.12.2-10.x86_64.rpm /usr/usr/local/usr/local/nginx/usr/local/nginx/conf/usr/local/nginx/conf/fastcgi.conf/usr/local/nginx/conf/fastcgi.conf.default/usr/local/nginx/conf/fastcgi_params/usr/local/nginx/conf/fastcgi_params.default/usr/local/nginx/conf/koi-utf/usr/local/nginx/conf/koi-win/usr/local/nginx/conf/mime.types/usr/local/nginx/conf/mime.types.default/usr/local/nginx/conf/nginx.conf/usr/local/nginx/conf/nginx.conf.default/usr/local/nginx/conf/scgi_params/usr/local/nginx/conf/scgi_params.default/usr/local/nginx/conf/uwsgi_params/usr/local/nginx/conf/uwsgi_params.default/usr/local/nginx/conf/win-utf/usr/local/nginx/html/usr/local/nginx/html/50x.html/usr/local/nginx/html/index.html/usr/local/nginx/logs/usr/local/nginx/sbin/usr/local/nginx/sbin/nginx 步驟三:安裝、卸載軟件
[root@web1 ~]# rpm -ivh RPMS/x86_64/nginx-1.12.2-10.x86_64.rpm [root@web1 ~]# rpm -qa |grep nginx[root@web1 ~]# /usr/local/nginx/sbin/nginx[root@web1 ~]# curl http:
轉載于:https://www.cnblogs.com/tiki/p/10783298.html
總結
以上是生活随笔為你收集整理的Subversion基本操作的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。