In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Introduction of git
Git is a distributed version control, everyone has their own version library, and the version number of each submission is the world's only number generated by the sha-1 algorithm.
SVN is centralized version control, with only one version library. The version number is numbered sequentially from 1pm to 2pm.
Several concepts:
Index staging area-joined tracking but not submitted
Work area Workspace
Local repository local warehouse
Remote repository remote warehouse
A folder that, after executing git init, is initialized to a local repository. Generate a .git hidden folder
.git | Local warehouse
Abc.html | Workspace
De.html | Workspace
.git hides the inside of the folder:
Logs | folder
Objects | data submitted by the folder
Refs | folder
COMMIT_EDITMSG |
Config |
FETCH_HEAD |
HEAD |
Index | File staging area
ORIG_HEAD |
Packed-refs
Sourcetreeconfig
Gitlab version control CE version
Download: https://about.gitlab.com/installation/#centos-7
Details: https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/doc/settings
Client uses: Git-2.10.2-64-bit.exe sourcetree
1. Download the gitlab installation package
The download speed of the official website is slow. It is recommended to download it first.
(1) https://about.gitlab.com/downloads/
(2)。 The latest version of https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/trusty/main/g/gitlab-ce/ can be found in domestic sources.
(3) .yum source installs curl-sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
two。 Installation dependency
Yum install curl policycoreutils openssh-server openssh-clients postfix-y
Systemctl enable postfix
Systemctl start postfix
Firewall-cmd-permanent-add-service=http
Systemctl reload firewalld
3. Add yum source, install package
Curl-sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
Sudo yum install gitlab-ce-y
Yum-- installroot specifies the installation path
Or
Curl-LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-XXX.rpm/download
Rpm-I gitlab-ce-XXX.rpm
4. Configure Startup GitLab
Gitlab-ctl reconfigure
Configuration file: / etc/gitlab/gitlab.rb
External_url 'http://tqsrv131-git' # #! This is the domain name or IP
5.EMail settings:
(1) / etc/gitlab/gitlab.rb
External_url 'http://60.205.222.133'
(2) enable postfix, (if not enabled in this example, use smtp)
Postfix profile:
Vi / etc/postfix/main.cf
Vi / var/log/mail.log
Gitlab_rails ['gitlab_email_enabled'] = true
Gitlab_rails ['gitlab_email_from'] =' huasaixiu@tianqiantek.cn'
Gitlab_rails ['gitlab_email_display_name'] =' GitLab'
Gitlab_rails ['gitlab_email_reply_to'] =' noreply@tianqiantek.cn'
(3) configure SMTP to send mail instead of SendMail/postfix
Gedit / etc/gitlab/gitlab.rb
External_url 'http://xx.xx.xx.xx'
# see https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/doc/settings
# Use smtp insttead of sendmail/postfix.
Gitlab_rails ['smtp_enable'] = true
Gitlab_rails ['smtp_address'] = "smtp.126.com"
Gitlab_rails ['smtp_port'] = 25
Gitlab_rails ['smtp_user_name'] = "system_mail_ul@126.com"
Gitlab_rails ['smtp_password'] = "xxxxx"
Gitlab_rails ['smtp_domain'] = "smtp.126.com"
Gitlab_rails ['smtp_authentication'] = "login"
Gitlab_rails ['smtp_enable_starttls_auto'] = true
Gitlab_rails ['smtp_tls'] = false
Gitlab_rails ['smtp_openssl_verify_mode'] =' peer'
Reconfigure
Gitlab-ctl reconfigure
test
Gitlab-rails console
Irb (main): 003Message Subject--test', 0 > Notify.test_email ('huasaixiu@tianqiantek.cn',' Message Subject--test', 'Message Body'). Deliver_now
Note: if it is an Ali CVM, you need to apply for port 25 unblocking, otherwise it will not work.
6.gitlab-ctl Management gitlab
1) View status
[root@tqsrv131-git ~] # gitlab-ctl status
Run: gitaly: (pid 25445) 440241s; run: log: (pid 24853) 440351s
Run: gitlab-monitor: (pid 25453) 440240s; run: log: (pid 25130) 440327s
Run: gitlab-workhorse: (pid 25457) 440240s; run: log: (pid 24873) 440349s
Run: logrotate: (pid 4445) 1038s; run: log: (pid 24953) 440345s
Run: nginx: (pid 25474) 440239s; run: log: (pid 24919) 440347s
Run: node-exporter: (pid 25482) 440239s; run: log: (pid 25058) 440337s
Run: postgres-exporter: (pid 25489) 440238s; run: log: (pid 25111) 440329s
Run: postgresql: (pid 25499) 440237s; run: log: (pid 24677) 440390s
Run: prometheus: (pid 25507) 440237s; run: log: (pid 25035) 440339s
Run: redis: (pid 25517) 440237s; run: log: (pid 24617) 440397s
Run: redis-exporter: (pid 25534) 440236s; run: log: (pid 25088) 440335s
Run: sidekiq: (pid 25542) 440234s; run: log: (pid 24834) 440357s
Run: unicorn: (pid 25566) 440233s; run: log: (pid 24795) 440359s
Tip: we need to make sure that port 80 is not occupied.
2) check the port
[root@tqsrv131-git ~] # gitlab-ctl restart
Ok: run: gitaly: (pid 6461) 1s
Ok: run: gitlab-monitor: (pid 6474) 0s
Ok: run: gitlab-workhorse: (pid 6477) 1s
Ok: run: logrotate: (pid 6487) 0s
Ok: run: nginx: (pid 6494) 0s
Ok: run: node-exporter: (pid 6502) 1s
Ok: run: postgres-exporter: (pid 6509) 0s
Ok: run: postgresql: (pid 6523) 1s
Ok: run: prometheus: (pid 6532) 0s
Ok: run: redis: (pid 6542) 0s
Ok: run: redis-exporter: (pid 6546) 1s
Ok: run: sidekiq: (pid 6553) 1s
Ok: run: unicorn: (pid 6563) 0s
[root@tqsrv131-git] # lsof-iRU 80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Nginx 6494 root 7u IPv4 9813609 0t0 TCP *: http (LISTEN)
Nginx 6495 gitlab-www 7u IPv4 9813609 0t0 TCP *: http (LISTEN)
Nginx 6496 gitlab-www 7u IPv4 9813609 0t0 TCP *: http (LISTEN)
Nginx 6497 gitlab-www 7u IPv4 9813609 0t0 TCP *: http (LISTEN)
Nginx 6498 gitlab-www 7u IPv4 9813609 0t0 TCP *: http (LISTEN)
AliYunDun 10327 root 18u IPv4 20373 0t0 TCP tqsrv131-git:60838- > 140.205.140.205:http (CLOSE_WAIT)
AliYunDun 10327 root 20u IPv4 585797 0t0 TCP tqsrv131-git:52398- > 106.11.68.13:http (CLOSE_WAIT)
AliYunDun 10371 root 18u IPv4 20373 0t0 TCP tqsrv131-git:60838- > 140.205.140.205:http (CLOSE_WAIT)
AliYunDun 10371 root 20u IPv4 585797 0t0 TCP tqsrv131-git:52398- > 106.11.68.13:http (CLOSE_WAIT)
AliYunDun 10371 root 22u IPv4 864184 0t0 TCP tqsrv131-git:44820- > 106.11.68.13:http (ESTABLISHED)
3) Web: visit
Http://xxx.xxx.xxx.xxx/
Log in to the default administrator password and user name for the first time according to the external_url access set above:
Username: root
Password: set the initial password based on the connection given by the email.
Gitlab closes open registration
Admin-- > settings-- > Sign-in Restrictions
Sign-upenbaled turns off the registration function
Sign-inenbaled turns off the registration login function
Set for internal use and do not disclose
4) use
First create a group, then use a group to create a project, and finally create a user and put it in the group
There are three permission levels for setting project, snippet and group:
Private is private and can only be accessed by yourself or members of the group
Internal all logged in users
Public is public and accessible to everyone.
Set up the project
5) the use of Git
Git Bash download address: https://git-scm.com/downloads
(1) add sshkey
Generate sshkey
Ssh-keygen-t rsa-C "$your_email"
Cat / .ssh/id_rsa.pub
Your_emai is your email address. Just enter all the time. This command generates a pair of public and private keys in C:\ Users\ .ssh directory and copies the contents of the public key (the file at the end of .pub).
(2)。 Save sshkey to gitlab
After logging in to your GitLab account, click "Profile Setting"-> "SSH Keys" in the upper right corner, enter the SSH Key title (customizable), and copy the copied id_rsa.pub content to Key, "Add Key".
(3)。 Start uploading code
Enter the project directory cd $project_root
Initialize the git warehouse git init
Add files to the warehouse git add.
Submit the code to the warehouse git commit-m 'init commit'
Link to git server
Git remote add origin git@example.com:namespace/projectname.git
Push code to server git push origin master
Some commonly used instructions in GitLab
Gitlab-ctl start/stop/restart/
The default log files for Gitlab are stored in the / var/log/gitlab directory
Gitlab-ctl tail
Gitlab-ctl tail nginx/gitlab_acces.log
Gitlab-ctl tail postgresql
1.GitLab warehouse
Search for git_data_dir in / etc/gitlab/gitlab.rb
Default warehouse path: git_data_dir "/ var/opt/gitlab/git-data"
Backup path: / var/opt/gitlab/backups
Backup save time: gitlab_rails ['backup_keep_time'] = 604800
2.GitLab backup
Reference document: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/backups.md
Http://shaonian.blog.51cto.com/2975261/1891124/
2.1 Mode 1 directly back up configuration files and data files
Backup directory: / etc/gitlab/var/opt/gitlab/git-data/repositories
Backup method cd / u01/gitlab/backups/
Tar-zPcf $(date "+ etc-gitlab_%Y%_m_%d_%H%M%S.tar.gz") / etc/gitlab
Tar-zPcf $(date "+ gitlab_data_%Y_%m_%d_%H%M%S.tar.gz") / var/opt/gitlab/git-data/repositories timing:
Sudo sh-c 'umask 0077; tar-cf $(date "+ etc-gitlab-%s.tar")-C / etc/gitlab'
2.2 Mode 2 Omnibus installation backup using the following command
Instruction: / opt/gitlab/bin/gitlab-rake gitlab:backup:create
[root@tqsrv131-git repositories] # gitlab-rake gitlab:backup:createDumping database... Dumping PostgreSQL database gitlabhq_production... [DONE]... doneDeleting old backups... Skipping
[root@tqsrv131-git backups] # pwd/var/opt/gitlab/backups [root@tqsrv131-git backups] # lltotal 64 RW-1 git git 61440 Aug 15 13:39 1502775554_2017_08_15_9.4.3_gitlab_backup.tar
Configure backups on a regular basis:
15 04 * * 2-6 umask 0077; tar cfz / secret/gitlab/backups/$ (date "+ etc-gitlab-\% s.tgz")-C / etc/gitlab
Back up the data warehouse regularly:
0 2 * / opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1
3. Restore
Cp 1493107454_2017_04_25_9.1.0_gitlab_backup.tar / var/opt/gitlab/backups/gitlab-ctl stop unicorngitlab-ctl stop sidekiqgitlab-ctl statusgitlab-rake gitlab:backup:restore BACKUP=1493107454_2017_04_25_9.1.0gitlab-ctl startgitlab-rake gitlab:check SANITIZE=true
Git Branch-Branch creation and merging
Master
| |-> C2-> C1-> C0 |
To solve the # 53 problem in the problem tracking system used by your company
$git checkout-b iss53
Switched to a new branch "iss53"
Which is the abbreviation of the order of the following two days.
$git branch iss53
$git checkout iss53
$git commit-a-m'added a new footer [issue 53]'
$git checkout master
Switched to branch 'master'
$git checkout-b hotfix
Switched to a new branch 'hotfix'
$vim index.html
$git commit-a-m'fixed the broken email address'
[hotfix 1fb7853] fixed the broken email address
1 file changed, 2 insertions (+)
Ssh-keygen-t rsa-C "huasaixiu@tianqiantek.cn"-b 4096
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.