Redmine and Gitlab are great project and code management systems, both based on Ruby on Rails, so I migrate them together and record Rails migration notes here.
Install Rails
install RVM in new server
1
2
3
4
5gpg2 --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
source ~/.bashrc
source ~/.bash_profile
rvm -vinstall Ruby in new server
1
2
3
4
5
6rvm list known
rvm install 2.6.0 --disable-binary
rvm use 2.6.0 --default
rvm list
rvm remove 1.8.7
ruby -vcreate new Gemset
1
2
3
4
5
6
7
8
9
10
11rvm use 2.6.0
rvm gemset create rails522
rvm gemset list
rvm use 2.6.0@rails522
gem -v
gem install bundler
gem install rails -v 5.2.2
gem install thin -v 1.7.2
bundle -v
rails -v
thin -v
Migrate Redmine
- install dev package neededif libjbig0 error in 18.04, download right version
1
2apt install libmysqlclient-dev
apt install imagemagick libmagickcore-dev libmagickwand-devdpkg -i libjbig0_2.1-3.1build1_amd64.deb
- modify thin config
1
2thin install
vi /etc/thin/redmine.yml---
chdir: /var/www/artec/mine
environment: production
address: 0.0.0.0
port: 3000
timeout: 30
log: log/thin.log
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 512
require: []
wait: 30
servers: 5
daemonize: true
- migrate Redmine
- download latest
- migrate config
1
2cp config/database.yml ./config
cp config/configuration.yml ./config - migrate files and theme
1
2cp -r files ./
cp -r public/themes/dengcb public/themes - install gems, Gemfile add
gem "thin", "~> 1.7.2"
1
2
3
4
5
6bundle install --without development test
bundle exec rake generate_secret_token
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake tmp:cache:clear RAILS_ENV=production
chown -R www-data.www-data *
/etc/init.d/thin start
Migrate Gitlab
install dependency package
install nodejs
1
2
3
4
5cd ~
curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt install nodejs
node -vinstall yarn
1
2
3
4
5curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt update
apt install yarn
yarn -vinstall go
1
2apt install golang
go versioninstall others
1
2apt install graphicsmagick
apt install postfix
Upgrade System
- upgrade Gitlab
1
2
3
4
5
6su git -l
cd ~/gitlab
git fetch --all --prune
git checkout -- db/schema.rb
git checkout -- locale
git checkout 11-8-stable - upgrade gitlab-shell
1
2
3
4cd ~/gitlab-shell
git fetch --all --tags --prune
git checkout v$(</home/git/gitlab/GITLAB_SHELL_VERSION)
bin/compile - upgrade gitlab-workhorse
1
2
3
4cd ~/gitlab-workhorse
git fetch --all --tags --prune
git checkout v$(</home/git/gitlab/GITLAB_WORKHORSE_VERSION)
make - upgrade Gitaly
1
2
3
4
5sed -i.pre-10.1 's/\[\[storages\]\]/[[storage]]/' /home/git/gitaly/config.toml
cd ~/gitaly
git fetch --all --tags --prune
git checkout v$(</home/git/gitlab/GITALY_SERVER_VERSION)
make - upgrade gitlab-pages
1
2
3
4cd ~/gitlab-pages
git fetch --all --tags --prune
git checkout v$(</home/git/gitlab/GITLAB_PAGES_VERSION)
make
- upgrade Gitlab
Update config
- update gitlab.yml
1
git diff origin/11-7-stable:config/gitlab.yml.example origin/11-8-stable:config/gitlab.yml.example
- update script
1
2
3
4
5cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
update-rc.d gitlab defaults 21
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
systemctl daemon-reload
- update gitlab.yml
start migration
1
2
3
4
5
6
7
8su git -l
cd /home/git/gitlab
bundle install --deployment --without development test postgres aws kerberos
bundle clean
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake gettext:compile RAILS_ENV=production
bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile RAILS_ENV=production NODE_ENV=production
bundle exec rake cache:clear RAILS_ENV=productionstart checking
1
2
3
4
5service gitlab start
service nginx restart
cd /home/git/gitlab
bundle exec rake gitlab:env:info RAILS_ENV=production
bundle exec rake gitlab:check RAILS_ENV=productionadditional
- fix
gnutls_handshake error
with git1
2
3
4
5
6
7
8
9
10apt install build-essential fakeroot dpkg-dev libcurl4-openssl-dev
apt build-dep git
mkdir ~/git-openssl
cd ~/git-openssl
apt source git
dpkg-source -x git_2.17.1-1.dsc
cd git-2.17.1
vi debian/control //replace libcurl4-gnutls-dev with libcurl4-openssl-dev
dpkg-buildpackage -rfakeroot -b //if fail on test, comment TEST=test in debian/rules
dpkg -i ../git_2.17.1-1ubuntu0.4_amd64.deb - fix
JavaScript heap out of memory
with nodejs1
node --max-old-space-size=4096 /home/git/gitlab/config/webpack.config.js
- fix Rails conflict of Redmine and Gitlab
rvm use 2.5.3 --default
vi /usr/local/rvm/bin/bootup_thin
1
2
3
4
5
6
7
8
9
10
11
if
[[ -s "/usr/local/rvm/gems/ruby-2.6.0/environment" ]]
then
source "/usr/local/rvm/gems/ruby-2.6.0/environment"
exec thin "$@"
else
echo "ERROR: Missing RVM environment file: '/usr/local/rvm/gems/ruby-2.6.0/environment'" >&2
exit 1
fivi /etc/init.d/thin
1
2
3
4...
#DAEMON=/usr/local/rvm/gems/ruby-2.6.0@rails522/bin/thin
DAEMON=/usr/local/rvm/bin/bootup_thin
...
- fix
Comments