Am at day 3 of trying to solve this. I have a working MySql that comes up at boot via the rc.d mysql-server. That server, with the help of a lot of software and some special files in /usr/local/etc/rc.d runs with all files in a ram disk to avoid burning up SSD writes in an edge server processing IoT information. Yes, this is a bit unusual, took a while to get it working.
I now want to bring up a second instance of MySql that runs with the data directory in SSD at /var/db/mysqlSSD. I've copied the original /usr/local/etc/rc.d/mysql-server to /usr/local/etc/rc.d/mysqlssd-server and changed what I believe were the correct fields. I also copied /usr/local/etc/mysql/my.cnf to /usr/local/etc/mysql/myssd.cnf and changed what I thought were the correct fields.
When I try to
/usr/local/etc/rc.d/mysqlssd-server: WARNING: failed precmd routine for mysqlssd
mysql Ver 8.0.25 for FreeBSD12.2 on amd64 (Source distribution)
FreeBsd 12.2-RELEASE-p6
Here is my mysqlssd-server deprived from the mysql-server file. I have some hard-coded values at the top, and a debug print to compare the parameters passed to /usr/local/libexec/mysqld, but it is derived from what works already for the mysql sever that is up and running with no problems.
The /usr/local/etc/mysql/myssd.cnf looks like this. I realize many of the fields are not pertinent to my problem, but, do not want to risk removing something that was relevant by mistake. Note also that on this system, /tmp is also a ram disk.
Is the process of creating a second running MySql server indeed possible by this approach? There does not seem to be much out there on how to do this, and what I have done was what I found in the
I now want to bring up a second instance of MySql that runs with the data directory in SSD at /var/db/mysqlSSD. I've copied the original /usr/local/etc/rc.d/mysql-server to /usr/local/etc/rc.d/mysqlssd-server and changed what I believe were the correct fields. I also copied /usr/local/etc/mysql/my.cnf to /usr/local/etc/mysql/myssd.cnf and changed what I thought were the correct fields.
When I try to
service mysqlssd-server start
I see:/usr/local/etc/rc.d/mysqlssd-server: WARNING: failed precmd routine for mysqlssd
mysql Ver 8.0.25 for FreeBSD12.2 on amd64 (Source distribution)
FreeBsd 12.2-RELEASE-p6
Here is my mysqlssd-server deprived from the mysql-server file. I have some hard-coded values at the top, and a debug print to compare the parameters passed to /usr/local/libexec/mysqld, but it is derived from what works already for the mysql sever that is up and running with no problems.
Code:
#!/bin/sh
# PROVIDE: mysqlssd
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable mysql:
# mysql_enable (bool): Set to "NO" by default
# Set it to "YES" to enable MySQL.
# mysql_dbdir (str): Default to "/var/db/mysql"
# Base database directory.
# mysql_confdir (str): Default to "/usr/local/etc/mysql"
# Base configuration directory.
# mysql_optfile (str): Server-specific option file.
# Set it in the rc.conf or default behaviour of
# `mysqld_safe` itself, will be picking
# ${mysql_confdir}/my.cnf if it exists.
# mysql_pidfile (str): Custum PID file path and name.
# Default to "${mysql_dbdir}/${hostname}.pid".
# mysql_args (str): Custom additional arguments to be passed
# to mysqld_safe (default empty).
#
. /etc/rc.subr
name="mysqlssd"
rcvar=mysqlssd_enable
# Added these to force database directory and config file location. Config file is called myssd.cnf
mysql_dbdir="/var/db/mysqlSSD"
mysql_confdir="/usr/local/etc/mysql"
mysql_cnf="myssd.cnf"
mysql_optfile="${mysql_confdir}/${mysql_cnf}"
# try to force the socket and port number when creating the auth tables.
mysql_extra="--socket=/tmp/mysqlssd.sock --port=3311"
load_rc_config $name
: ${mysqlssd_enable="NO"}
: ${mysql_dbdir="/var/db/mysqlSSD"}
: ${mysql_confdir"/usr/local/etc/mysql"}
if [ -f "${mysql_confdir}/${mysql_cnf}" ]; then
: ${mysql_optfile="${mysql_confdir}/${mysql_cnf}"}
elif [ -f "${mysql_dbdir}/${mysql_cnf}" ]; then
: ${mysql_optfile="${mysql_dbdir}/${mysql_cnf}"}
fi
if [ ! -z "${mysql_optfile}" ]; then
mysql_extra="--defaults-extra-file=${mysql_optfile}"
fi
mysql_user="mysql"
: ${hostname:=`/bin/hostname`}
pidfile=${mysql_pidfile:-"${mysql_dbdir}/${hostname}.pid"}
command="/usr/sbin/daemon"
command_args="-c -f /usr/local/bin/mysqld_safe ${mysql_extra} --basedir=/usr/local --datadir=${mysql_dbdir} --pid-file=${pidfile} --user=${mysql_user} ${mysql_args} "
procname="/usr/local/libexec/mysqld"
start_precmd="${name}_prestart"
start_postcmd="${name}_poststart"
mysqld_init="${procname}"
mysqld_init_args="${mysql_extra} --initialize-insecure --basedir=/usr/local --datadir=${mysql_dbdir} --user=${mysql_user}"
mysqlssd_create_auth_tables()
{
# Debug print to see make sure the variables passed are OK
echo "eval ${mysqld_init} ${mysqld_init_args}"
eval $mysqld_init $mysqld_init_args >/dev/null 2>/dev/null
}
mysqlssd_prestart()
{
if [ ! -d "${mysql_dbdir}/mysqlSSD/." ]; then
mysqlssd_create_auth_tables || return 1
fi
return 0
}
mysqlssd_poststart()
{
local timeout=15
while [ ! -f "${pidfile}" -a ${timeout} -gt 0 ]; do
timeout=$(( timeout - 1 ))
sleep 1
done
return 0
}
run_rc_command "$1"
The /usr/local/etc/mysql/myssd.cnf looks like this. I realize many of the fields are not pertinent to my problem, but, do not want to risk removing something that was relevant by mistake. Note also that on this system, /tmp is also a ram disk.
Code:
# $FreeBSD: branches/2020Q2/databases/mysql80-server/files/my.cnf.sample.in 469734 2018-05-12 15:35:25Z mmokhi $
[client]
port = 3311
socket = /tmp/mysqlssd.sock
[mysql]
prompt = \u@\h [\d]>\_
no_auto_rehash
[mysqld]
user = mysql
port = 3311
socket = /tmp/mysqlssd.sock
bind-address = 127.0.0.1
basedir = /usr/local
datadir = /var/db/mysqlSSD
tmpdir = /tmp/mysqlSSD_tmpdir:/var/db/mysqlSSD_tmpdir
slave-load-tmpdir = /tmp/mysqlSSD_tmpdir:/var/db/mysqlSSD_tmpdir
secure-file-priv = /var/db/mysqlSSD_secure
log-bin = /tmp/mysqlSSD-bin
pid-file = /var/db/mysqlSSD/abcde.org.pid
plugin-dir = /usr/local/lib/mysql/plugin
log-error = /var/db/mysqlSSD/abcde.org.err
log-output = TABLE
relay-log-recovery = 1
slow-query-log = 1
server-id = 1
sync_binlog = 1
sync_relay_log = 1
binlog_cache_size = 16M
binlog_expire_logs_seconds =86400
default_password_lifetime = 0
enforce-gtid-consistency = 1
gtid-mode = ON
safe-user-create = 1
lower_case_table_names = 1
explicit-defaults-for-timestamp = 1
myisam-recover-options = BACKUP,FORCE
open_files_limit = 32768
table_open_cache = 16384
table_definition_cache = 8192
net_retry_count = 16384
key_buffer_size = 256M
max_allowed_packet = 64M
long_query_time = 0.8
innodb_buffer_pool_size = 1G
innodb_data_home_dir = /var/db/mysqlSSD
innodb_log_group_home_dir = /var/db/mysqlSSD
innodb_data_file_path = ibdata1:128M:autoextend
innodb_temp_data_file_path = ibtmp1:128M:autoextend
innodb_flush_log_at_timeout =4
innodb_flush_log_at_trx_commit =2
innodb_flush_method = O_DIRECT
innodb_log_file_size = 256M
innodb_log_buffer_size = 16M
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_autoinc_lock_mode = 2
[mysqldump]
max_allowed_packet = 256M
quote_names
quick
Is the process of creating a second running MySql server indeed possible by this approach? There does not seem to be much out there on how to do this, and what I have done was what I found in the