我尝试在我的 Debian 8 服务器上使用 Galera 设置 MariaDB 集群。
当我尝试将服务器添加到集群中已存在的服务器时:
systemctl start mysql
我收到此错误:
mariadb.service 的作业失败。请参阅“systemctl status mariadb.service”和“journalctl -xn”了解详情。
我在输出中找到了这一行journalctl -xn
:
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [ERROR] /usr/sbin/mysqld: unknown option '--.'
于是我/etc/init.d/mysql
用打开nano
,但却找不到--
任何地方。
有人知道如何解决这个问题吗?
结果如下systemctl status mariadb.service
:
● mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: failed (Result: exit-code) since Mi 2016-10-12 09:35:29 CEST; 4min 36s ago
Process: 5272 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=1/FAILURE)
Process: 5267 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 5266 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 4281 (code=exited, status=0/SUCCESS)
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: 128 rollback segment(s) are active.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: Waiting for purge to start
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.32-78.1 started; log sequence number 1616869
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Warning] InnoDB: Skipping buffer pool dump/restore during wsrep recovery.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] Plugin 'FEEDBACK' is disabled.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [ERROR] /usr/sbin/mysqld: unknown option '--.'
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [ERROR] Aborting'
Okt 12 09:35:29 node2 systemd[1]: mariadb.service: control process exited, code=exited status=1
Okt 12 09:35:29 node2 systemd[1]: Failed to start MariaDB database server.
Okt 12 09:35:29 node2 systemd[1]: Unit mariadb.service entered failed state.
结果如下journalctl -xn
:
-- Logs begin at Di 2016-10-11 16:10:14 CEST, end at Mi 2016-10-12 09:35:29 CEST. --
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: 128 rollback segment(s) are active.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: Waiting for purge to start
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Warning] InnoDB: Skipping buffer pool dump/restore during
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] Plugin 'FEEDBACK' is disabled.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [ERROR] /usr/sbin/mysqld: unknown option '--.'
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [ERROR] Aborting'
Okt 12 09:35:29 node2 systemd[1]: mariadb.service: control process exited, code=exited status=1
Okt 12 09:35:29 node2 systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has failed.
--
-- The result is failed.
Okt 12 09:35:29 node2 systemd[1]: Unit mariadb.service entered failed state.
lines 1-18/18 (END)
-- Logs begin at Di 2016-10-11 16:10:14 CEST, end at Mi 2016-10-12 09:35:29 CEST. --
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: 128 rollback segment(s) are active.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: Waiting for purge to start
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.32-78.1 starte
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Warning] InnoDB: Skipping buffer pool dump/restore during wsrep recovery.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [Note] Plugin 'FEEDBACK' is disabled.
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [ERROR] /usr/sbin/mysqld: unknown option '--.'
Okt 12 09:35:29 node2 sh[5272]: 2016-10-12 9:35:27 3045435776 [ERROR] Aborting'
Okt 12 09:35:29 node2 systemd[1]: mariadb.service: control process exited, code=exited status=1
Okt 12 09:35:29 node2 systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mariadb.service has failed.
--
-- The result is failed.
Okt 12 09:35:29 node2 systemd[1]: Unit mariadb.service entered failed state.
:/etc/init.d/mysql
# and its wrapper script "mysqld_safe".
### END INIT INFO
#
set -e
set -u
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
test -x /usr/sbin/mysqld || exit 0
. /lib/lsb/init-functions
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
CONF=/etc/mysql/my.cnf
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
# priority can be overriden and "-s" adds output to stderr
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"
# Safeguard (relative paths, core dumps..)
cd /
umask 077
# mysqladmin likes to read /root/.my.cnf. This is usually not what I want
# as many admins e.g. only store a password without a username there and
# so break my scripts.
export HOME=/etc/mysql/
# Source default config file.
[ -r /etc/default/mariadb ] && . /etc/default/mariadb
## Fetch a particular option from mysql's invocation.
#
# Usage: void mysqld_get_param option
mysqld_get_param() {
/usr/sbin/mysqld --print-defaults \
| tr " " "\n" \
| grep -- "--$1" \
| tail -n 1 \
| cut -d= -f2
}
## Do some sanity checks before even trying to start mysqld.
sanity_checks() {
# check for config file
if [ ! -r /etc/mysql/my.cnf ]; then
log_warning_msg "$0: WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz"
echo "WARNING: /etc/mysql/my.cnf cannot be read. See README.Debian.gz" | $ERR_LOGGER
fi
# check for diskspace shortage
datadir=`mysqld_get_param datadir`
if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4>4096) }'; then
log_failure_msg "$0: ERROR: The partition with $datadir is too full!"
echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
exit 1
fi
}
## Checks if there is a server running and if so if it is accessible.
#
# check_alive insists on a pingable server
# check_dead also fails if there is a lost mysqld in the process list
#
# Usage: boolean mysqld_status [check_alive|check_dead] [warn|nowarn]
mysqld_status () {
ping_output=`$MYADMIN ping 2>&1`; ping_alive=$(( ! $? ))
ps_alive=0
pidfile=`mysqld_get_param pid-file`
if [ -f "$pidfile" ] && ps `cat $pidfile` >/dev/null 2>&1; then ps_alive=1; fi
if [ "$1" = "check_alive" -a $ping_alive = 1 ] ||
[ "$1" = "check_dead" -a $ping_alive = 0 -a $ps_alive = 0 ]; then
return 0 # EXIT_SUCCESS
else
if [ "$2" = "warn" ]; then
echo -e "$ps_alive processes alive and '$MYADMIN ping' resulted in\n$ping_output\n" | $ERR_LOGGER -p daemon.debug
fi
return 1 # EXIT_FAILURE
fi
}
#
# main()
#
case "${1:-''}" in
'start')
sanity_checks;
# Start daemon
log_daemon_msg "Starting MariaDB database server" "mysqld"
if mysqld_status check_alive nowarn; then
log_progress_msg "already running"
log_end_msg 0
else
# Could be removed during boot
test -e /var/run/mysqld || install -m 755 -o mysql -g root -d /var/run/mysqld
# Start MariaDB!
/usr/bin/mysqld_safe "${@:2}" > /dev/null 2>&1 &
# 6s was reported in #352070 to be too little
for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-60}"); do
sleep 1
if mysqld_status check_alive nowarn ; then break; fi
log_progress_msg "."
done
if mysqld_status check_alive warn; then
log_end_msg 0
# Now start mysqlcheck or whatever the admin wants.
output=$(/etc/mysql/debian-start)
[ -n "$output" ] && log_action_msg "$output"
else
log_end_msg 1
log_failure_msg "Please take a look at the syslog"
fi
fi
;;
'stop')
# * As a passwordless mysqladmin (e.g. via ~/.my.cnf) must be possible
# at least for cron, we can rely on it here, too. (although we have
# to specify it explicit as e.g. sudo environments points to the normal
# users home and not /root)
log_daemon_msg "Stopping MariaDB database server" "mysqld"
if ! mysqld_status check_dead nowarn; then
set +e
shutdown_out=`$MYADMIN shutdown 2>&1`; r=$?
set -e
if [ "$r" -ne 0 ]; then
log_end_msg 1
[ "$VERBOSE" != "no" ] && log_failure_msg "Error: $shutdown_out"
log_daemon_msg "Killing MariaDB database server by signal" "mysqld"
killall -15 mysqld
server_down=
for i in `seq 1 600`; do
sleep 1
if mysqld_status check_dead nowarn; then server_down=1; break; fi
done
if test -z "$server_down"; then killall -9 mysqld; fi
fi
fi
if ! mysqld_status check_dead warn; then
log_end_msg 1
log_failure_msg "Please stop MariaDB manually and read /usr/share/doc/mariadb-server-10.1/README.Debian.gz!"
exit -1
else
log_end_msg 0
fi
;;
'restart')
set +e; $SELF stop; set -e
$SELF start
;;
'reload'|'force-reload')
log_daemon_msg "Reloading MariaDB database server" "mysqld"
$MYADMIN reload
log_end_msg 0
;;
'status')
if mysqld_status check_alive nowarn; then
log_action_msg "$($MYADMIN version)"
else
log_action_msg "MariaDB is stopped."
exit 3
fi
;;
'bootstrap')
# Bootstrap the cluster, start the first node
# that initiates the cluster
log_daemon_msg "Bootstrapping the cluster" "mysqld"
$SELF start "${@:2}" --wsrep-new-cluster
;;
*)
echo "Usage: $SELF start|stop|restart|reload|force-reload|status|bootstrap"
exit 1
;;
esac
这是my.cnf:
# MariaDB database server configuration file.
#
# You can copy this file to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc_messages_dir = /usr/share/mysql
lc_messages = en_US
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
max_connections = 100
connect_timeout = 5
wait_timeout = 600
max_allowed_packet = 16M
thread_cache_size = 128
sort_buffer_size = 4M
bulk_insert_buffer_size = 16M
tmp_table_size = 32M
max_heap_table_size = 32M
#
# * MyISAM
#
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched. On error, make copy and try a repair.
myisam_recover_options = BACKUP
key_buffer_size = 128M
#open-files-limit = 2000
table_open_cache = 400
myisam_sort_buffer_size = 512M
concurrent_insert = 2
read_buffer_size = 2M
read_rnd_buffer_size = 1M
#
# * Query Cache Configuration
#
# Cache only tiny result sets, so we can fit more in the query cache.
query_cache_limit = 128K
query_cache_size = 64M
# for more write intensive setups, set to DEMAND or OFF
#query_cache_type = DEMAND
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# we do want to know about network errors and such
log_warnings = 2
#
# Enable the slow query log to see queries with especially long duration
#slow_query_log[={0|1}]
slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 10
#log_slow_rate_limit = 1000
log_slow_verbosity = query_plan
#log-queries-not-using-indexes
#log_slow_admin_statements
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#report_host = master1
#auto_increment_increment = 2
#auto_increment_offset = 1
log_bin = /var/log/mysql/mariadb-bin
log_bin_index = /var/log/mysql/mariadb-bin.index
# not fab for performance, but safer
#sync_binlog = 1
expire_logs_days = 10
max_binlog_size = 100M
# slaves
#relay_log = /var/log/mysql/relay-bin
#relay_log_index = /var/log/mysql/relay-bin.index
#relay_log_info_file = /var/log/mysql/relay-bin.info
#log_slave_updates
#read_only
#
# If applications support it, this stricter sql_mode prevents some
# mistakes like inserting invalid dates etc.
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
default_storage_engine = InnoDB
# you can't just change log file size, requires special procedure
#innodb_log_file_size = 50M
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
innodb_open_files = 400
innodb_io_capacity = 400
innodb_flush_method = O_DIRECT
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completion
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
我使用并命名的自定义配置galera.cnf
:
[mysqld]
.#mysql settings
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
innodb_doublewrite=1
query_cache_size=0
query_cache_type=0
bind-address=0.0.0.0
#galera settings
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="skyfillers_cluster"
wsrep_cluster_address=gcomm://192.168.2.162,192.168.2.164,192.168.2.163
wsrep_sst_method=rsync
答案1
您需要定义节点的地址,例如:
# this server ip, change for each server
wsrep_node_address="192.168.2.162"
请注意在测试时禁用所有防火墙,以防防火墙阻止节点之间的连接