Internet_ Teamwork

Time:2020-11-28

VCS

Git overview

VCS:

Centralized VCs: there is a centralized version management server, with file version management and branch management capabilities, the integration efficiency has been significantly improved, the client must be connected to the server.
Distributed VCs: both the server and the client have a complete version library. Without the server, the client can still manage the version. Viewing history and version comparison operations do not need to access the server, which can improve the efficiency of version management more than centralized.

Git :

A free and open source distributed version control system, Linux system inventor Linus Torvalds developed an open source version control software to help manage the development of Linux kernel. Open source, easy to backup, support offline operation.

Git workflow:

First clone the remote resources to the local directory, add or modify the files in the local warehouse, and use git add to add the modified files to the buffer
After adding, GIT commit can be used to add to the current workspace, and git push pushes local changes to the remote git server.

Git’s environment construction:

https://git-scm.com/  Download and install the official website

Git basic operation:

Create warehouse: git init add file to warehouse: git add 123.txt submit file to warehouse git commit - M "add a file"
Warehouse status: git status: git status view the change: git diff view commit log: git log back to the previous version: git reset -- hard head ^ delete file: git RM test.txt   Clone to local: git clone [email protected] :xxxx/ test.git
The local code is submitted to the server: git push origin master

New project

Master: default development branch; origin: default remote version library
#Initialization operation
    $ git config -global  user.name  < name > ා set the name of the submitted person
    $ git config -global  user.email  Submit email address
    $ git config -global  core.editor  < editor > ා set default text editor
    $ git config -global  merge.tool  < tool > ා set the difference analysis tool when resolving merge conflicts
    $git config - list ා check existing configuration information
#Create a new version of the library
    $git clone < URL > ා clone remote version Library
    $git init ා initialize local version Library
#Modification and submission
    $git add. ා add all changed files
    $git add < File > ා adds the specified file
    $git MV < old > < New >? File rename
    $git RM < File > ා delete file
    $git RM - cached < File > ා stops tracking files but does not delete them
    $git commit - M < File > ාsubmit the specified file
    $git commit - M "commit message" ා submit all updated files
    $git commit - amend
    $git commit - C head - A - amend
#View submission history
    $ git log  #View submission history   
    $git log - P < File > ා view the submission history of the specified file
    $git blank < File > ා view the submission history of the specified file in a list
    $gitk ා view current branch history
    $gitk < Branch > ා view the history of a branch
    $gitk -- all ා view all branch history
    $git branch - V ා last commit of each branch
    $git status ා view current status
    $git diff ා view changes
#Undo operation
    $git reset - hard head ා undo the modification of all uncommitted files in the working directory
    $git checkout head < file1 > < File2 > ා undoes the modification of the specified uncommitted file
    $git checkout head. ා undo all files
    $git revert < commit > ා undoes the specified commit
#Branch and label
    $git branch ා displays all local branches
    $git checkout < branch / tagName > ා switches to the specified branch or label
    $git branch < New Branch > ා create a new branch
    $git branch - d < Branch > ා delete local branch
    $git tag ා lists all local tags
    $git tag < tagName > ා create tags based on the latest submission
    $git tag - d < tagName > ා delete tag
#Merger and derivation
    $git merge < Branch > ා merges the specified branch to the current branch
    $git rebase < Branch > ා to derive the specified branch to the current branch
#Remote operation
    $git remote - V ා view remote version library information
    $git remote show < remote >? View the specified remote version library information
    $git remote add < remote > < URL > ා add remote version Library
    $git fetch < remote > ා get code from remote library
    $git pull < remote > < Branch >? Download code and quick merge
    $git push < remote > < Branch >? Upload code and quick merge
    $git push < remote >: < Branch > / < tagName > ා Delete remote branch or label
    $git push - Tags ා upload all tags

Gitlab

What is gitlab?
Gitlab was developed by Ukrainian programmers Dmitry zaporozhets and valerysizov and written in ruby. It is an open source project of GIT warehouse management tool based on network with MIT license, and has Wiki and issue tracking functions. It uses git as code management tool and builds web services on this basis.
Differences between gitlab and GitHub:
(1) Gitlab distributed online code warehouse hosting software is divided into community version and enterprise charging version, both of which need enterprise server installation;
(2) GitHub distributed online code hosting repository, personal version can be directly online free trial, enterprise version charge and need server installation.
The main services of gitlab are as follows:
(1) Nginx static web server
(2) Gitlab workhorse lightweight response proxy server
(3) Gitlab shell is used to process git commands and modify the authorized keys list
(4) Lograte log file management tool
(5) PostgreSQL database
(6) Redis cache server
Advantages and application scenarios of gitlab:
(1) Open source free, suitable for small and medium-sized companies to place code on the company's intranet server
(2) Differentiated version management, offline synchronization and powerful branch management
(3) Convenient GUI operation interface and powerful account management function
(4) Highly integrated, able to integrate most development tools (e.g., JIRA, etc.)
(5) Support built-in ha to ensure high availability under high parallel operation

deploy

Gitlab workflow

1. Create and clone the project
2. Create a feature branch of the project (corresponding to some small requirements)
3. Write the code and submit it to the branch
4. Push the project branch to remote gitlab server
5. Check the code and submit the master branch merger application
6. The project leader reviews the code and confirms the merger application
Gitlab installation configuration

  the general enterprise level gitlab is deployed in the Intranet environment. In order to avoid the embarrassment of making mistakes when visiting, we have to do some preparatory work.
(1) : turn off firewalld firewall

#Turn off the firewall temporarily, that is to say, the firewall will open itself after entering the system next time
sudo systemctl stop firewalld
#Turn off the firewall permanently, and it will not start automatically when it is turned on
sudo systemctl disable firewalld
#Firewall boot up
sudo systemctl enable firewalld
#View firewall status
sudo systemctl status firewalld

(2) : shut down SELinux

#I use Tencent cloud Ubuntu is not installed this subsystem, if you need to install this subsystem can
sudo apt-get install selinux-utils
#Temporary shutdown of SELinux
setenforce 0
#Temporarily open SELinux
setenforce 1
#View the status of SELinux
getenforce
#Power on and shut down SELinux, edit the / etc / SELinux / config file, and set the value of SELinux to disabled. The next time you boot SELinux will not start.
#Setenforce 1 also cannot open the required modification configuration file
#Restart the system
reboot

(3) : install SSH

#If you use a cloud server, you will generally have SSH. If not, we need to install it manually.
#Update system software
sudo apt-get update
#Install SSH service
sudo apt-get install openssh-server
#Start SSH service
sudo /etc/init.d/ssh start
#Restart the SSH service
sudo /etc/init.d/ssh restart
#Shut down SSH service
sudo /etc/init.d/ssh stop
#Check the process to see if the SSH service is started
ps -e | grep sshd

#Configuration allows root to log in remotely
sudo vi /etc/ssh/sshd_config
#Add permitrotlogin yes to the file to save

(4) : install postfix mail service

#Install postfix service
sudo apt-get install postfix
#Start the postfix service
sudo systemctl start postfix
#Restart the postfix service
sudo systemctl restart postfix
#Turn off the postfix service
sudo systemctl stop postfix
#Booting postfix service
sudo systemctl enable postfix

(5) : install CA certificates

#The
sudo apt-get install ca-certificates

(6) Installing gitlab

#Add gitlab package service and install package
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

#Install community version gitlab CE
sudo apt-get install gitlab-ce

#To configure gitlab, the external_ Change the URL address to the server address
sudo vim /etc/gitlab/gitlab.rb

#Update configuration
#Update configuration报错(由于服务器的配置带不动o(╥﹏╥)o)https://idce.com/document/VnmQ
sudo gitlab-ctl reconfigure

#Start, stop, view status, restart gitlab service
sudo gitlab-ctl start/stop/status/restart

(7) Gitlab configuration certificate

#Certificate created on configuration load

#Nginx SSL proxy server configuration

#Initialize gitlab related services and complete the installation

Ansible deployment tool

#The best way to get ansible for Ubuntu is to add the project's PPA (personal package Archive) to the system
sudo apt-add-repository ppa:ansible/ansible

#Refresh the system's package index so that it knows the packages available in the PPA
sudo apt-get update
sudo apt-get install ansible

#Check whether ansible is successfully installed
ansible --version

Jenkins

overview

Continuous integration / CI:
Is a software development practice, the main role is to achieve a complete automatic build process, including automatic compilation, distribution, deployment and testing.
It is emphasized that developers should build and unit test the new code immediately after submitting it. According to the test results, whether the new code and the original code can be correctly integrated is judged, and the code optimization is carried out according to the judgment results.
The significance of continuous integration:
As development or testing, if you want to build your own automation environment better, complete automatic packaging, automatic deployment, automatic testing, the greatest advantage is to reduce the duplication of work, reduce the human cost and possible errors
It is widely used in the current Internet companies. For high-frequency code integration, each integration is verified by daily build (including compilation, release, deployment, automated testing) of the version, so as to expose software defects as soon as possible.
Ci three components = continuous delivery:
Version control system: GitHub, gitlab
Continuous integration tool: Jenkins
Automated deployment tools (instead of our laborious script writing): ansible, saltstack, chef
What is continuous delivery / CD
On the basis of continuous integration, the integrated code is deployed to the real running environment (class production environment). After the unit test is completed, the code can be deployed to the staging environment connected to the database, and more tests can be conducted in the environment. When the code is OK, it can be manually deployed to the production environment.
Note: the environment corresponding to the classic model of software application development: development development environment, integration integration environment, testing environment, QA verification, staging preview environment, production environment
What is Jenkins
A software open source project is a continuous integration tool based on Java development. It originated from Hudson (Hudson is commercial). It is mainly used for continuous and automatic construction / testing of software projects and monitoring the operation of external tasks.
Jenkins features
1. Mainstream operation and maintenance development platform, compatible with all mainstream development environments
2. Plug in can be integrated with a large number of mainstream development tools in the industry
3. Configure the unit and log management, so that the operation and maintenance personnel and developers can work together
4. Different roles of authority management
5. Powerful load balancing function to ensure the reliability of the project
Jenkins configuration

Official documents:

Configure in win10
Method: 1
Premise: configure Java environment
Click to download the [generic java package (. War) file on the official website
Start the Jenkins command, open CMD to the Jenkins installation directory, and run the command Java - jar jenkins.war 
If you change the default port, specify the port, such as port number 1080: Java - jar jenkins.war  --httpPort=1080。
Method 2:
Deploy the downloaded war package file to a server container such as tomact, and then start the container
Copy the war package to the webapps directory of Tomcat and configure Jenkins_ Home environment variable, the variable value is input into the installation directory of Jenkins
Input in browser http://localhost :8080/jenkins
The first time you need to unlock, enter the password
When configuring, install plug-ins: select the recommended plug-ins to install. Next, create users and save them. When configuring instances, choose not to (configure later). Use after confirmation
Domestic installation may not be smooth, need to modify the configuration
In the server configuration:
#Jenkins's dependent operating system still takes Ubuntu as an example
#Jenkins is based on Java
#Install and configure Jenkins' dependent environment - Java environment. Java 8 is recommended here
#If the version is too high, it will be incompatible
sudo apt-get install openjdk-8-jdk
#Check whether Java is installed successfully
java

#Install and configure Jenkins
#Add the Jenkins repository key to the system
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
#Attach the Debian package repository address to the server's sources.list
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
#Update local software source
sudo apt-get update
#Install Jenkins
sudo apt-get install jenkins

#Related operations of Jenkins
#Start
sudo service jenkins start
#Stop running
sudo service jenkins stop
#Restart the service
sudo service jenkins restart
#View running status
sudo service jenkins status

#Using Jenkins
#Access address after Jenkins starts: http://ip_ address_ Or_ domain_ name:8080
#Access to the above address will find that you need to enter the initial password, check to get the initial password
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Jenkins job module


Jenkins plug-in

Internet_ Teamwork

Recommended Today

Interviewer: young man, what do you think of the principle of distributed system

1 Concept 1.1 model 1.2 copies 1.3 indicators for measuring distributed systems 2. Principle of distributed system 2.1 data distribution 2.2 basic copy agreement 2.3 lease mechanism 2.4 quorum mechanism 2.5 log technology 2.6 two phase submission protocol 2.7 MVCC 2.8 Paxos protocol 2.9 CAP 1 Concept 1.1 model node In a specific project, a […]