自動化運維:php
網絡層(接入層、匯聚層、核心層);html
LB+HA(L四、L7);前端
服務層(reverse proxy cache、應用層、web層、SOA層、分佈式層、DAL);java
數據層(分佈式緩存、NoSQL、DB);python
系統層(環境初始化)nginx
基礎設施(IDC託管、設備上下架);git
自動化實現:github
網絡層(SDN,softwaredefinition network);web
LB+HA(平臺開發、IaaS);redis
服務層(PaaS or docker(自動化調度、自動化開發、自動化發現(服務發現、服務註冊));reverse proxy cache(第三方平臺開發);應用層(自定義開發);web層、SOA層、分佈式層、DAL(saltstack,saltcloud,有docker模塊、消息));
數據層(DAL);
基礎設備、系統層(IaaS,openstack);
安全:
網絡層(firewall);
LB+HA、服務層(WAF,web application firewall)
數據層(如DB權限);
系統層(tcp wrapper);
基礎設施(物理安全);
備份:
網絡層(HSRP、VRRP);
LB+HA(VRRP);
數據層(DB備份);
服務層中的web層(saltstack);
核心層(網關設備(outside、inside)、防火牆、router);
匯聚層(三層交換;動態路由、靜態路由、EC、端口匯聚);
接入層(二層交換;VTP、SPF、trunk、port安全);
L4(LVS、F5's BigIP、Citrix's Netscaler、A10);
L7(haproxy、nginx);
DAL、專業團隊作(taobao'sTDDL、360);
分佈式層(分佈式存儲(glusterfs、moosefs、fastDFS);分佈式MQ(rabbitMQ、QPID、zeroMQ));
SOA層、服務化(應用服務層duddo、基於restfull api開發);
web層(httpd、nginx、tomcat、jboss、resin);
應用層、應用變動ittle(php、java、python、C、C++);
reverse proxy cache(ATS、squid、varnish;CDN(配置同步;流量統計;預緩存;緩存更新;日誌分析;智能DNS));
DB(MySQL、Oracle、postgre SQL、SQLserver、access);
NoSQL(mongodb、redis、couchbase、elasticsearch);
分佈式緩存(memcached、redis);
環境初始化(性能優化;監控agent;自動化管理saltstack minion;內部DNS;limit(例如tcp wrapper限制僅跳板機ssh到server);
設備上下架(網絡配置;標籤;自檢(配貨單與實物對比);raid;iDrac|ILO|IMM;OS安裝;資產錄入(分層設計)——合同管理(採購方-採購時間-採購人-聯繫信息)——保修時間——地點——配置詳情——MDB配置項(OS類型-IPv4,RIP,VIP,IPMI,hostname)——服務層面);
IDC託管(熟悉各大IDC廠商;根據業務類型選擇;網絡測試;談價格、走合同;設備採購(需求分析、採購、上下架));
運維標準化(版本、路徑、服務、OS……);
運維邊界:
運維邊界模糊化(掌握儘量多的知識點);
運維開發(後端>前端,重點在後端);
自動化運維發展階段:
標準化、工具化(標準化運維;運維標準化、操做工具化、變動流程化);
web化、平臺化(web化運維;操做web化、權限控制、弱化流程、統計分析、統一調度);
服務化、api化(DNS服務、LB服務、監控服務、分佈式緩存服務、分佈式存儲服務、CMDB);
智能化;
服務器生命週期:
服務器上架-->網絡配置-->raid配置-->IPMI
服務器上架-->環境部署-->運維變動-->(服務更新-->代碼更新-->服務擴容&縮容);(服務下線,服務器下線)
環境部署(OS安裝(cobbler);服務部署(saltstack);應用代碼部署(saltstack&shell);監控配置(zabbix);加入運行集羣(LVS&haproxy))
持續集成、持續部署:
git:
分佈式的版本控制系統;
diff(2002年以前)-->bitkeeper(2002年)-->git(不要逼我);
集中式;
分佈式(中央服務器用於交換代碼);
注:不要拿git與svn相對比,git只能管理文本文件,不能管理picture;
https://github.com/jowinchaitest,github源碼託管,開源項目,代碼管理,控制工具;
[root@test1 ~]# yum -y install git
[root@test1 ~]# git --help
usage: git [--version][--exec-path[=GIT_EXEC_PATH]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
[--help] COMMAND [ARGS]
The most commonly used git commands are:
add Add file contents tothe index
bisect Find by binary searchthe change that introduced a bug
branch List, create, or deletebranches
checkout Checkout abranch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to therepository
diff Show changes betweencommits, commit and working tree, etc
fetch Download objects andrefs from another repository
grep Print lines matching apattern
init Create an empty gitrepository or reinitialize an existing one
log Show commit logs
merge Join two ormore development histories together
mv Move or rename a file,a directory, or a symlink
pull Fetch fromand merge with another repository or a local branch
push Update remote refsalong with associated objects
rebase Forward-port local commits to the updatedupstream head
reset Reset current HEAD tothe specified state
rm Remove files from theworking tree and from the index
show Show various types ofobjects
status Show the working treestatus
tag Create,list, delete or verify a tag object signed with GPG
經常使用命令:
#git config --list
#git config --global user.name "jowin.chai"
#git config --global user.email "jowinchai@163.com"
#git config --global color.ui true
#git init
#git add readme.txt
#git commit -m "modified by jowin.20161123"
#git status
#git log
#git diff readme.txt
#git reflog #(Manage reflog information.)
#git reset --hard HEAD^ #(一個^表示回退到上一個版本,兩個^表示回退到前兩個版本,三個^表示回退到前三個版本)
#git reset --hard STRING #(Resetcurrent HEAD to the specified state.回退到#git reflog查詢出的指定的版本)
#git remote add origin git@github.com:jowinchaitest/demo
#cat .git/config
#git pull origin master
#git push -u origin master #(若出錯,#git push -f;git pull;git push)
#git clone git@github.com:jowinchaitest/demo
#git branch
#git branch dev
#git checkout dev #(#gitcheckout -b dev,建立並切至dev分支)
#git checkout master
#git merge dev
#git branch -d dev
#git log --graph
#git log --graph --pretty=oneline --abbrev-commit #(This is a shorthand for "--pretty=oneline --abbrev-commit" used together.)
#git tag v1.0
#git push origin v1.0
#git show v1.0
注:
#git push <REMOTE_HOST> <LOCAL_BRANCH>:<REMOTE_BRANCH> #(#mangit-push,用於將本地分支的更新推送到遠程主機;若省略遠程分支名,表示將本地分支推送與之存在追蹤關係的遠程分支(一般二者同名),若是該遠程分支不存在則會被新建)
#git pull <REMOTE_BRANCH>:<LOCAL_BRANCH>
#git push origin master #(將本地的master分支推送到origin主機的master分支,若是後者不存在則會被新建,若是省略本地分支名錶示刪除指定的遠程分支,這等同於推送一個空的本地分支到遠程分支)
#git push origin :master
等同於
#git push origin --delete master #(刪除origin主機的master分支)
#git push origin #(將當前分支推送到origin主機的對應分支;若是當前分支與遠程分支存在追蹤關係,則本地分支和遠程分支均可省略)
#git push #(若是當前分支只有一個追蹤分支,那主機名均可省略)
#git push -u origin master #(將本地的master分支推送到origin主機,同時指定origin爲默認主機,以後可不加任何參數使用#git push了;若是當前分支與多個主機存在追蹤關係,可以使用-u指定一個默認主機,這樣後面可不加任何參數使用#git push)
注:
不帶任何參數的#git push默認只推送當前分支,這叫simple方式,此外還有一種matching方式,會推送全部有對應分支的本地分支,git2.0版本以前,默認採用matching方式,如今改成默認使用simple方式,若是要修改這個設置,可採用#git config --globalpush.default matching;
還有一種狀況,不論是否存在對應的遠程分支,將本地的全部分支都推送到遠程主機,要使用--all;
若是遠程主機的版本比本地版本更新,推送時會報錯,要求先在本地作git pull合併差別,而後再推送到遠程主機,這時若是必定要往遠程主機推送可以使用--force;
#git config --global push.default matching
#git config --global push.default simple
#git push --all origin #(將全部本地分支都推送到origin主機)
#git push --force origin #(使用--force會致使遠程主機產生一個非直進式(non-fast-forward merge)的合併,除非很肯定要這樣作,不然應儘可能避免使用--force)
#git push origin --tags #(push全部標籤)
#git push origin v1.0 #(push單個標籤)
[root@test1 ~]# git --version
git version 1.7.1
[root@test1 ~]# git config --global user.name "jowinchai" #(配置當前用戶信息,某個開發在提交代碼後,以辨別是誰提交的代碼(誰在幹活))
[root@test1 ~]# git config --global user.email "jowinchai@163.com"
[root@test1 ~]# git config --global color.ui true
[root@test1 ~]# git config --list
user.name=jowinchai
user.email=jowinchai@163.com
color.ui=true
[root@test1 ~]# mkdir -pv /ane/test
mkdir: created directory `/ane'
mkdir: created directory `/ane/test'
[root@test1 ~]# cd !$
cd /ane/test
[root@test1 test]# git init
Initialized empty Git repository in/ane/test/.git/
[root@test1 test]# vim readme.txt
1row test
2row test2
[root@test1 test]# git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will becommitted)
#
# readme.txt
nothing added to commit but untracked filespresent (use "git add" to track)
[root@test1 test]# git add readme.txt
[root@test1 test]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# newfile: readme.txt
#
[root@test1 test]# git commit -m "the first commit"
[master (root-commit) 68692db] the firstcommit
1files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 readme.txt
[root@test1 test]# git status
# On branch master
nothing to commit (working directory clean)
[root@test1 test]# git log
commit68692dba5bf091ec829ee35c179a2a75948e6477
Author: jowinchai <jowinchai@163.com>
Date: Tue Nov 22 22:34:32 2016 -0800
the first commit
[root@test1 test]# vim readme.txt
1row test
2row test2
3row test3
[root@test1 test]# git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will becommitted)
# (use "git checkout -- <file>..." to discard changes inworking directory)
#
# modified: readme.txt
#
no changes added to commit (use "gitadd" and/or "git commit -a")
[root@test1 test]# git diff readme.txt
diff --git a/readme.txt b/readme.txt
index 696014d..da593d5 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,3 @@
1rowtest
2rowtest2
+3row test3
[root@test1 test]# git add readme.txt
[root@test1 test]# git status
# On branch master
# Changes to be committed:
# (use"git reset HEAD <file>..." to unstage)
#
# modified: readme.txt
#
[root@test1 test]# git commit -m "add 3row"
[master f9b7739] add 3row
1files changed, 1 insertions(+), 0 deletions(-)
[root@test1 test]# git status
# On branch master
nothing to commit (working directory clean)
[root@test1 test]# git log
commitf9b77398c7dbd083dc8e37e63ec1fa0a999a2c62
Author: jowinchai <jowinchai@163.com>
Date: Tue Nov 22 22:39:50 2016 -0800
add 3row
commit68692dba5bf091ec829ee35c179a2a75948e6477
Author: jowinchai <jowinchai@163.com>
Date: Tue Nov 22 22:34:32 2016 -0800
the first commit
[root@test1 test]# git reflog
f9b7739 HEAD@{0}: commit: add 3row
68692db HEAD@{1}: commit (initial): thefirst commit
[root@test1 test]# git reset --hard HEAD^
HEAD is now at 68692db the first commit
[root@test1 test]# cat readme.txt
1row test
2row test2
[root@test1 test]# git reflog
68692db HEAD@{0}: HEAD^: updating HEAD
f9b7739 HEAD@{1}: commit: add 3row
[root@test1 test]# git reset --hard f9b7739
HEAD is now at f9b7739 add 3row
[root@test1 test]# cat readme.txt
1row test
2row test2
3row test3
在https://github.com/中建立用戶-->organization name:jowinchaitest;
獲得https://github.com/jowinchaitest;
點右上角+,New repository,Repository name:demo,Public,Initialize this repository with a README,Createrepository;
點demo-->Settings-->Deploykeys,Title:localhost-vmware-test1,Key:粘貼本地vmware中test1,/root/.ssh/id_rsa.pub中的內容;
[root@test1 ~]# cd /ane/test/
[root@test1 test]# git remote add origin git@github.com:jowinchaitest/demo
[root@test1 test]# cat .git/config
[core]
repositoryformatversion= 0
filemode= true
bare= false
logallrefupdates= true
[remote "origin"]
url= git@github.com:jowinchaitest/demo
fetch= +refs/heads/*:refs/remotes/origin/*
[root@test1 test]# git pull origin master
The authenticity of host 'github.com(192.30.253.113)' can't be established.
RSA key fingerprint is16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continueconnecting (yes/no)? yes
Warning: Permanently added'github.com,192.30.253.113' (RSA) to the list of known hosts.
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:jowinchaitest/demo
*branch master -> FETCH_HEAD
Merge made by recursive.
README.md | 2 ++
1files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 README.md
[root@test1 test]# git push -u origin master
Counting objects: 9, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (8/8), 726 bytes,done.
Total 8 (delta 0), reused 0 (delta 0)
To git@github.com:jowinchaitest/demo
05ffa4e..935f53a master ->master
Branch master set up to track remote branchmaster from origin.
網頁上將有本地test1上/ane/test/的readme.txt了
[root@test1 test]#git clone git@github.com:jowinchaitest/demo
Initialized empty Git repository in/ane/test/demo/.git/
Warning: Permanently added the RSA host keyfor IP address '192.30.253.112' to the list of known hosts.
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (5/5),done.
remote: Total 11 (delta 0), reused 8 (delta0), pack-reused 0
Receiving objects: 100% (11/11), done.
[root@test1 test]# ll
total 12
drwxr-xr-x. 3 root root 4096Dec 7 02:12 demo
-rw-r--r--. 1 root root 17 Dec 7 02:08 README.md
-rw-r--r--. 1 root root 32 Nov 22 22:51 readme.txt
建立分支:
[root@test1 test]# git branch #(查看當前分支,綠色並用*號開頭表示當前所在分支)
* master
[root@test1 test]# git branch dev #(建立dev分支;也可用#gitcheckout -b dev建立並切至dev分支)
[root@test1 test]# git branch
dev
* master
[root@test1 test]# git checkout dev #(切至dev分支)
Switched to branch 'dev'
[root@test1 test]# git branch
* dev
master
[root@test1 test]# vim dev.txt
1st he
2st hehe
[root@test1 test]# git add dev.txt
[root@test1 test]# git commit -m "adddev.txt"
[dev 1229ea4] add dev.txt
1files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 dev.txt
[root@test1 test]# git checkout master #(切至master分支;若要合併兩個分支,要先切至master分支上再用#git merge dev合併)
Switched to branch 'master'
[root@test1 test]# ll
total 12
drwxr-xr-x. 3 root root 4096 Dec 7 02:12 demo
-rw-r--r--. 1 root root 17 Dec 7 02:08 README.md
-rw-r--r--. 1 root root 32 Nov 22 22:51 readme.txt
[root@test1 test]# git merge dev #(合併master和dev分支)
Updating 935f53a..1229ea4
Fast-forward
dev.txt | 2 ++
1files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 dev.txt
[root@test1 test]# ll
total 16
drwxr-xr-x. 3 root root 4096 Dec 7 02:12 demo
-rw-r--r--. 1 root root 16 Dec 9 22:35 dev.txt
-rw-r--r--. 1 root root 17 Dec 7 02:08 README.md
-rw-r--r--. 1 root root 32 Nov 22 22:51 readme.txt
[root@test1 test]# git branch
dev
* master
[root@test1 test]# git branch -d dev #(刪除一個分支)
Deleted branch dev (was 1229ea4).
[root@test1 test]# git branch
* master
模擬衝突conflict:
[root@test1 test]# ll
total 12
drwxr-xr-x. 3 root root 4096 Dec 7 02:12 demo
-rw-r--r--. 1 root root 17 Dec 7 02:08 README.md
-rw-r--r--. 1 root root 87 Dec10 00:05 readme.txt
[root@test1 test]# pwd
/ane/test
[root@test1 test]# git branch
* master
[root@test1 test]# git checkout -b dev #(建立並切至dev分支)
Switched to a new branch 'dev'
[root@test1 test]# git branch
* dev
master
[root@test1 test]# vim readme.txt
1row test
2row test2
3row test3
4row test4
[root@test1 test]# git add readme.txt
[root@test1 test]# git commit -m "devchange"
[dev 1a96c6c] dev change
1files changed, 1 insertions(+), 0 deletions(-)
[root@test1 test]# git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by2 commits.
[root@test1 test]# vim readme.txt
1row test
2row test2
3row test3
5row test5
[root@test1 test]# git add readme.txt
[root@test1 test]# git commit -m "master change"
[master 13b119c] master change
1files changed, 1 insertions(+), 0 deletions(-)
[root@test1 test]# git merge dev #(沒法合併,提示有衝突)
Auto-merging readme.txt
CONFLICT (content): Mergeconflict in readme.txt
Automatic merge failed; fixconflicts and then commit the result.
[root@test1 test]# git branch
dev
* master
[root@test1 test]# cat readme.txt #(直接查看提示的有問題的文件可獲取哪些地方有問題)
1row test
2row test2
3row test3
<<<<<<< HEAD
5row test5
=======
4row test4
>>>>>>> dev
[root@test1 test]# git status #(使用#git status可獲取衝突緣由)
# On branch master
# Your branch is ahead of 'origin/master'by 3 commits.
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to markresolution)
#
# bothmodified: readme.txt
#
no changes added to commit (use "gitadd" and/or "git commit -a")
解決衝突:
[root@test1 test]# vim readme.txt #(手動編輯好,add到緩存區,再commit,最後合併兩分支)
1row test
2row test2
3row test3
4row test4
5row test5
[root@test1 test]# git add readme.txt
[root@test1 test]# git commit -m "conflict fixed"
[master 66c9414] conflict fixed
[root@test1 test]# git merge dev
Already up-to-date.
[root@test1 test]# cat readme.txt
1row test
2row test2
3row test3
4row test4
5row test5
[root@test1 test]# git branch -d dev
Deleted branch dev (was 1a96c6c).
[root@test1 test]# git log --graph --pretty=oneline --abbrev-commit #(使用#git log--graph,可看到分支的詳細狀況,This is a shorthand for"--pretty=oneline --abbrev-commit" used together.)
[root@test1 test]# git log --graph
[root@test1 test]# git push origin master #(將當前分支推送到origin主機的對應分支,若是當前只有一個追蹤分支主機名能夠忽略)
Counting objects: 15, done.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (13/13), 1.14 KiB,done.
Total 13 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4),completed with 1 local objects.
To git@github.com:jowinchaitest/demo
6e62669..66c9414 master ->master
打標籤:
[root@test1 test]# git branch #(打標籤前,先肯定在哪一個分支上)
* master
[root@test1 test]# git tag v1.0
[root@test1 test]# git push origin v1.0 #(上傳本地當前代碼到master分支;#git push是上傳本地全部代碼到遠程對應的分支上)
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:jowinchaitest/demo
*[new tag] v1.0 -> v1.0
可在遠程服務器上查看:
[root@test1 test]# git show v1.0
commit66c94144338e45677db687ced4b2c2a6052a6118
Merge: 13b119c 1a96c6c
Author: jowinchai <jowinchai@163.com>
Date: Sat Dec 10 00:15:57 2016 -0800
conflict fixed
diff --cc readme.txt
index 73198d5,d70b440..d8e3e4e
--- a/readme.txt
+++ b/readme.txt
@@@ -1,4 -1,4 +1,5 @@@
1row test
2row test2
3row test3
+ 4row test4
+5row test5
持續集成:
markdown編輯器:
http://markdownpad.com/ #(windows,markdownpad)
http://25.io/mou/ #(mac,mou)
markdown是一種可使用普通文本編輯器編寫的標記語言,經過簡單的標記語法,它可使普通文本內容具備必定的格式;Markdown具備一系列衍生版本,用於擴展Markdown的功能(如表格、腳註、內嵌HTML等等),這些功能原初的Markdown尚不具有,它們能讓Markdown轉換成更多的格式,例如LaTeX,Docbook;
markdown加強版中比較有名的有MarkdownExtra、MultiMarkdown、Maruku等,這些衍生版本要麼基於工具,如Pandoc;要麼基於網站,如GitHub和Wikipedia,在語法上基本兼容,但在一些語法和渲染效果上有改動;
markdown的語法簡潔明瞭、學習容易,並且功能比純文本更強,所以有不少人用它寫博客,世界上最流行的博客平臺WordPress和大型CMS如Joomla、Drupal都能很好的支持Markdown,徹底採用Markdown編輯器的博客平臺有Ghost和Typecho;
markdown用於編寫說明文檔,而且以「README.MD」的文件名保存在軟件的目錄下面;
除此以外,如今因爲咱們有了RStudio這樣的神級編輯器,咱們還能夠快速將Markdown轉化爲演講PPT、Word產品文檔、LaTex論文甚至是用很是少許的代碼完成最小可用原型,在數據科學領域,Markdown已經被確立爲科學研究規範,極大地推動了動態可重複性研究的歷史進程;
標題:
標題能顯示出文章的結構,markdown中若是一段文字被定義爲標題,只要在這段文字前加#便可,總共支持六級標題,#與其後的文字用空格分隔,如1個#表示一級標題,##、###、####、#####、######,共支持6級標題
列表:
列表分有序列表和無序列表,無序列表用*或-;只有空格或tab的就是一個空行;
例:
無序列表:
* 1
* 2
* 3
無序列表:
- 1
- 2
- 3
有序列表:
1. 1
2. 2
3. 3
引用:
例:
> war,this is a reference
[unixhot](http://www.unixhot.com) #(連接,網頁引用,廣告連接)
 #(圖片引用,圖片廣告)
代碼框:
例1:
<TAB>while true:
<TAB><TAB>do echo nimei;
<TAB>done
例2:
'while true:
doecho nimei;
done'
例3:
'yum -y install lrzsz' 'echo nimei'
*的使用:
例:
*我變斜了* #(文字兩邊各1個*,把文字傾斜)
**我變粗了** #(文字兩邊用2個*,把文字變粗)
*** #(一行中僅有3個*,表示分割線)
[root@test1 ~]# cd /ane/test/demo/
[root@test1 demo]# vim README.md #(內容爲以上舉例的內容)
[root@test1 demo]# git add README.md
[root@test1 demo]# git commit -m 'justmodified'
[master 59f981e] just modified
1files changed, 4 insertions(+), 0 deletions(-)
[root@test1 demo]# git commit -m 'justmodified'
[master 59f981e] just modified
1files changed, 4 insertions(+), 0 deletions(-)
[root@test1 demo]# git push -u origin master -f
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 332 bytes,done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1),completed with 1 local objects.
To git@github.com:jowinchaitest/demo
b92b2ea..59f981e master ->master
Branch master set up to track remote branchmaster from origin.
打開網頁查看:
BitBucket是一家源代碼託管網站,採用Mercurial和Git做爲分佈式版本控制系統,同時提供商業計劃和免費帳戶;
https://bitbucket.org/
SonarQube是一個用於代碼質量管理的開源平臺,用於管理源代碼的質量,經過插件形式,能夠支持包括:java,C#,C/C++,PL/SQL,Cobol,JavaScrip,Groovy等等二十幾種編程語言的代碼質量管理與檢測;
Gitlab是一個用Ruby onRails開發的開源項目管理程序,能夠經過WEB界面進行訪問公開的或者私人項目。它和Github有相似的功能,可以瀏覽源代碼,管理缺陷和註釋。
gitlab.org
gitlab-ce-8.14.4-ce.0.el6.x86_64
[root@test4 ~]# yum -y install curl openssh-server openssh-clients postfix cronie
[root@test4 ~]# service postfix start
[root@test4 ~]# /etc/init.d/postfix restart
Shutting down postfix: [ OK ]
Starting postfix: [ OK ]
[root@test4 ~]# chkconfig --list postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@test4 ~]# service iptables stop #(#lokkit -s http -sssh)
iptables: Setting chains to policy ACCEPT:filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@test4 ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
[root@test4 ~]# yum -y install gitlab-ce #(ce,community edition)
……
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/____(_) /_/ / ____ _/ /_
// __/ / __/ / / __ `/ __ \
//_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
……
[root@test4 ~]# gitlab-ctl reconfigure
Running handlers:
Running handlers complete
Chef Client finished, 234/321 resourcesupdated in 13 minutes 01 seconds
gitlab Reconfigured!
[root@test4 ~]# gitlab-ctl status #(#gitlab-ctl start|stop|restart)
run: gitlab-workhorse: (pid 51686) 3108s;run: log: (pid 51523) 3765s
run: logrotate: (pid 54441) 139s; run: log:(pid 51605) 3742s
run: nginx: (pid 51569) 3758s; run: log:(pid 51568) 3758s
run: postgresql: (pid 51251) 3834s; run:log: (pid 51250) 3834s
run: redis: (pid 51111) 3845s; run: log:(pid 51110) 3845s
run: sidekiq: (pid 51478) 3772s; run: log:(pid 51477) 3772s
run: unicorn: (pid 51422) 3778s; run: log:(pid 51421) 3778s
[root@test4 ~]# gitlab-ctl tail nginx
……
[root@test4 ~]# netstat -tnulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 51472/unicorn maste
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 51569/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2876/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1805/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3085/master
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 51569/nginx
tcp 0 0 :::22 :::* LISTEN 2876/sshd
tcp 0 0 ::1:631 :::* LISTEN 1805/cupsd
tcp 0 0 ::1:25 :::* LISTEN 3085/master
udp 0 0 0.0.0.0:631 0.0.0.0:* 1805/cupsd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1810/dhclient
[root@test4 ~]# gitlab-ctl help
/opt/gitlab/embedded/bin/omnibus-ctl:command (subcommand)
deploy-page
Putup the deploy page
remove-accounts
Delete *all* users and groups used by this package
upgrade
Runmigrations after a package upgrade
General Commands:
cleanse
Delete *all* gitlab data, and start from scratch.
help
Print this help message.
reconfigure
Reconfigure the application.
show-config
Show the configuration that would be generated by reconfigure.
uninstall
Kill all processes and uninstall the process supervisor (data will bepreserved).
Service Management Commands:
graceful-kill
Attempt a graceful stop, then SIGKILL the entire process group.
hup
Send the services a HUP.
int
Send the services an INT.
kill
Send the services a KILL.
once
Start the services if they are down. Do not restart them if they stop.
restart
Stop the services if they are running, then start them again.
service-list
List all the services (enabled services appear with a *.)
start
Start services if they are down, and restart them if they stop.
status
Show the status of all the services.
stop
Stop the services, and do not restart them.
tail
Watch the service logs of all enabled services.
term
Send the services a TERM.
Database Commands:
pg-upgrade
Upgrade the PostgreSQL DB to the latest supported version
revert-pg-upgrade
Run this to revert to the previous version of the database
Container Registry Commands:
registry-garbage-collect
Run Container Registry garbage collection.
[root@test4 ~]# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf #(定義網頁監聽的端口)
[root@test4 ~]# cp /opt/gitlab/etc/gitlab.rb.template /opt/gitlab/etc/gitlab.rb
[root@test4 ~]# vim /opt/gitlab/etc/gitlab.rb #(/etc/gitlab/gitlab.rb此處會將external_url設爲http://YOUR_HOSTNAME;可將external_url改成以下,這個地址很重要,上傳的圖片什麼的,url會以這個爲基準,若是地址寫錯,將沒法訪問到圖片等這些資源)
external_url 'http://192.168.23.132'
http://192.168.23.132
默認user:root,password:wavel!fe
注:第一次啓動的時候,須要初始化大量的東西,常常會出現502錯誤,一般是因爲內存不足的緣由致使,因此須要準備好足夠的內存,官方推薦生產環境中使用2G內存,2核CPU,虛擬機中測試1GB內存基本就能夠了
FAQ:
[root@test1 demo]# git push -u originmaster
To git@github.com:jowinchaitest/demo
![rejected] master -> master(non-fast-forward)
error: failed to push some refs to'git@github.com:jowinchaitest/demo'
To prevent you from losing history,non-fast-forward updates were rejected
Merge the remote changes before pushingagain. See the 'Note about
fast-forwards' section of 'git push --help'for details.
注:當處於master branch默認的remote就是origin,當在master branch使用#git pull時,沒有指定remote和branch,那git就會採用默認的remote(origin)來merge在masterbranch上的全部改變
出現non-fast-forwards緣由:git倉庫已有一部分代碼,不容許直接把本地代碼覆蓋到遠程主機上,解決:
1、#git push-f #(強制,以覆蓋方式將本地的代碼替代git倉庫中的內容)
2、#git fetch
#git merge
這兩個命令等價於#git pull,最後#gitpush
應用上線:
獲取代碼-->編譯(可選)-->配置文件-->打包-->copy到對應服務器(對應目錄)-->部署節點、移除集羣-->解壓、copy差別文件-->建立軟連接-->重啓-->自動化測試-->加入集羣-->列出回滾版本-->執行回滾-->刪除軟連接-->從新建立軟連接-->重啓(可選)
[root@test1 ~]# vim pro-deploy.sh
---------------------script start------------------
#!/bin/bash
#
DATE=`date "+%Y-%m-%d"`
TIME=`date "+%Y-%m-%d-%H-%M"`
CODE_DIR=/ane/test/demo
CONFIG_DIR=/ane/test/config
TAR_DIR=/ane/tar
TMP_DIR=/ane/tmp
usage() {
echo$"Usage: $0 [deploy|rollback-list|rollback-pro VERSION]"
}
git_pro() {
echo "git pull"
cd $CODE_DIR && git pull
API_VERL=`gitshow | grep commit | cut -d' ' -f2`
API_VER=`echo${API_VERL:0:6}`
/bin/cp -r $CODE_DIR $TMP_DIR
}
config_pro() {
echo "add pro config"
/bin/cp $CONFIG_DIR/* $TMP_DIR/demo
TAR_VER=$API_VER-$TIME
cd $TMP_DIR && mv demo pro_demo_"$TAR_VER"
}
tar_pro() {
echo "tar_pro"
cd $TMP_DIR && tar zcf pro_demo_"$TAR_VER".tar.gz pro_demo_"$TAR_VER"
echo "tar end"
}
scp_pro() {
echo "begin scp"
/bin/cp$TMP_DIR/pro_demo_"$TMP_VER".tar.gz /tmp/
}
deploy_pro() {
echo "begin deploy"
cd /tmp && tar zxf pro_demo_"$TAR_VER".tar.gz
rm -f /var/www/html/demo
ln -s /tmp/pro_demo_"$TAR_VER" /var/www/html/demo
}
test_pro() {
echo "test begin"
echo "test ok"
}
rollback_list() {
ls -l /tmp/*.tar.gz
}
rollback_pro() {
rm -f /var/www/html/demo
ln -s /tmp/$1 /var/www/html/demo
}
main() {
case $1 in
deploy)
git_pro;
config_pro;
tar_pro;
scp_pro;
deploy_pro;
test_pro;
;;
rollback-list)
rollback_list;
;;
rollback-pro)
rollback_pro$2;
;;
*)
usage;
esac
}
main $1 $2
---------------------scriptend-----------------
[root@test1 test]# git show #(#git show的第一行)
commit0487226e101b59fd4ea1e63ccbe7760cebe240a2
Author: jowinchai <jowinchai@163.com>
Date: Wed Dec 14 22:24:09 2016 -0800
……
[root@test1 test]# git show | grep commit | cut -d' ' -f2
0487226e101b59fd4ea1e63ccbe7760cebe240a2
#./pro-deploy.sh deploy
#./pro-deploy.sh rollback-list
#./pro-deploy.sh rollback-pro