How to install Seafile in a TrueNAS (12.0) jail

NinthWave

Contributor
Joined
Jan 9, 2021
Messages
129
A few months ago, I succesffully installed Seafile in a jail but as a total FreeBSD noob, the sqlite database lies within the same jail as the Seafile serve which means I have to backup the whole jail on Backblaze, which I dont find elegant anymore.

For a few days now and wihout any success, I have been trying to just install Seafile again and mounting a dataset.
I used this: https://www.truenas.com/community/threads/how-to-install-seafile-in-a-freebsd-jail.64121/post-459138
I can't figure out to make it work.


So I'd like to do it the right way: having the datase outside the seafile jail.
There is another post specifically for MariaDB but then again, the guy installed MariaDB in the Seafile jail: https://www.truenas.com/community/threads/how-to-install-seafile-in-a-freebsd-jail.64121/post-560587

Unless I am told that it is an appropriate way to do it (I might use MariaDB for another app in the future), I'd prefer to have in it's own jail.

So what I did yet is:

Installing a MariaDB server in a jail
I followed this: https://www.ricalo.com/blog/mariadb-server-freenas/#
But I also followed this:
@Patrick M. Hausen

The information to create separate datasets for InnoDB tables and logfiles and complicated adjustment of ZFS parameters is according to Allan Jude and others who work on OpenZFS outdated.
Simply putting all of your database file in the same dataset with the default blocksize of 128k will in most cases result in better performance ever since compressed ARC was introduced


Sorry, I dont know how to quote across different threads

Created the ZFS dataset
1. Created the /mnt/Bassin/innodb_data dataset
Code:
zfs create Bassin/innodb_data
zfs set atime=off Bassin/innodb_data
zfs set compression=off Bassin/innodb_data
zfs set primarycache=metadata Bassin/innodb_data
zfs set recordsize=128K Bassin/innodb_data


Created the jail
Code:
iocage create --name mariadb --release 12.2-RELEASE

The IP is 10.0.0.16

Installed the mariadb103-server-10.3.31_1 package
For some reason, mariadb105-server-10.5.12_1 result in the impossibility to start the service so I gave a previous version a try.

Created folders in the jail where you are going to mount the datasets. Assign the mysql user as the owner
Code:
mkdir -p /var/db/mysql/innodb_data
mkdir -p /var/db/mysql/innodb_log
mkdir -p /var/db/mysql/datadir

chown -R mysql:mysql /var/db/mysql/innodb_data
chown -R mysql:mysql /var/db/mysql/innodb_log
chown -R mysql:mysql /var/db/mysql/datadir


Mounted the [|CODE]data[/|CODE] and [|CODE]log[/|CODE] datasets on the corresponfing folder in the jail
I also followed @Patrick M. Hausen comment on the heaviness in separating the datasets and, not certainly knowing if it was the correct way to do it, I mounted the three directories in the sole dataset:
Code:
iocage fstab mariadb --add /mnt/Bassin/innodb_data /var/db/mysql/innodb_data nullfs rw 0 0
iocage fstab mariadb --add /mnt/Bassin/innodb_data /var/db/mysql/innodb_log  nullfs rw 0 0
iocage fstab mariadb --add /mnt/Bassin/innodb_data /var/db/mysql/datadir     nullfs rw 0 


Configure the service
Create the /var/db/mysql/my.cnf file
Code:
[mysqld]
# Uncomment the following line to enable access from remote hosts.
bind-address    = 0.0.0.0
innodb_data_home_dir      = /var/db/mysql/innodb_data
innodb_log_group_home_dir = /var/db/mysql/innodb_log
datadir                   = /var/db/mysql/datadir
skip-innodb_doublewrite


Configure the service startup and start the service
Code:
sysrc mysql_enable=yes
service mysql-server start


Run the script to improve the security of the installation
Code:
mysql_secure_installation

I left the root password empty

Testing the installation

Code:
mysql --user=root

It worked

Installing seafile
This is where I am at now and in need of help.

Installation of Seafile Server Community Edition with MySQL/MariaDB This is meant for a linux install and FreeBSD packages are different so I am not sure if I should follow that.

FreeBSD Install from @Hizar
My problem here is that since @Hizar installed Seafile and MariaDB in the same jail, I am not sure what goes where

Any help would be appreciated
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
There's nothing wrong with bundling the database into the jail and it doesn't exactly cost you a lot to run an instance of your database server in each jail that needs one.

It feels to me like you're complicating your life for no good reason trying to do otherwise.

What you absolutely can/should do is mount /var/db/mysql into the jail from a dedicated dataset in your pool rather than let it be part of the jail filesystem directly, which would mean you could back up the database without needing to capture the entire jail if that's something that bothers you (I guess the jail isn't actually more than a hundred MB anyway, but keeping that data outside the jail is good).
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Mounted the [|CODE]data[/|CODE] and [|CODE]log[/|CODE] datasets on the corresponfing folder in the jail
I also followed @Patrick M. Hausen comment on the heaviness in separating the datasets and, not certainly knowing if it was the correct way to do it, I mounted the three directories in the sole dataset:
Code:
iocage fstab mariadb --add /mnt/Bassin/innodb_data /var/db/mysql/innodb_data nullfs rw 0 0
iocage fstab mariadb --add /mnt/Bassin/innodb_data /var/db/mysql/innodb_log nullfs rw 0 0
iocage fstab mariadb --add /mnt/Bassin/innodb_data /var/db/mysql/datadir nullfs rw 0
You may have just made a copy/paste error here, but those last 3 lines all mount the same dataset in 3 different places... you can't really expect it to work like that if that's actually what you did.
 

NinthWave

Contributor
Joined
Jan 9, 2021
Messages
129
It feels to me like you're complicating your life for no good reason trying to do otherwise.

What you absolutely can/should do is mount /var/db/mysql into the jail from a dedicated dataset in your pool rather than let it be part of the jail filesystem directly, which would mean you could back up the database without needing to capture the entire jail if that's something that bothers you (I guess the jail isn't actually more than a hundred MB anyway, but keeping that data outside the jail is good).
This is what I tried without success. As soon as I mount /var/db/mysql to a data set, the service won't even start.

[EDIT 13h30]
Do I need to mount two directories? I do not fully get how /www and /var are segmented from a file point.

@haziz

The below uses default locations in a FreeNAS jail that I made as a test.. In Production I would use a mount point from a dataset for /var to store my DB backups and another mount for /usr/local/www to keep my files safe.
 
Last edited:

NinthWave

Contributor
Joined
Jan 9, 2021
Messages
129
You may have just made a copy/paste error here, but those last 3 lines all mount the same dataset in 3 different places... you can't really expect it to work like that if that's actually what you did.
Yeah, maybe I just don't fully get the concept of mounting.

Following this post: https://www.truenas.com/community/threads/installing-mariadb-in-jail.92152/post-638666 :
The information to create separate datasets for InnoDB tables and logfiles and complicated adjustment of ZFS parameters is according to Allan Jude and others who work on OpenZFS outdated.
Simply putting all of your database file in the same dataset with the default blocksize of 128k will in most cases result in better performance ever since compressed ARC was introduced.
I mistakenly understood that the 3 different directories where required for MariaDb to work but needed not be mounted to 3 different datasets so I mounted the 3 directories in the same on.
 

NinthWave

Contributor
Joined
Jan 9, 2021
Messages
129
I tried to install mariadb_104 instead of 103 and I get this dreaded message
Code:
root@seafile-server:~ # /usr/local/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)
Enter current password for root (enter for none):
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
This is what I tried without success. As soon as I mount /var/db/mysql to a data set, the service won't even start.
You need (or needed to) mount that storage before installing mariadb.

You can either remove the mount restart the jail, copy the contents to a temp structure in the jail, remount and copy it back... or just reinstall mariadb with the mount in place.

I tried to install mariadb_104 instead of 103 and I get this dreaded message
You need to install a fresh mariadb, so kill the contents of the mounted structure first of you're going to do that.

Do I need to mount two directories? I do not fully get how /www and /var are segmented from a file point.
They are 2 completely different directories... any (empty) directory can be set as the target for a mount, but only one mount can be made to any given directory and you should only really be mounting each dataset from your pool to one location in a jail.
 
Top