Monday, February 6
Shadow

How to set up Confluence with MySQL database. Part 1

Part 1 of 2

Confluence supports most of the databases. In this post, we will set up confluence with MySQL database in a Linux environment. I am using ubuntu 20.04 OS.

In the first step, we will install the MySQL database.
apt install mysql-server and press y.

[email protected]:~# apt install mysql-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libmecab2 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils
mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
Suggested packages:
libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx tinyca
The following NEW packages will be installed:
libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-perl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libmecab2 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils
mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server mysql-server-8.0 mysql-server-core-8.0
0 upgraded, 25 newly installed, 0 to remove and 46 not upgraded.
Need to get 36.7 MB of archives.
After this operation, 319 MB of additional disk space will be used.
Do you want to continue? [Y/n]

The database is successfully installed. now, we need to enable MySQL service on the startup, start the service and check the status.
1- systemctl enable mysql
2- systemctl start mysql
3- systemctl status mysql

[email protected]:~# systemctl enable mysql
Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mysql
[email protected]:~# systemctl start mysql
[email protected]:~# systemctl status mysql
● mysql.service – MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-11-30 07:25:59 UTC; 1min 12s ago
Main PID: 3001 (mysqld)
Status: “Server is operational”
Tasks: 39 (limit: 4594)
Memory: 365.3M
CGroup: /system.slice/mysql.service
└─3001 /usr/sbin/mysqld

Nov 30 07:25:56 conf systemd[1]: Starting MySQL Community Server…
Nov 30 07:25:59 conf systemd[1]: Started MySQL Community Server.
[email protected]:~#

so, MySQL is enabled to auto-start. service is started and the status is running.
In the next step, we will create a user, and database and grant permission on the database to the created user for confluence setup.

[email protected]:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.31-0ubuntu0.20.04.2 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> create user ‘confluence’@’localhost’ identified by ‘badminpassword’;
Query OK, 0 rows affected (0.11 sec)

mysql> create database confluence character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.11 sec)

mysql> grant all privileges on confluence.* to ‘confluence’@’localhost’;
Query OK, 0 rows affected (0.08 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)

mysql>

In the above screen, we created the confluence user with badminpassword password. confluence database is created with utf8mb4 character and utf8mb4_bin collate. granted all the privileges on the confluence database to the confluence user and applied the changes of permission with the flush privileges command.

Let’s check the database and the user is created and given permission is working fine. Exit from MySQL and log in using confluence credentials. And display the database.

[email protected]:~# mysql -u confluence -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.31-0ubuntu0.20.04.2 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;
+——————–+
| Database |
+——————–+
| confluence |
| information_schema |
| performance_schema |
+——————–+
3 rows in set (0.01 sec)

mysql>

The database is created and permission is working correctly.

We need to add some parameters or variables into the mysqld.cnf file.

[email protected]:~# nano /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_bin
default-storage-engine=INNODB
max_allowed_packet=256M
innodb_log_file_size=2GB
transaction-isolation=READ-COMMITTED
binlog_format=row
log_bin_trust_function_creators = 1

Before jumping to installing and configuring the confluence, we need to install JDK and set up the JAVA_HONE environment variable. Run the apt install openjdk-8-jdk command and press y.

[email protected]:~# apt install openjdk-8-jdk
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
adwaita-icon-theme at-spi2-core ca-certificates-java fontconfig fontconfig-config fonts-dejavu-core
………………………………………………………………………………….
…………………………………………………………………………………..
0 upgraded, 126 newly installed, 0 to remove and 46 not upgraded.
Need to get 96.1 MB of archives.
After this operation, 757 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Check the java version and localtion.

[email protected]:~# java -version
openjdk version “1.8.0_352”
OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~20.04-b08)
OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)
[email protected]:~# update-alternatives –list java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

java version is 1.8.0_352 and location is /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java.
Now, need to update-alternatives to the java location and set java home.

[email protected]:~# update-alternatives –set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
[email protected]:~# echo $JAVA_HOME

[email protected]:~#

Still java home is blank. There should be a location of the java. Let,s create a java home file and set it to permanent.

[email protected]:~# touch /etc/profile.d/jdk_home.sh
[email protected]:~# nano /etc/profile.d/jdk_home.sh

using touch command jdk_home.sh file is created, using the nano editor below values are inserted in the jdk_home.sh file.
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin

Exit from the nano editor and reboot the system. Run the cat command to verify the changes. and echo $JAVA_HOME to check or verify the java environment is configured permanently.

[email protected]:~# cat /etc/profile.d/jdk_home.sh
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
[email protected]:~#echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
[email protected]:~#

java home is configured successfully. Now, we will download, install and configure the confluence.
you can download confluence from the link below.

https://product-downloads.atlassian.com/software/confluence/downloads/atlassian-confluence-7.19.3.tar.gz

After finishing the download we need to extract the files.

[email protected]:~# tar -xzf atlassian-confluence-7.19.3.tar.gz
[email protected]:~# ls
atlassian-confluence-7.19.3 atlassian-confluence-7.19.3.tar.gz snap
[email protected]:~#

we need to move the confluence extracted file to another directory. lets, ‘s make a confluence and confluence-home directory.

[email protected]:~# mkdir /opt/confluence
[email protected]:~# mkdir /opt/confluence-home
[email protected]:~#

Remove the Atlassian .tar.gz file, move all the extracted files to the /opt/confluence directory and verify that all files are moved to the targeted directory.

[email protected]:~# rm -rf atlassian-confluence-7.19.3.tar.gz
[email protected]:~# mv atlassian-confluence-7.19.3/* /opt/confluence
[email protected]:~# ls /opt/confluence
bin conf CONTRIBUTING.md LICENSE logs README.html README.txt RUNNING.txt temp work
BUILDING.txt confluence lib licenses NOTICE README.md RELEASE-NOTES synchrony-proxy webapps
[email protected]:~#

All the files are successfully moved to the /opt/confluence directory.

Please continue to part 2.

Leave a Reply

Your email address will not be published. Required fields are marked *