SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2
Posted by Administrator | 27/01/2025 | Thủ thuật
SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 In my previous article, I
For this implementation, I am using a Linux server with Ubuntu distribution version 22.04.
The server I used has the following configuration: 2 vCPUs, 4GB RAM and a 30GB SSD disk.
For our server to be accessible via the internet, and for our GitLab to generate the certificate via Let’s Encrypt, we need to have a public IP address and we need to open ports 80 and 443 to the internet.
We also need to have a DNS record to create the URL for GitLab.
I have made Docker Compose available in the following GitHub repository:
Structure:
.
└── docker-compose.yml
I will not cover the installation of Docker Engine, if you still do not know how to install it, see this other post:
First of all, let’s define and create the URL that we will use for GitLab.
I will use the domain alfredocastro.com.br, I defined the URL gitlab.alfredocastro.com.br – ATTENTION: You need to change it in the Docker Compose file (docker-compose.yml).
Access your domain’s DNS record manager and create an A record using your server’s public IP address as the value.
Here’s an example:
To check the propagation of the created record, visit the website: WhatsMyDNS
After installing Docker Engine, let’s continue with our implementation.
Run the following commands to clone our Docker Compose into our server:
cd /opt
git clone https://github.com/alfredotavio/gitlab-docker.git
cd gitlab-docker
NOTE: I used the Linux /opt directory, if you want you can change it to another directory of your choice.
First let’s define the access URL, edit the docker-compose.yml file in the project root and change the GitLab URL, there are two lines, in the current project it is set to gitlab.example.com.
vim /opt/gitlab-docker/docker-compose.yml
To upload our environment, simply run the following command within the root directory where our docker-compose.yml is located:
docker compose up -d
NOTE: Docker will download and provision all images. Wait a few minutes for the images to complete the first-time setup.
By default, GitLab automatically sets a temporary password found inside the “initial_root_password” file. To get the password, use the following command:
docker exec -it gitlab grep "Password:" /etc/gitlab/initial_root_password
Access the GitLab URL that we defined in the first step, you will be asked for a username and password to access, by default the user is “root” and the password will be the one displayed in the previous command.
After performing the first login, it is recommended to change the password and email of the “root” user, it is also recommended to disable the public registration option.
To change the password and email of the “root” user, after logging in, click on the user’s profile picture in the left side tab.
Then click on “Edit profile”.
In the “Profile” tab, scroll down to the “Email” field and change the email “ admin@example.com ” to your email address, then click “Update profile settings”.
You will be asked to confirm the “root” user password, use the temporary password we got earlier.
Now click on the “Password” tab in the left side menu.
In “Current password”, enter the temporary password we got earlier, in “New password” define a new password and in “Password confirmation” repeat the new password, then click on “Save password”.
You will be logged out and a message will appear saying that the password was updated successfully.
Log in again, now using the new password. Let’s disable the public registration option. After logging in, a warning message will be displayed: “Check your sign-up restrictions – Your GitLab instance allows anyone to register for an account, which is a security risk on public-facing GitLab instances. You should deactivate new sign ups if public users aren’t expected to register for an account.” Click the “Deactivate” button.
Uncheck the “Sign-up enabled” option and click the “Save changes” button.
Okay, now we have launched GitLab and made the first security configurations.
To integrate GitLab Runner with GitLab, you must generate a token and register within GitLab Runner.
To generate the token you need to access the “Admin Area”, on the home screen after logging in, click on the “Configure GitLab” box.
In the left side menu, click on “CI/CD” and then on “Runners”.
Click on the “New instance runner” button.
Make the following settings:
In “Platform” select “Linux”.
Under “Tags” check the box “Run untagged jobs”.
Click on the “Create runner” button.
Copy and write down the command displayed in “Step 1” and click the “Go to runners page” button.
See that our Runner is in “Idle” status and the last interaction is “Never”.
Now we must access the terminal where our Docker Compose is located to run the GitLab Runner registration command. Access your Linux instance and type the following command to register the GitLab Runner within your GitLab, remember to change the “–url” and “–token” fields to the information corresponding to your previously generated Runner.
docker exec -it gitlab-runner gitlab-runner register --name MyRunner --url "https://gitlab.alfredocastro.com.br" --token "glrt-FyeL9ZZz6QozSD2aJE3x" --executor docker --docker-image "docker:latest" --non-interactive
The execution should return a message similar to the following print “Runner registered successfully”.
Go back to the browser with the Runners and refresh the page to see the status of our Runner, see in the print that it has the status “Online” and already has the time of the last interaction.
Okay, we’ve now uploaded our environment with GitLab and GitLab Runner integrated.
I hope I’ve helped! If you have any questions, don’t hesitate to contact me.
Liên hệ ngay với OceanTech-Group để thiết kế hệ thống trơn chu chuẩn bảo mật cho doanh nghiệp của bạn!