SQL database

You really should use a PostgreSQL database, as explained in Chapter 1, Introducing the GitLab Architecture. For MySQL (a different SQL database), check the MySQL setup guide.

Install the database packages using the following command:

$ sudo apt-get install -y postgresql postgresql-client libpq-dev postgresql-contrib

Setting up postgresql (9.6+181+deb9u2) ...
Setting up postgresql-client (9.6+181+deb9u2) ...
Setting up postgresql-contrib-9.6 (9.6.10-0+deb9u1) ...
Setting up postgresql-contrib (9.6+181+deb9u2) ...
Processing triggers for systemd (232-25+deb9u4) ...
Processing triggers for libc-bin (2.24-11+deb9u3) ...

Start the Database Engine:

$ sudo service postgresql start

Create a database user for GitLab:

$ sudo -u postgres psql -d template1 -c "CREATE USER git CREATEDB;"
CREATE ROLE

Create the pg_trgm extension (required for GitLab 8.6+):

$ sudo -u postgres psql -d template1 -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
CREATE EXTENSION

Create the GitLab production database and grant all privileges on the database:

$ sudo -u postgres psql -d template1 -c "CREATE DATABASE gitlabhq_production OWNER git;"
CREATE DATABASE

Try connecting to the new database with the new user:

$ sudo -u git -H psql -d gitlabhq_production
Postgresql (9.4.22) Type “help” for help.
gitlabhq_production=>

Check whether the pg_trgm extension is enabled by pasting or typing this in the database console:

 SELECT true AS enabled
FROM pg_available_extensions
WHERE name = 'pg_trgm'
AND installed_version IS NOT NULL;

If the extension is enabled, this will produce the following output:

enabled
-------
t

(1 row)

Now, we set the database password:

gitlabhq_production=> password git
Enter new password: <type a password>
Enter it again: <type again this password>
gitlabhq_production=> q

Quit the database console with q. Save this password for later use for yourself when you configure the GitLab installation.

Create an entry in the PostgreSQL main configuration file:

$ vi /etc/postgresql/9.6/main/postgresql.conf

Change the listen address to *, or change the IP if it now says localhost and uncomment:

listen_addresses = '*'

Create an entry in the PostgreSQL host file:

$ sudo vi /etc/postgresql/9.6/main/pg_hba.conf

Add a line such as this:

host gitlabhq_production git <ip of gitlab server>/32 md5

After saving the host file, restart the database instance for the settings to take effect:

$ sudo service postgresql restart

The database is now ready for GitLab.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.15.94