Centos6.5 install gitlab and migrate gitolite

Source: Internet
Author: User
Tags ldap
Centos6.5 install gitlab and gitolite to migrate gitlabgitlab and install Data Structures

Environment:

  • Centos6.5
  • If you want to change your application environment to passpsenger Based on the application environment established by using the nginx + unicorn, refer to the documentation on the internet.
  • The ruby environment is built based on rbenv.
1: Install Vim

yum install -y vim

2: Install git> 1.7.10
  • Install git
$ Rpm-I 'HTTP: // your rpm -- import http://apt.sw.be/rpm-gpg-key.dag.txt$ Vim/etc/yum. repos. d/rpmforge. repo # enabled = 0 => enabled = 1 $ Yum install-y git $ git -- versiongit version 1.7.12.4 $ Yum clean all under [rpmforge-extras]

Reference: http://tecadmin.net/how-to-upgrade-git-version-1-7-10-on-centos-6 /#

  • Git config
git config --global user.name ‘jerry‘git config --global user.email ‘[email protected]‘git config --global color.branch ‘auto‘git config --global color.diff ‘auto‘git config --global color.interactive ‘auto‘git config --global color.interactive ‘auto‘git config --global core.editor ‘/usr/bin/vim‘
3: Install dependent rpm
  • First: replace Yum Repo
rpm -Uvh http://mirrors.sohu.com/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
  • Second: Install
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml libyaml-devel libffi libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel git-core libxml libxml-devel libxslt libxslt-devel wget pcre-devel openssl openssl-devel tcl tcl-devel libaio-devel ntpdate libicu-devel
4: Install rbenv & Ruby
  • Add users: git
adduser --comment ‘GitLab‘ --create-home --home-dir /home/git git
  • Use rbenv-installer install rbenv
cd /home/git/sudo -u git sh -c "curl https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer > rbenv-installer"su - git -c ‘/bin/bash rbenv-installer‘sudo -u git -H echo ‘export RBENV_ROOT="${HOME}/.rbenv"if [ -d "${RBENV_ROOT}" ]; then  export PATH="${RBENV_ROOT}/bin:${PATH}"  eval "$(rbenv init -)"fi‘ >> /home/git/.bashrc
  • Install Ruby
su - git -c ‘rbenv install 2.0.0-p353‘su - git -c ‘rbenv global 2.0.0-p353‘
  • Install bundler
su - git -c ‘gem install bundler --no-ri --no-rdoc‘
5: Install gitlab
  • Install gitlab Shell
Sudo-u Git-H git clone https://gitlab.com/gitlab-org/gitlab-shell.gitcd gitlab-shellsudo-u Git-h cp config. yml. example config. yml # Note: replace your_git_domain with your Sudo-u Git-H sed-I's/localhost/your_git_domain/g'config. ymlsu-Git-c '/home/git/gitlab-shell/bin/install'
  • Install MySQL, redis, and nginx

Refer: http://blog.58share.com /? P = 291

  • Install gitlab
CD/home/gitsudo-u Git-H git clone https://gitlab.com/gitlab-org/gitlab-ce.git-B 6-6-stable gitlabcd/home/git/gitlabsudo-u Git-h cp config/gitlab. yml. example config/gitlab. yml # Make sure to change "localhost" to the fully-qualified domain name of your # If you installed git from source, change the GIT bin_path to/usr/local/bin/git # Modify host (domain name), email_from: (email), support_email (email) here) sudo-u Git-H Vim config/gitlab. ymlchown-r git log/chown-r git tmp/chmod-r u + rwx log/chmod-r u + rwx tmp/Sudo-u Git-H mkdir/home/git/ gitlab-satellitessudo-u Git-H mkdir tmp/PIDs/Sudo-u Git-H mkdir tmp/sockets/chmod-r u + rwx tmp/PIDs/chmod-r u + rwx TMP/sockets/Sudo-u Git-H mkdir public/uploadschmod-r u + rwx public/uploadssudo-u Git-h cp config/Unicorn. RB. example config/Unicorn. RB # ex. change amount of workers to 3 for 2 gb ram serversudo-u Git-H Vim config/Unicorn. rbsudo-u Git-h cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rbsudo-u Git-H git config -- global user. name "gitlab" Sudo-u Git-H git config -- global user. email "[email protected]" Sudo-u Git-H git config -- global core. autocrlf input # mysqlsudo-u git CP config/database. yml. mySQL config/database. yml # modify the configuration file config/database. yml
  • Install gem
Su-gitcd/home/git/gitlab # Notes: ram must be> 512 m if your MySQL onbundle install -- deployment -- without development test Postgres AWS # confirm database configuration is correct # create database bundle exec rake DB: create rails_env = production # initialize gitlab data notes: Need redisbundle exec rake gitlab: Setup rails_env = production # Here the database is cleared, for the first time, enter yes # Install scriptcp lib/support/init. d/gitlab/etc/init. d/gitlab
  • Start Server
/etc/init.d/gitlab start
  • Check env
# Check the environment bundle exec rake gitlab: ENV: info rails_env = production executed by gitlab # Check bundle exec rake gitlab: Check rails_env = Production
  • Compile static files and configure nginx
# Compile the static file bundle exec rake assets: precompile rails_env = production # configure nginx # Note: the nginx configuration user is git cp lib/support/nginx/gitlab/usr/local/nginx/CONF. d/gitlab. conf
  • Bind host
vim /etc/hosts127.0.0.1 your_domain
  • Deployed successfully
Follow the above deployment: After the deployment is successful, access the domain name # That's all # Username: [email protected] # password: 5 ivel! Fe # after the first entry, You need to reset the password. After the setting is successful, the deployment is successful.
  • Installation document refer:

Http://www.digitalsanctuary.com/tech-blog/general/installing-gitlab-on-redhat-enterprise-5-rhel-5.html

Https://gitlab.com/gitlab-org/gitlab-ce/blob/6-6-stable/doc/install/installation.md

Migrate gitolite to gitlab Step 1. initialize MySQL Configuration

bundle exec rake gitlab:setup RAILS_ENV=production

After initialization: you can log on to the super Administrator Account:

username: [email protected] password: 5iveL!fe
2. Import existing projects to gitlab

bundle exec rake gitlab:import:repos RAILS_ENV=production

3. Obtain the root API key token, write the token as the client configuration, and perform API-related operations.
  • Create a user and insert the corresponding ssh-key. The newly created user has no permission to create a group.
  • Obtain the created groups and write users to different groups based on the groups.
  • Add the admin administrator to all groups. manually set the corresponding user as the administrator and allow the user to create groups.
  • User operations with email addresses involve online database updates, online test machine pulling, manual virtual user creation, and corresponding Permissions
    Offline machines do not have the push permission and are set to reporter.
  • The merging personnel must be set to master for this project.
  • Administrator account, and modify their corresponding permission control and number of projects created
4. Write a script to change the validation status of all users created through the API to the confirmed status, and perform operations under the project.

$ Vim lib/task/gitlab/user. Rake

namespace :gitlab do  desc "Update all users‘confirmed is true"  task :update_confirmed => :environment do.     User.find_each do |user|       user.confirmation_token = nil       user.confirmed_at = Time.now       user.save     end  endend

Perform operations

bundle exec rake gitlab:updateconfirmed RAILSENV=production

Other related configurations
  • Configure SMTP mail service

cd /home/git/gitlab

$ Vim config/environments/production. Rb

  config.action_mailer.delivery_method       = :smtp  config.action_mailer.perform_deliveries    = true  config.action_mailer.raise_delivery_errors = true  config.action_mailer.smtp_settings = {    :address              => ‘smtp.exmail.qq.com‘,    :port                 => 465,    :domain               => ‘qq.com‘,    :user_name            => ‘email_address‘,    :password             => ‘password‘,    :authentication       =>  :plain,    :enable_starttls_auto => true  }
  • Configure LDAP

cd /home/git/gitlab

$ Vim config/gitlab. yml

LDAP: enabled: true host: your_ldap_host base: 'ou = accounts, Dc = domain, Dc = com 'port: your_port uid: 'uid' method: 'plain '# "TLS" or "SSL" or "plain" bind_dn: 'cn = binder, Dc = domain, Dc = com 'password: 'Your _ password' allow_username_or_email_login: true # Whether username or email logon is allowed. If this parameter is set to false, only the LDAP portal is displayed.
Notes: migration project pitfalls 1. user data can be obtained through the interface. By default, only 20 pieces of data can be obtained, and up to 100 pieces of data can be obtained by page. 2. you can obtain only 20 items by default through the interface. if it is a migration project, if the previous git project has a multi-layer interface, you need to change it to a layer, such as Java/ABC/AAA. git => JAVA/abc_aaa.git, because gitlab does not support multi-level structure 4. some projects with keywords cannot be created successfully, such as Java/admin. git, Ruby/services. for the git5. gitlab clone project, both SSH and HTTP call HTTP requests to determine user permissions and perform other operations. The LDAP access permission is configured for our HTTP request. Therefore, you need to add the IP address of the Local Machine (gitlab server) to the LDAP white list for reference.
  • Import existing projects to gitlab
bundle exec rake gitlab:import:repos RAILS_ENV=production

* Add all users to all groups (the admin role is the owner)

bundle exec rake gitlab:import:all_users_to_all_groups RAILS_ENV=production

* Add all users to all projects (the admin role is master)

bundle exec rake gitlab:import:all_users_to_all_projects RAILS_ENV=production

* Add a special user to all groups (Role: Developer)

bundle exec rake gitlab:import:user_to_groups[email] RAILS_ENV=production

* Add a special user to all projects (Role: Developer)

bundle exec rake gitlab:import:user_to_projects[email] RAILS_ENV=production

# Other gitlab references #### API related if gitlab has your public key, you can use authentication_token to call the API

curl --header "PRIVATE-TOKEN: ArTMXVSWjFEYn9DQrL7f" "http://git.tuan800-inc.com/api/v3/user/keys"
Gitlab API gem

Refere: https://github.com/NARKOZ/gitlab

Problem: the interface of this gem package is V2, but gitlab is now stable version V3, but some functions can be used, and some functions described in some interfaces need to be written by themselves.

Other helpsrefer: http://mrk1869.com/blog/gitlab_installation/gitupgrade Solution

How to upgrade git version> = 1.7.10 on centos 6

Refer: http://tecadmin.net/how-to-upgrade-git-version-1-7-10-on-centos-6 /#

Git clone project times no environment variable

Refer: http://thoughtpointers.net/2013/04/18/using-rbenv-with-gitlab-shell-on-os-x/

Git push Error
test [master] % ggpushCounting objects: 3, done.Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)remote: GitLab: An unexpected error occurred (redis-cli returned 127).remote: error: hook declined to update refs/heads/masterTo [email protected]:huhongda/test.git ! [remote rejected] master -> master (hook declined)error: failed to push some refs to ‘[email protected]:huhongda/test.git‘

Solution: Modify the redis-cli path in gitlab-shell/config/gitlab. yml to the correct path.

#### Check if the running environment of gitlab is correct. Bundle exec rake gitlab: Check rails_env = production #### errorsall migrations up?... Rake aborted! Cannot allocate memory-Git log -- pretty = format: '% H'-N 1/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/core_ext/kernel/agnostics. RB: 7: In '''/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/core_ext/kernel/agnostics. RB: 7: In '''/home/git/gitlab/config/initializers/2_app.rb: 3: In ''/home/git/gitlab/config/initializers/2_app.r B: 1: In ''/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies. RB: 223: In 'load'/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies. RB: 223: In 'block in load'/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies. RB: 214: In 'Load _ dependency '/home/git/gitlab/vendor/bu Ndle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies. RB: 223: In 'load'/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/engine. RB: 609: In 'block (2 levels) in '/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/engine. RB: 608: In 'wheel'/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/engine. RB: 608: In 'block in'/home /Git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/initializable. RB: 30: In 'instance _ exec '/home/git/gitlab/vender/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/initializable. RB: 30: In 'run'/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/initializable. RB: 55: In 'block in run_initializers'/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/I Nitializable. RB: 44: In 'wheel'/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/initializable. RB: 44: In 'tsort _ each_child '/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/initializable. RB: 54: In 'run _ initializers'/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/application. RB: 215: In 'initialize! '/Home/git/gitlab/vendor/ bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/railtie/retriable. RB: 30: In 'method _ missing '/home/git/gitlab/config/environment. RB: 5: In ''/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies. RB: 229: In 'require '/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies. RB: 229: In 'block in Require '/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies. RB: 214: In 'Load _ dependency '/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/dependencies. RB: 229: In 'require '/home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/application. RB: 189: In 'require _ environment! '/Home/git/gitlab/vendor/bundle/Ruby/2.0.0/gems/railties-4.0.3/lib/rails/application. RB: 250: In 'block in run_tasks_blocks 'tasks: Top => DB: migrate: Status => environment (see full trace by running task with -- Trace)

Solution: due to the lack of memory, if VPs is used, use free-m to check if the memory is too small or swap memory is not used. If swap is not used, add swap, generally, it is 1 or 1.5 times of memory.

# Swapmkdir-P/data/swapdircd/data/swapdirdd if =/dev/Zero of = swapfile BS = 1024 COUNT = 1024000 mkswap/data/swapdir/swapfileswapon swapfile # enable swapswapswapoff # disable swap # use free-m to view memory conditions # Add enable echo '/data/swapdir/swapfile swap ults 0 0'>/etc/fstab
Reference

Http://mrk1869.com/blog/gitlab_installation/ http://www.digitalsanctuary.com/tech-blog/general/installing-gitlab-on-redhat-enterprise-5-rhel-5.html https://gitlab.com/gitlab-org/gitlab-ce/blob/6-6-stable/doc/install/installation.md http://git.58share.com/help/api/README

This is a project for gitlab API

Https://github.com/NARKOZ/gitlab

Https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/groups.md

 

This entry was posted in git, Linux

Leave a reply

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.