SVN details, standalone installation configuration, hooks configuration management and large portal code on-line process

Source: Internet
Author: User
Tags svn client svn update rsync version control system tortoisesvn


Code Release Scenarios:

1, installation, optimization of the Software Environment, (NGINX,LVS) "-------Operation and maintenance engineer

2, program code (constantly updated). "--------Development Engineer, (development, operations can be released)

3, configuration changes (constantly changing). "--------Operations engineer.



One, version control management tool SVN detailed


1.1 What is svn (subversion)?

SVN is a very good version management tool in recent years, like the CSV management tool, SVN is a cross-platform Kaiyuan version control system, but SVN is different, SVN will back up and remember


Each file is updated and changed every time. This allows us to restore any point-in-time file to an older version of the desired one, or to browse the updated calendar of the specified file directly.


History record


SVN's related sites:

http://subversion.tigris.org/

http://subversion.apache.org/

SVN client: http://tortoisesvn.net/

SVN Chinese site: http://svndoc.iusesvn.com/



So far: The common version management software is: Vss,cvs,svn,git



1.1.2 What is the difference between SVN and git?


SVN is a centralized data management center, there is a central repository, all developers use the code from the repository, the submission code is the central repository.


SVN version control system workflow:

A, create or copy a branch from the trunk on a central library

b, from the Central Library check out under this branch code

C, add your own code, modify, delete code files

D, commit code. Assuming someone has just submitted the code in the branch, you'll be reminded that the code expires

You need to update your code first and then submit it.


Advantages and Disadvantages

In an environment where you cannot connect to a central repository, you cannot submit code and add code to version control.

You cannot view the historical version of the code and the process of the version change. The code that is submitted to the version control system is run by default through a self-test. If the code of a module is more complex, it is not


The ability to implement testable functionality in a short period of time requires more time to submit your own code, so backup storage is required for backup. This is a better distributed version control system.


SVN backup to back up all code data and new version records for all changes




1.1.2.2 git distributed version control


There is no central distribution in git, but for the development team's code share, we usually build a remote Git repository, in a sense, local git and remote git silos


The library has no master-slave points.


A. If you create a git library locally and add it to a remote git library

b, you add or delete files locally, then commit, of course commit is committed to the local git library, (that is, committed to the local git directory in the object directory)

C, push the branch of the local git repository to the branch of the remote Git repository, and if this is the remote Git repository and the other push, then the remote Git branch doesn't allow you to push,


This time you need to pull, then if there is conflict, commit to local git, push to the remote git library




1.1.3 operations need to master the technical points:

A, installation, deployment, maintenance, troubleshooting

B, simple application, many companies are managed by development, including building new warehouses, adding, deleting accounts




1.2.0 SVN service operation mode and access mode

1.2.1 SVN server run mode

There are 3 common ways to access SVN services:

A, standalone server access

Access Address: Svn://svn.etiantian.org/sadoc

B, with HTTP services like Apache

Access address such as: Http://svn.etiantian.org/sadoc

B1, separate installation apache+svn not recommended, compare soil

B2,CSVN (APACHE+SVN) is a separate integrated software, with the Web interface management of SVN software.


C, local direct access

Access mode File://application/svndata/sadoc is typically used locally on SVN servers

We mainly use the first and second type of CSVN Web management method



1.2.1.1 SVN Client access mode


FILE://direct Local disk or network disk access to the repository

/HTTP access to Subversion Apache server via WebDAV protocol

https://is similar to/HTTP, but encrypted with SSL access

svn://access Svnsever via the header TCP/IP custom protocol

Svn+ssh automatically accesses the Svnserver server with a protocol via authenticated encryption TCP/IP.


1.3.1 SVN archive data format

SVN stores version data in 2 ways: BDB (a Transaction-safe table Type Berkley DB), FSFS (a storage system that does not require a database) BDB in the case of a server outage,


May lock data, so it's safer to FSFS


FSFS a file system backend dedicated to the Subversion repository, which can be used with a network file system (NFS,SMBFS)



SVN is a relational database-based BDB or a series of binary files Fsfs


1.4.1 SVN centralized version management system

SVN is a centralized file system version management system that centrally manages workflows such as


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/DB/wKiom1YrUo6STGugAAE73J7ZiJQ067.jpg "title=" Svn1.png "alt=" Wkiom1yruo6stgugaae73j7zijq067.jpg "/>










The core of centralized code management is the SVN server, the first day all developers must get the code from the server, then develop, finally resolve the conflict, commit, all the information is put in SVN


On the server.


1.4.2 developers take advantage of SVN version management system work process


To illustrate:

A, download the latest project code from the SVN server.

b, go into your own branch, do the development work, every once in a while, submit it,

C, time off, merge your own branch into the server main branch, the day's work is completed, and reflected to the server

Disadvantages:

A, since each commit will have an original copy, the SVN database capacity will burst

b, if you can't connect to the SVN server, you can't basically work

c, not suitable for open source system development, the number of developers more, but centralized management very clear authority management mechanism, can be hierarchical management


Advantages:

A, easy to manage, clear and clear logic.

B, easy to manage, centralized SVN server makes it easier to ensure data security

C, very high code consistency

D, suitable for development of a very few projects



2.0 Installation Configuration SVN service


2.0.1 preparing the operating system and viewing the system environment


[Email protected] ~]# cat/etc/redhat-release

CentOS Release 6.5 (Final)

[Email protected] ~]# uname-r

2.6.32-431.el6.x86_64


[email protected] ~]# Yum install subversion-y


[Email protected] ~]# Rpm-qa | grep subversion

Subversion-1.6.11-15.el6_7.x86_64



[Email protected] ~]# sed-i ' s#keepcache=0#keepcache=1#g '/etc/yum.conf

[[email protected] ~]# grep keepcache/etc/yum.conf

keepcache=1 RPM package does not clear after installation


2.0.2 Configuring and Starting SVN

Build SVN version data store root directory svndata, user, password, permissions directory

[[email protected] ~]# mkdir-p/application/svndata/--The root directory of the data store

[[email protected] ~]# mkdir-p/application/svnpasswd--User, Password permissions directory


Start the SVN service and specify the root directory of the SVN service

[Email protected] ~]# svnserve-d-r/application/svndata/


[Email protected] ~]# Ps-ef | grep SVN

Root 1838 1 0 16:56? 00:00:00 svnserve-d-r/application/svndata/


2.0.3 build the project repository, and configure the repository

Create a new Subversion project Sadoc, similar to this shows up against can create multiple, and for different code,


[[email protected] ~]# svnadmin Create/application/svndata/sadoc-Create a new project



2.0.4 Modify, adjust svn configuration files and permissions files

Configuration allows users to wyb read and write access

Cd/application/svndata/sadoc/conf


[email protected] conf]# CP svnserve.conf Svnserve.conf.bak

[Email protected] conf]# vim svnserve.conf

The following changes are completed


[Email protected] conf]# Grep-ev "^#|^$" svnserve.conf

[General]

Anon-access = None

auth-access = Write

Password-db =/application/svnpasswd/passwd

Authz-db =/application/svnpasswd/authz

[SASL]


Copy the password Authentication file module to the relevant directory, so as to facilitate the consent management


[Email protected] conf]# ls/application/svnpasswd/

[email protected] conf]# CP passwd authz/application/svnpasswd/

[Email protected] conf]# ls/application/svnpasswd/

Authz passwd

[Email protected] conf]# ll/application/svnpasswd/

Total 8

-rw-r--r--1 root root 17:19 Oct Authz

-rw-r--r--1 root root 309 Oct 17:19 passwd

[Email protected] conf]# chmod 700/application/svnpasswd/*

[Email protected] conf]# ll/application/svnpasswd/

Total 8

-rwx------1 root root Oct 17:19 Authz

-rwx------1 root root 309 Oct 17:19 passwd

[Email protected] conf]#


New User, password

Tips:

1, before the equal sign SVN account, wait for the password, the password is tomorrow night, pay attention to password permissions 700

2, change svnserve.conf time, need to restart SVN, change authz,passwd file time do not need to restart SVN


[[email protected] svnpasswd] #vim passwd

[email protected] svnpasswd]# cat passwd


[Users]

# Harry = Harryssecret

# sally = Sallyssecret

wyb = 123456

Zhiyan = Zhiyan

[Email protected] svnpasswd]#



[[email protected] svnpasswd]# Vim Authz Privilege profile

Format description

Repository directory format:

[< Repository >:/project/catalog]

@< User group name >=< permissions >

< user name >=< permissions >

[/] represents the root directory. The root directory is the Svnserver startup, we have developed the/application/svndata [/] to the full repository set permissions

[repos:/] means setting permissions on repository repository

[Repos:/sadoc] means setting permissions on Sadoc items in the repository repo

[Repos:/sadoc/wyb] Represents the wyb directory setting permissions for Sadoc projects in the repository repos



The permission principal can be user group, user, *, user group Front plus @,* for all users

Permissions can be W, R,WR, and null indicate no permissions

Each parameter in the Authz is to be fixed, with no spaces at the beginning

For a group, the user does not need to start @ at the beginning of the @



[[email protected] svnpasswd] #cat Authz

New section

Sagroup = Wyb,zhiyan

[sadoc:/]

wyb = RW

Zhiyan = R

@sagroup = R

Attention:

* The user name that appears in the permissions profile must be defined in the user profile

* Changes to the permissions profile take effect immediately and do not need to restart SVN


User format

[Groups]

Of these, 1 user groups can contain 1 or more users, and the user can be separated by a comma.

SVN installation is complete at this time


3.1 Windows Client software TORTOISESSVN


: http://tortoisesvn.net/downloads.html


Because the SVN standalone access is currently installed, the SVN client links the server in the following way

Svn://192.168.2.48/sadoc

User name: Gongli

Password: 123456


3.1.2 Linux Client command-line usage instructions

Co Checkout

Up update

CI Commit


3.1.2.1 extracting data from the SVN repository

A, checkout files to the local directory Linux client, is checkout, not update



[Email protected] sadoc]# Mkdir/svndata


/svndata---Project code downloaded to,/svndata/

SVN co svn://192.168.2.48/sadoc//svndata/--username=gongli--password=123456


3.1.2.2-viewing server-side data


[[Email protected] svndata]# svn ls svn://192.168.2.48/sadoc/--username=wyb--password=123456-View server-side data

Svn.txt

Ww.txt

New text document. txt

[Email protected] svndata]#


[[Email protected] svndata]# svn ls svn://192.168.2.48/sadoc/--username=wyb--password=123456--verbose

5 wyb Oct 23 10:59./

1 wyb 8011 Oct 09:49 svn.txt

4 wyb 0 Oct 10:37 ww.txt

5 wyb 0 Oct 23 10:59 new text document. txt


3.1.2.3 submitted locally to SVN server

[email protected] svndata]# Touch a.html



[[Email protected] svndata]# SVN add a.html

A a.html

[[Email protected] svndata]# SVN commit

Svn:commit failed (details follow):

Svn:could not use external editor to fetch log message; Consider setting the $SVN _editor environment variable or using the


--message (-M) or--file (-f) options

Svn:none of the environment variables svn_editor, VISUAL or EDITOR is set, and no ' editor-cmd ' run-time configuration


option was found

[[Email protected] svndata]# svn commit-m "svn ci data"

Adding a.html

Transmitting file data.

Committed revision 6.

[Email protected] svndata]#


[[Email protected] svndata]# svn ls svn://192.168.2.48/sadoc/--username=wyb--password=123456--verbose

6 wyb Oct 23 11:09./

6 wyb 0 Oct 11:09 a.html

1 wyb 8011 Oct 09:49 svn.txt

4 wyb 0 Oct 10:37 ww.txt

5 wyb 0 Oct 23 10:59 new text document. txt


############################################################################################################### ##############


#####

Second, SVN hooks


1.1.1 Hook Script:


Writing is the way the shell script program in the system



When the SVN repository changes, the hooks triggers the execution of the command, depending on the hooks output or the returned state, the hooks program can perform the action in some way to continue


Line, stop or hang,


-rw-r--r--1 root root 2780 Oct 17:05 Start-commit.tmpl

[Email protected] hooks]# pwd

/application/svndata/sadoc/hooks

[email protected] hooks]# LL

Total 36

-rw-r--r--1 root root 1977 Oct 17:05 Post-commit.tmpl

-rw-r--r--1 root root 1638 Oct 17:05 Post-lock.tmpl

-rw-r--r--1 root root 2289 Oct 17:05 Post-revprop-change.tmpl

-rw-r--r--1 root root 1567 Oct 17:05 Post-unlock.tmpl

-rw-r--r--1 root root 3426 Oct 17:05 Pre-commit.tmpl

-rw-r--r--1 root root 2410 Oct 17:05 Pre-lock.tmpl

-rw-r--r--1 root root 2786 Oct 17:05 Pre-revprop-change.tmpl

-rw-r--r--1 root root 2100 Oct 17:05 Pre-unlock.tmpl

-rw-r--r--1 root root 2780 Oct 17:05 Start-commit.tmpl

[Email protected] hooks]#



There is a template for each of the hooks supported by the Subversion repository, and by looking at the contents of these scripts, we can see what events triggered the script and how the script was passed


According to

At the same time, these templates are also examples of how to use these scripts, combined with subversion-supported tools to accomplish tasks.

To actually install an available hook, you need to install some executable program or script with the same name as the hook in the Repo/hooks directory.


Attention:

For security reasons, the Subversion repository executes a hook script in an empty environment without any environment variables, or even $path or%path% for this reason, many management


Members will be confused, their hook scripts run normally when they are manually, but they cannot be run in subversion. Note that you must set the "environment variable" in your hooks or


Your program has the "absolute path" in place.



1.1.2 SVN's hooks template

1.1.2.1 Common Hook Scripts



Post-commit The hook is executed after the commit has completed a successful build, the commit is completed and cannot be changed, so the return value of this script is ignored


。 Departure transaction when submission is complete

Pre-commit commit completion triggers execution of the script

Start-commit before the client has submitted data to the server, that is, before the subversion transaction has been established


Execute the Script


Example of 1.2 SVN hooks production Environment Application scenario

Pre-commit

Limit upload file size extension and size, control the submission of information to be entered, etc.,


Post-commit

SVN update automatic known, MSN, e-mail message known

SVN update triggers checkout program, then real-time rsync to the server, etc.


1.2.1 SVN hook Production application combat.


Case one: rsync combined with SVN hooks for data synchronization a small case of a business


A, create a synchronization web directory:

[Email protected] hooks]# mkdir-p/data/www


b, checkout the contents of SVN to a web directory

[[Email protected] www]# SVN co svn://192.168.2.48/sadoc/data/www/--username=wyb--password=123456


[[email protected] www]# ls

a.html b.html c.html svn.txt ww.txt


Modify the hooks script to synchronize

chmod 755/application/svndata/sadoc/hooks/post-commit


[Email protected] svndata]# More/application/svndata/sadoc/hooks/post-commit

#!/bin/bash

Repos= "$"

rev= "$"

Export Lc_ctype= "en_US. UTF-8 "

Export lc_all=


Logpath= "App/log"

[!-D ${logpath}] && mkdir ${logpath}-P

# #update content from SVN

Svn=/usr/bin/svn

$SVN update--username wyb--password 123456/data/www/

If [$?-eq 0]

Then

/usr/bin/rsync-az--delete/data/www//tmp/

Fi


[email protected] svndata]# Touch wwwwwwwwwwwwwwwww

[[Email protected] svndata]# SVN add wwwwwwwwwwwwwwwww

A wwwwwwwwwwwwwwwww

[[Email protected] svndata]# svn commit-m "Wwwwwwww"

Adding wwwwwwwwwwwwwwwww

Transmitting file data.

Committed revision 13.


[[Email protected] svndata]# svn ls svn://192.168.2.48/sadoc/--username=wyb--password=123456--verbose

wyb Oct 23 15:11./

9 wyb Oct 11:34 a.html

wyb 0 Oct 15:09 asd.txt

7 wyb 0 Oct 11:28 b.html.txt

8 wyb 0 Oct C.html.txt

wyb 0 Oct 15:08 hh.txt

1 wyb 8011 Oct 09:49 svn.txt

4 wyb 0 Oct 10:37 ww.txt

wyb 0 Oct 15:11 wwwwwwwwwwwwwwwww

[Email protected] svndata]#


[Email protected] svndata]# ls/tmp/

a.html asd.txt b.html.txt c.html.txt hh.txt svn.txt ww.txt wwwwwwwwwwwwwwwww



Notes for writing a hook script:

A, the permission of the hook script to allow SVN execution, generally can be set chmod 755 post-commit


b, the hook script defines the environment variable as much as possible, primarily the path of the used command, because SVN considers the installation problem and does not invoke the system environment variable, so if the discovery is performed manually post-


Commit is fine, but it may not be possible to do so automatically


C, the case of this note script, before SVN update to manually checkout a copy, and as far as possible to add a user password, if it is just manual update, but if the touch


may not be updated


#####################################################

SVN Remote Sync Program code to the Remote Web server reference method

Method One: http://biancheng.dnbcw.info/linux/345531.html

Method Two: Http://os.51cto.com/art/201410/454887.htm

#######################################################



Case TWO:

Use Pre-commit to limit upload file extensions and sizes

.

.

.

.

.

.

.

.

.


###############################################################

Code-on-line solutions, cases

1.1 Small format code-on-line case


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/D7/wKioL1YrUiCTui9cAAMs6naCrBc100.jpg "title=" Small business on-line process. png "alt=" wkiol1yruictui9caams6nacrbc100.jpg "/>



1.2 Midsize enterprise on-line solution:


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/DB/wKiom1YrUi7xhfPtAAHTYHIAYCs400.jpg "title=" Midsize enterprises on-line. png "alt=" wkiom1yrui7xhfptaahtyhiaycs400.jpg "/>




1.3 Large enterprises on-line solutions:

ITIL BSWX




650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/D7/wKioL1YrUpOQmEUEAARMMIlWO8M494.jpg "title=" Large enterprise on-line scenario. png "alt=" wkiol1yrupoqmeueaarmmilwo8m494.jpg "/>






Batch update in a clustered environment



Code-on-Line solution considerations:

1, on-line process, office test environment---"IDC test environment----" The formal production environment, all the environmental software version should be unified, whether I endless;


2, Development Team Team Office Internal Test Environment (the environment is maintained by the development team, or the code is automatically updated regularly), the code has a problem to return to a developer

3, there is a special test engineer, the program has problems directly returned to the developer

The 4,IDC test has a test and operations participation, called Idctest, carries out a program stress test, and a problem is returned directly to the developer. No problem on the production environment


5, several server code distribution on-line scenario Example (Java program)::::::

A, suppose the interbank server has 6 units, divided into 2 groups, a group of three, Group B three, first to a smooth offline, B group to provide services, to avoid affecting the business

B, the downline is the script will be a set of servers from the RS pool (LVS,NGINX,HAPROXY,F5) and other load balancer to be presented, to avoid the load balancer will send the request to

Group A server, (at this time in low traffic peak period)






This article is from the "Crazy_sir" blog, make sure to keep this source http://douya.blog.51cto.com/6173221/1705833

SVN details, standalone installation configuration, hooks configuration management and large portal code on-line process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.