BigW Consortium Gitlab

7.3-to-7.4.md 6.47 KB
Newer Older
Ben Bodenmiller committed
1
# From 7.3 to 7.4
2
*Make sure you view this [upgrade guide from the `master` branch](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/update/7.3-to-7.4.md) for the most up to date instructions.*
Ben Bodenmiller committed
3

4
### 0. Stop server
Ben Bodenmiller committed
5

6
    sudo service gitlab stop
Valery Sizov committed
7

8
### 1. Backup
Valery Sizov committed
9 10

```bash
11 12
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
13
```
Valery Sizov committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

### 2. Get latest code

```bash
sudo -u git -H git fetch --all
sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically
```

For GitLab Community Edition:

```bash
sudo -u git -H git checkout 7-4-stable
```

OR

For GitLab Enterprise Edition:

```bash
sudo -u git -H git checkout 7-4-stable-ee
```

### 3. Install libs, migrations, etc.

```bash
# MySQL installations (note: the line below states '--without ... postgres')
sudo -u git -H bundle install --without development test postgres --deployment

# PostgreSQL installations (note: the line below states '--without ... mysql')
sudo -u git -H bundle install --without development test mysql --deployment

# Run database migrations
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production

# Clean up assets and cache
sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production

# Update init.d script
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
```

55
### 4. Update config files
Valery Sizov committed
56 57 58 59

#### New configuration options for gitlab.yml

There are new configuration options available for gitlab.yml. View them with the command below and apply them to your current gitlab.yml.
Ben Bodenmiller committed
60

Valery Sizov committed
61 62 63 64 65 66 67
```
git diff origin/7-3-stable:config/gitlab.yml.example origin/7-4-stable:config/gitlab.yml.example
```

#### Change timeout for unicorn

```
68 69
# set timeout to 60
sudo -u git -H editor config/unicorn.rb
Valery Sizov committed
70 71
```

72
#### Change Nginx HTTPS settings
Valery Sizov committed
73

74
* HTTPS setups: Make `/etc/nginx/sites-available/gitlab-ssl` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/lib/support/nginx/gitlab-ssl but with your setting
Valery Sizov committed
75

76
#### MySQL Databases: Update database.yml config file
Ben Bodenmiller committed
77

78
* Add `collation: utf8_general_ci` to `config/database.yml` as seen in [config/database.yml.mysql][mysql]:
Ben Bodenmiller committed
79

80 81 82
```
sudo -u git -H editor config/database.yml
```
Valery Sizov committed
83

84
### 5. Start application
Valery Sizov committed
85 86 87 88

    sudo service gitlab start
    sudo service nginx restart

89
### 6. Check application status
Valery Sizov committed
90 91 92 93 94 95 96 97 98 99 100 101

Check if GitLab and its environment are configured correctly:

    sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

To make sure you didn't miss anything run a more thorough check with:

    sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

If all items are green, then congratulations upgrade is complete!


102
### 7. Optional optimizations for GitLab setups with MySQL databases
Ben Bodenmiller committed
103

104
Only applies if running MySQL database created with GitLab 6.7 or earlier. If you are not experiencing any issues you may not need the following instructions however following them will bring your database in line with the latest recommended installation configuration and help avoid future issues. Be sure to follow these directions exactly. These directions should be safe for any MySQL instance but to be sure make a current MySQL database backup beforehand.
Ben Bodenmiller committed
105 106

```
107 108 109
# Stop GitLab
sudo service gitlab stop

Ben Bodenmiller committed
110 111 112 113 114 115 116 117 118 119 120
# Secure your MySQL installation (added in GitLab 6.2)
sudo mysql_secure_installation

# Login to MySQL
mysql -u root -p

# do not type the 'mysql>', this is part of the prompt

# Convert all tables to use the InnoDB storage engine (added in GitLab 6.8)
SELECT CONCAT('ALTER TABLE gitlabhq_production.', table_name, ' ENGINE=InnoDB;') AS 'Copy & run these SQL statements:' FROM information_schema.tables WHERE table_schema = 'gitlabhq_production' AND `ENGINE` <> 'InnoDB' AND `TABLE_TYPE` = 'BASE TABLE';

121
# If previous query returned results, copy & run all shown SQL statements
Ben Bodenmiller committed
122

123 124 125 126
# Convert all tables to correct character set
SET foreign_key_checks = 0;
SELECT CONCAT('ALTER TABLE gitlabhq_production.', table_name, ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') AS 'Copy & run these SQL statements:' FROM information_schema.tables WHERE table_schema = 'gitlabhq_production' AND `TABLE_COLLATION` <> 'utf8_unicode_ci' AND `TABLE_TYPE` = 'BASE TABLE';

127
# If previous query returned results, copy & run all shown SQL statements
128 129 130 131

# turn foreign key checks back on
SET foreign_key_checks = 1;

Ben Bodenmiller committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
# Find MySQL users
mysql> SELECT user FROM mysql.user WHERE user LIKE '%git%';

# If git user exists and gitlab user does not exist 
# you are done with the database cleanup tasks
mysql> \q

# If both users exist skip to Delete gitlab user

# Create new user for GitLab (changed in GitLab 6.4)
# change $password in the command below to a real password you pick
mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';

# Grant the git user necessary permissions on the database
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO 'git'@'localhost';

# Delete the old gitlab user
mysql> DELETE FROM mysql.user WHERE user='gitlab';

# Quit the database session
mysql> \q

# Try connecting to the new database with the new user
sudo -u git -H mysql -u git -p -D gitlabhq_production

# Type the password you replaced $password with earlier

# You should now see a 'mysql>' prompt

# Quit the database session
mysql> \q

# Update database configuration details
# See config/database.yml.mysql for latest recommended configuration details
#   Remove the reaping_frequency setting line if it exists (removed in GitLab 6.8)
167
#   Set production -> pool: 10 (updated in GitLab 5.3)
Ben Bodenmiller committed
168 169 170
#   Set production -> username: git
#   Set production -> password: the password your replaced $password with earlier
sudo -u git -H editor /home/git/gitlab/config/database.yml
171

172 173 174 175
# Start GitLab
sudo service gitlab start
sudo service nginx restart

176 177
# Run thorough check
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
178
```
Valery Sizov committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194


## Things went south? Revert to previous version (7.3)

### 1. Revert the code to the previous version
Follow the [upgrade guide from 7.2 to 7.3](7.2-to-7.3.md), except for the database migration
(The backup is already migrated to the previous version)

### 2. Restore from the backup:

```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
```
If you have more than one backup *.tar file(s) please add `BACKUP=timestamp_of_backup` to the command above.

195 196
[yaml]: https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/config/gitlab.yml.example
[mysql]: https://gitlab.com/gitlab-org/gitlab-ce/blob/7-4-stable/config/database.yml.mysql