Currently Viewing Posts in L.A.M.P.

Migrating GitLab to another Server from Ubuntu 16.04 to Ubuntu 18.04

Because my old Gitlab is running on a Ubuntu 16.04 server. The latest LTS version of Ubuntu is already 18.04 for more than one year. I was thinking about to directly upgrade the server from 16.04 to 18.04.  There are still some chances it may fail and the server may crash. I can not afford to lose the data.

So the final decision is to migrate the Gitlab from the old server Ubuntu 16.04 to a new server with  Ubuntu 18.04.

This is how to do it.

First, I install the new server on my Proxmox VE environment with Ubuntu 18.04. 3CPU Cores and 4GB memory and 64GB storage. Meanwhile, the old server still uses Ubuntu 16.04. And the Gitlab version that I use is 12.4.2

On the Old Server

  1.  Shutdown Gitlab service
    sudo gitlab-ctl stop unicorn
    sudo gitlab-ctl stop sidekiq
  2. Backup Gitlab on the old server
    sudo gitlab-rake gitlab:bakcup:create
  3. Create a folder named gitlab-old
    mkdir ~/gitlab-old
  4. Copy the backup file to the folder ~/gitlab-old
    sudo cp ~/backups/xxxxxxxx_gitlab_backup.tar ~/gitlab-old
  5. Copy the Gitlab configuration files
    sudo cp /etc/gitlab/gitlab.rb ~/gitlab-old
    sudo cp /etc/gitlab/gitlab-secrets.json ~/gitlab-old
    sudo cp -R /etc/gitlab/ssl ~/gitlab-old

Then all the important files are under folder ~/gitlab-old

My configuration of Gitlab changed the backup folder to ~/backups. The default path is /var/opt/gitlab/backups/

You can change it on the “Backup Settings” section in the file gitlab.rb

 

To verify the version of your gitlab installation, enter the following command.

sudo gitlab-rake gitlab:env:info

On the New Server

The server is a clean installation of Ubuntu 18.04. The only service is SSH  and postfix.

Before doing the migration, I transfer the whole folder ~/gitlab-old from the old server to this new server.

  1.  Add Gitlab source
    curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
  2.  Install Gitlab 12.4.2 CE
    sudo apt update
    sudo apt install gitlab-ce=12.4.2
  3. Copy the configuration files to folder /etc/gitlab
    sudo cp ~/gitlab-old/gitlab* /etc/gitlab
  4. Copy the ssl folder to folder /etc/gitlab
    sudo cp -R ~/gitlab-old/ssl /etc/gitlab
  5. Run Gitlab service for the first time
    sudo gitlab-ctl reconfigure
  6. Shutdown the Gitlab services
    sudo gitlab-ctl stop unicorn
    sudo gitlab-ctl stop sidekiq
  7. Copy the backup file to ~/backups then change the permission
    sudo cp ~/gitlab-old/*.tar ~/backups
    sudo chown git:root ~/backups/*.tar
  8. Restore the Gitlab backup file
    sudo gitlab-rake gitlab:backup:restore BACKUP=XXXXXX
  9. Restart Gitlab and check
    sudo gitlab-ctl start
    sudo gitlab-rake gitlab:check SANITIZE=true

There are some notes for the above nine steps.

The backup file name looks like 1573175514_2019_11_07_12.4.2_gitlab_backup.tar. So the code in the step 8, BACKUP=1573175514_2019_11_07_12.4.2

The version of Gitlab I am using 12.4.2. I install the 12.4.2 on step 2. When I do the restore in step 8, it displays the error, the version does not match. The backup is 12.4.2, but the installation is 12.4.1. I have to do the apt update and apt upgrade to upgrade the Gitlab from 12.4.1 to 12.4.2. I am not sure where the problem came from. Just a reminder, double-check the version installed on the new server.

At the first step of adding the repo source, I always get the network error on my server. I believed it is the problem of guest OS on Proxmox VE. So I actually add the repo source and public key of gitlab source manually.

My current Gitlab information on the new server Ubuntu 18.04

davidyin@gitlab:~$ sudo gitlab-rake gitlab:env:info

System information
System: Ubuntu 18.04
Current User: git
Using RVM: no
Ruby Version: 2.6.3p62
Gem Version: 2.7.9
Bundler Version:1.17.3
Rake Version: 12.3.3
Redis Version: 3.2.12
Git Version: 2.22.0
Sidekiq Version:5.2.7
Go Version: unknown

GitLab information
Version: 12.4.2
Revision: 393a5bdafa2
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 10.9
URL: https://gitlab.g2soft.net
HTTP Clone URL: https://gitlab.g2soft.net/some-group/some-project.git
SSH Clone URL: git@gitlab.g2soft.net:some-group/some-project.git
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version: 10.2.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git

At the end, I should give the credit to Didiet A. Pambudiono. Most of the steps above is based on this post.

php script timeout on php7.2-fpm and Nginx Webserver

Here is the background.

  • It is a php script that is accessed through a browser.
  • Server: Ubuntu 18.04
  • Web server: Nginx 1.14
  • php: php7.2-fpm

 

The script always stoped on 60 seconds.

The Nginx error log is shown below:

2019/10/23 14:05:18 [error] 996#996: *950 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 135.0.172.188, server: fctu.win, request: “GET /go/do-something.php HTTP/2.0”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock”, host: “mywebsite.com”

It is a timeout.  I knew it.

In the beginning, I am looking for the php timeout settings.

I tried to add max_execution_time to 360. It doesn’t help.

At last, I add a line into Nginx settings.

fastcgi_read_timeout 180;

Sample code below:

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php7.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_read_timeout 180;
    include fastcgi_params;
} 

 

Force IPv4 when using APT command in Ubuntu

Sometimes you may want to disable IPv6 when using apt update command or some other apt operation.

If you want to use IPv4 in one command, just run following:

$ sudo apt -o Acquire::ForceIPv4=true update

If you want to force to use IPv4 for all apt operations, add a new file under /etc/apt/apt.conf.d/

$ sudo nano /etc/apt/apt.conf.d/99force-ipv4

Then add a line:

Acquire::ForceIPv4 "true";

If you want to disable IPv4, change the IPv4 to IPv6.

Nginx : Unit nginx.service is masked

Complied a Nginx server to the latest version and also add Brotli support, but get the following error message:

$ sudo service nginx status
* nginx.service
   Loaded: masked (/dev/null; bad)
   Active: inactive (dead)

$ sudo service nginx restart
Failed to restart nginx.service: Unit nginx.service is masked.

Solution

To fix the problem, or error, just unmask with the command:

$ sudo systemctl unmask nginx.service

 

How to upgrade Proxmox Virtual Environment 5.4.x

I am using a Proxmox VE for a while. It is almost one month I start to use Proxmox VE 5.3-8.

I noticed that Proxmox VE has newer version released. Now it is v5.4-4.

I have not subscribe the license of PVE.

 

Here is a simple guide to show you how to upgrade Proxmox VE 5.3x to v5.4x

1) Edit /etc/apt/sources.list.d/pve-enterprise.list

Comment or delete the following line.

deb https://enterprise.proxmox.com/debian/pve stretch pve-enterprise

2) Edit /etc/apt/sources.list

Add following line at the end of the file.

deb http://download.proxmox.com/debian stretch pve-no-subscription

3) Now, it is OK to do the update.

apt update

apt upgrade

apt dist-upgrade

 

Continue reading “How to upgrade Proxmox Virtual Environment 5.4.x”

Hot to fix the problem on the new installation MariaDB

After the installation of MySQL server or MariaDB on Ubuntu, I would like to use phpMyAdmin or Adminer to access the MySQL server. But the first time the error comes like below.

Access denied for user ‘root’@’localhost’

mysqli_real_connect(): (HY000/1698): Access denied for user ‘root’@’localhost’

MySQL connect error on phpMyAdmin

 

MySQL connect error on Adminer

Here is the solution to make the root connect to a server without error.

Continue reading “Hot to fix the problem on the new installation MariaDB”

How to enable the VM auto-boot in Proxmox VE

After the setup of my first Proxmox VE, I need to shutdown and startup your Proxmox hardware node. There are many reasons for this such as adding new hardware or to apply new kernel updates.

Before shutting down the Host machine, I have to shutdown the LXC container and all VMs.

When I start the Proxmox VE host node, the VM will not start up automatically. I will do it manually.

Here is the way to make the VMs auto-start with the HOST.

Datacenter > Virtual Machine > 109 (example.com) > Options > Start at boot

Double click the “Start at boot”, select the check box and OK.

Start at boot, options of Virtual Machine in Proxmox VE

Continue reading “How to enable the VM auto-boot in Proxmox VE”

  • Archives