GitLab Development Kit 環境搭建

在公司內網服務器上面搭建gdk環境,踩了不少坑,歷時四五天(中間涉及申請開通固定外網),整理以下:php

總覽:html

操做系統:redhat 6.3node

參考文檔:https://gitlab.com/gitlab-org/gitlab-development-kitlinux

準備階段

 

申請開通網絡

registry.npm.taobao.orgwebpack

registry.yarnpkg.comc++

yarnpkg.comgit

upyun.gems.ruby-china.orggithub

nm.ctn.aicdn.comgolang

yum.postgresql.orgweb

download.fedoraproject.org

get.rvm.io

keys.gnupg.net

cache.ruby-china.org

gitlab.com

github.com

gems.ruby-china.org

 

配置代理/etc/profile中追加:

http_proxy=http://192.168.XX.XX:8080

https_proxy=$http_proxy

no_proxy=XX.XX.XX.XX,XX.XX.XX.XX

export http_proxy https_proxy no_proxy

  

 

 

新建用戶gitdev

user add gitdev

 

開通sudo權限,在/etc/sudoers後追加:

gitdev ALL=(ALL) ALL

注意:sodu出現環境變量問題引發的命令找不到時,設置secure_path便可。

 

如下安裝都用gitdev用戶進行

 

安裝步驟

安裝ruby

下載安裝包:ruby-2.4.1.tar.gz

tar –xvzf ruby-2.4.1.tar.gz

cd ruby-2.4.1

./configure

make

sudo make install

 

安裝/更新本地的nodejs和npm

下載最新版本的npm和node:http://nodejs.cn/download/

node-v8.2.1-linux-x64.tar.xz 

解壓

/opt/software/node-v8.2.1-linux-x64

設置環境變量

$ vim /etc/profile

export NODE_HOME=/opt/software/node-v8.2.1-linux-x64
export PATH=$PATH:$NODE_HOME/bin/

 

配置npm源到公司源(若是沒有公司的npm源,可配置到淘寶源):

npm config set registry=https://XXX.XX.com

修改gem源

gem sources --add http://gems.ruby-china.org/ --remove https://rubygems.org/

 

注意:執行過程當中openssl相關報錯

安裝openssl和openssl-devel

而後到ruby的安裝目錄執行:

ruby extconfig.rb
make
make install

 

過程當中報錯:make: *** No rule to make target `/thread_native.h', needed by `ossl.o'.  Stop.

實際上是ext/openssl/Makefile中忘了給路徑變量top_srcdir賦值,調用的時候固然就報錯了,修改 Makefile 增長 top_srcdir = ../.. 

 

安裝rails

gem install rails –y

 

測試執行命令時報錯:

rails server

rails g controller events

ERROR:  Loading command: install (LoadError)

    no such file to load -- zlib

進入ruby源碼文件夾

安裝ruby自身提供的zlib包

#cd ext/zlib

#ruby ./extconf.rb

#make

#make install

來源: <http://blog.csdn.net/kenera/article/details/6524557>

報錯信息;

make: *** No rule to make target `/thread_native.h', needed by `ossl.o'.  Stop.

解決這個問題,修改 Makefile 增長 top_srcdir = ../.. 便可。

 

Preparing your computing environment for GDK

進入頁面:https://gitlab.com/gitlab-org/gitlab-development-kit/blob/master/doc/prepare.md

頁面給出的提示,要仔細閱讀並遵守執行,不然會走不少彎路:

Prerequisites for all platforms

If you do not have the dependencies below you will experience strange errors
during installation.


A non-root Unix user, this can be your normal user but DO NOT run the
installation as a root user
Ruby 2.3 (2.3.3 or newer) installed with a Ruby version manager
(RVM, rbenv, chruby, etc.), DO NOT use the
system Ruby
Bundler, which you can install with gem install bundler

Git version of 2.7.X or higher
Node 4.3 or newer and Yarn 0.17 or newer. If your package manage does not
have up-to-date versions of node or yarn available, visit the official
websites for node and yarn for installation instructions.
Go 1.8.3 or newer. If your package manager does not have up-to-date versions
of Go available, visit the official website for go for installation instructions.

 

找到對應的操做系統安裝步驟,本例中是centos,因此,執行centos的安裝步驟:

CentOS

頁面步驟:

Please read the prerequisites for all platforms.

 

This is tested on CentOS 6.5:

 

sudo yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm

sudo yum install https://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

sudo yum install postgresql95-server postgresql95-devel libicu-devel cmake gcc-c++ redis ed fontconfig freetype libfreetype.so.6 libfontconfig.so.1 libstdc++.so.6 nodejs npm re2

 

sudo npm install phantomjs-prebuilt@2.1.12 -g

 

bundle config build.pg --with-pg-config=/usr/pgsql-9.5/bin/pg_config

sudo rvm install 2.3

sudo rvm use 2.3

#Ensure your user is in rvm group

sudo usermod -a -G rvm <username>

#add iptables exceptions, or sudo service stop iptables

Install go manually using go official installation instructions.

 

Install phantomJS manually, or download it and put in your $PATH. For

instructions, follow the Debian guide on phantomJS.

 

Git 1.7.1-3 is the latest git binary for CentOS 6.5 and GitLab. Spinach tests

will fail due to a higher version requirement by GitLab. You can follow the

instructions found in the GitLab recipes repository to install a newer

binary version of Git.

 

You may need to install Redis 2.8 or newer manually.

安裝實踐:

因爲是內網環境,有些安裝包可能會出現缺失,因此第一次安裝不到的後面分批次安裝。

yum安裝軟件1:

$ sudo yum install postgresql95-server postgresql95-devel libicu-devel cmake gcc-c++ redis ed fontconfig freetype libfreetype.so.6 libfontconfig.so.1 libstdc++.so.6 nodejs npm re2

Loaded plugins: product-id, security, subscription-manager

 

注意:有些軟件服務器所在的yum源沒有提供,則後面進行安裝,若是已經安裝,後面有些步驟能夠跳過。

yum安裝軟件2:

安裝postgresql相關

可參考地址:http://www.cnblogs.com/mchina/archive/2012/06/06/2539003.html

包下載地址:https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6.3-x86_64/

按照順序rpm –ivh安裝,也可yum安裝

postgresql96-libs-9.6.4-1PGDG.rhel6.x86_64.rpm

postgresql96-9.6.4-1PGDG.rhel6.x86_64.rpm

postgresql96-server-9.6.4-1PGDG.rhel6.x86_64.rpm

postgresql96-devel-9.6.4-1PGDG.rhel6.x86_64.rpm

postgresql96-contrib-9.6.4-1PGDG.rhel6.x86_64.rpm

 

注意:安裝postgresql96-contrib時可能會報卻依賴:resource libxslt.so.1()(64bit)

下載libxslt-1.1.26-2.el6_3.1.x86_64.rpm安裝,在安裝postgresql96-contrib便可。

安裝完成 驗證便可:

驗證步驟可以下:

service postgresql-9.6 initdb  #初始化

service postgresql-9.6 start  #啓動服務

chkconfig postgresql-9.6 on  #加入開機自啓動

#修改密碼爲postgres 此步驟只是驗證,不是安裝gdk環境必須的

# su - postgres

$ psql

# ALTER USER postgres WITH PASSWORD 'postgres';

# select * from pg_shadow ;

  出現相關信息。

驗證成功!

yum安裝軟件3:

安裝re2

下載地址:https://mirrors.tuna.tsinghua.edu.cn/epel/6/x86_64/

$sudo yum install  re2-20130115-2.el6.x86_64.rpm re2-devel-20130115-2.el6.x86_64.rpm

  

 

安裝phantomjs-prebuilt

$ npm install phantomjs-prebuilt@2.1.12 --ignore-scripts

  

配置bundle

$ bundle config build.pg --with-pg-config=/usr/pgsql-9.6/bin/pg_config

  

 

安裝GO

下載:https://golang.org/doc/install?download=go1.8.3.linux-amd64.tar.gz

解壓安裝: 

$ tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz

  

設置環境變量:

vim /etc/profile
export PATH=$PATH:/usr/local/go/bin

  

安裝:phantomJS

下載:https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2

 

PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"

cd ~

wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2

tar -xvjf $PHANTOM_JS.tar.bz2

sudo mv $PHANTOM_JS /usr/local/share

sudo ln -s /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

phantomjs –version

  

 

注:安裝成功後,查看版本報錯以下:

[root@neptunesitweb12 software]# phantomjs --version

phantomjs: /lib64/libz.so.1: no version information available (required by phantomjs)

2.1.1

解決:zlib沒有安裝或者版本過低,本次安裝是因爲版本過低:

wget http://zlib.net/zlib-1.2.7.tar.gz  

tar zxvf zlib-1.2.11.tar.gz  

cd zlib-1.2.11   

./configure  

make  

make install 

  

覆蓋原來的:

cp libz.so.1  /lib/libz.so.1.2.3

cp libz.so.1   /lib64/libz.so.1.2.3

[root@neptunesitweb12 zlib-1.2.11]# phantomjs --version

2.1.1

安裝git

版本須要 >=1.7.1-3

本次安裝版本:2.10.2,

準備軟件: git-2.10.2.tar.gz

安裝依賴:

$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

  

解壓

 $ tar –xvzf  git-2.10.2.tar.gz

 $ cd  git-2.10.2

 $ make prefix=/usr/local/git all

 $ sudo make prefix=/usr/local/git install

  

設置環境變量

$ vim /etc/profile

export PATH=/usr/local/git/bin:$PATH

  

 

驗證查看版本:

$ git --version
git version 2.10.2

  

安裝redis

要求版本 >=2.8

 

下載地址:http://www.redis.net.cn/download/

redis-3.0.6.tar.gz

$ tar –xvzf  redis-3.0.6.tar.gz

$ cd redis-3.0.6

$ make test

$ make prefix=/usr/local/redis install

  

 

過程當中報錯:

Hint: It's a good idea to run 'make test' ;) 可忽略

 

 

修改環境變量

$ vim /etc/profile

export PATH=/usr/local/redis/bin:$PATH

$ source /etc/profile

  

執行啓動命令redis-server

測試redis 命令redis-cli

 

Set up GDK

此步驟過程當中不能用root執行時,要切換到非root用戶,本次安裝使用gitdev用戶

安裝gdk

$ gem install gitlab-development-kit

  

初始化項目&執行安裝

gdk init gdk-ee

cd gdk-ee

echo 3001 > port

echo 3809 > webpack_port

echo XX.XX.XX.XXX >host  #此步驟可根據我的須要,默認是localhost

gdk install gitlab_repo=https://gitlab.com/gitlab-org/gitlab-ee.git

  

 

解釋:

gem install gitlab-development-kit 安裝軟件

gdk init  [能夠跟項目名稱,也能夠不跟,不跟默認爲gitlab-development-kit]

gdk install #下載代碼 https://gitlab.com/gitlab-org/gitlab-ce.git gitlab

 

過程當中bundle報錯以下:

 

因爲本次安裝服務器不能連外網,因此可切換到已經開了白名單的gem源gems.ruby-china.org, 修改Gemfile中的源到gems.ruby-china.org

 

$ vim gitlab/Gemfile

source 'https://gems.ruby-china.org'

$ vim gitlab/Gemfile.lock

source 'https://gems.ruby-china.org'

  

 

 

過程當中提示缺乏安裝的組件,一一安裝便可:

本例中層提示以下:

gem install charlock_holmes -v '0.7.3'

gem install ffi -v '1.9.10'

 

gem install rubocop-rspec

 

gem install charlock_holmes -v '0.7.3'

注:安裝報錯,icu required (brew install icu4c or apt-get  install libicu-dev)

解決辦法:下載安裝libicu-devel-4.2.1-14.el6.x86_64.rpm 
libicu-4.2.1-14.el6.x86_64.rpm

下載地址:http://www.rpmfind.net/linux/rpm2html/search.php?query=libicu%28x86-64%29&submit=Search+...&system=centos&arch=

安裝命令:

$ yum install libicu-4.2.1-14.el6.x86_64.rpm  libicu-devel-4.2.1-14.el6.x86_64.rpm

  

再執行下面命令便可:

$ gem install charlock_holmes -v '0.7.3' --  --with-icu-lib=/usr/lib64

  

 

 

gem install rugged -v '0.26.0'

報錯,須要升級cmake版本到2.8以上

下載cmake: https://cmake.org/files/v2.8/

解壓編譯安裝設置環境變量

$ cmake --version

cmake version 2.8.11.2

  

 

 

 

報錯:Yarn executable was not detected in the system.

安裝yarn

npm install yarn –g

切換源到淘寶源

$ yarn config set registry https://registry.npm.taobao.org

  

 

 

報錯:LoadError:cannot load such file --readline

解決辦法:找打gems安裝路徑下的byebug-9.0.6/lib/byebug/history.rb

注掉require 'readline'

 

報錯:Authentication is required for http://rubygems.org/

Please supply credentials for this source....

解決辦法:修改:/opt/software/gitlab-development-kit/gitlab-shell

下的Gemfile.lock Gemfile中的rubygems到http://gems.ruby-china.org

執行報錯:

 make:pg_config :Command not found

解決辦法:postgresql沒有安裝或者沒有配置環境變量

確認已經安裝,即配置環境變量

 

解決完諸多報錯以後,後面還會進行一些數據庫的初始化、redis的初始化操做,都是有命令自動完成的,耐心等待便可。出現下面的setup finished,恭喜你,安裝成功了。

 

*********************************************

************** Setup finished! **************

*********************************************

cat HELP

# GitLab Development Kit cheat sheet

 

gdk run            # Start everything

gdk run db         # Start enough to run tests

gdk run app        # Start GitLab, needs 'gdk run db'

 

gdk install gitlab_repo=https://my-fork   # Install everything

gdk update                                # Pull application changes from Git

gdk reconfigure                           # Delete and regenerate all config files created by GDK

gdk psql -d gitlabhq_development          # Postgres console

gdk redis-cli                             # Redis console

 

# Development admin account: root / 5iveL!fe

 

For more information about GitLab development see

https://docs.gitlab.com/ce/development/README.html.

*********************************************

git clone https://gitlab.com/gitlab-org/gitaly.git gitaly/src/gitlab.com/gitlab-org/gitaly

Cloning into 'gitaly/src/gitlab.com/gitlab-org/gitaly'...

remote: Counting objects: 6183, done.

remote: Compressing objects: 100% (3453/3453), done.

remote: Total 6183 (delta 2935), reused 5057 (delta 2280)

Receiving objects: 100% (6183/6183), 6.13 MiB | 1.56 MiB/s, done.

Resolving deltas: 100% (2935/2935), done.

GO15VENDOREXPERIMENT=1 GOPATH=/opt/chenyu/gdk-geo/gitaly go install gitlab.com/gitlab-org/gitaly/cmd/...

sed \

           -e "s|^socket_path.*|socket_path = \"/opt/chenyu/gdk-geo/gitaly.socket\"|" \

           -e "s|# prometheus_listen_addr|prometheus_listen_addr|" \

           -e "s|/home/git|/opt/chenyu/gdk-geo|" gitaly/src/gitlab.com/gitlab-org/gitaly/config.toml.example > gitaly/config.toml

ln -s /opt/chenyu/gdk-geo/gitaly/src/gitlab.com/gitlab-org/gitaly/ruby gitaly/ruby

 

gdk  run

 

在項目/opt/chenyu/gdk-ee下執行:

$ gdk run

  

順利的話,出現以下log,即啓動成功:

 

21:07:19 rails-background-jobs.1 | resque:gitlab:queue:export_csv
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:git_garbage_collect
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:update_user_activity
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:elastic_indexer
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:admin_emails
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:irker
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:authorized_projects
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:expire_build_instance_artifacts
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:use_key
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:elastic_batch_project_indexer
21:07:19 rails-background-jobs.1 | resque:gitlab:queue:project_destroy
21:07:19 rails-background-jobs.1 | 2

.......

  

 

此時,訪問http://ip:3001 即出現gitlab的登陸頁面:

 

 

恭喜你,安裝成功~~

 

其餘的報錯和解決辦法以下:

 

 

缺包:

exec gitaly/bin/gitaly /opt/gitDEV/gdk-ee/gitaly/config.toml執行的時候報錯

 

# gem install grpc -v '1.4.1'

 

gem install gitaly -v '0.19.0'

 

 

 

npm install webpack-dev-server –g

 

npm install webpack –g

 

 

 

 

ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR:  could not open extension control file "/usr/pgsql-9.5/share/extension/pg_trgm.control": No such file or directory

: CREATE EXTENSION IF NOT EXISTS "pg_trgm"

 

手動執行MakeFile中的第三步驟

報錯:realpath:command not found 

解決:

echo '/usr/bin/readlink -e "$@"' > /usr/local/bin/realpath ; chmod +x /usr/local/bin/realpath

再次執行:成功

相關文章
相關標籤/搜索