我在Ubuntu 16.04服务器上安装了percona-xtradb-cluster-server-5.7,并且mysql运行正常,默认配置为我们的盒子。但是,当我尝试编辑my.cnf文件时,我会收到变量未知的错误,例如:
mysql: [ERROR] unknown variable 'datadir=/var/mysql/mysql'
我试图在服务器上找到不同的my.cnf文件,并试图一个接一个地添加变量,但似乎得到了同样的错误。
所以我的问题是,在Ubuntu 16.04上适用于MySQL 5.7的my.cnf文件在哪里?我甚至试过这个:/etc/mysql/conf.d/mysql.cnf localtion并得到以下错误:
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
failed!
以下是与我的Ubuntu 16.04服务器上可能的MySQL 5.7配置文件相关的信息
ubuntu@db-test-1:~$ sudo find / -name my.cnf
/etc/mysql/my.cnf
/etc/alternatives/my.cnf
/var/lib/dpkg/alternatives/my.cnf
ubuntu@db-test-1:~$
ubuntu@db-test-1:~$ sudo ls -l /etc/mysql/
total 20
drwxr-xr-x 2 root root 4096 Oct 30 15:05 conf.d
-rw-r--r-- 1 root root 237 Oct 30 12:42 debian.cnf
-rw-r--r-- 1 root root 836 Oct 30 14:49 my.cnf
-rw-r--r-- 1 root root 380 Oct 24 01:18 percona-xtradb-cluster.cnf
drwxr-xr-x 2 root root 4096 Oct 30 11:51 percona-xtradb-cluster.conf.d
ubuntu@db-test-1:~$ sudo ls -l /etc/mysql/conf.d/
total 8
-rw-r--r-- 1 root root 8 Oct 30 15:05 mysql.cnf
-rw-r--r-- 1 root root 55 Jan 22 2017 mysqldump.cnf
ubuntu@db-test-1:~$ /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"^C
ubuntu@db-test-1:~$ sudo su
root@db-test-1:/home/ubuntu# /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
顺便说一句,debian.cnf文件不带5.7版本,但是我添加了它,因为我需要它在刷新日志期间进行日志轮换。
下面是我在/etc/mysql/conf.d/mysql.cnf配置文件底部添加的galera配置:
server-id = 1010101
# Galera Config
wsrep_cluster_address = gcomm://10.1.0.101, 10.1.0.101
wsrep_cluster_name = db-hr
wsrep_provider = /usr/lib/libgalera_smm.so
wsrep_provider_options = "gcache.size=4G"
wsrep_slave_threads = 4
wsrep_sst_auth = "user:secret"
wsrep_sst_method = xtrabackup-v2
答案 0 :(得分:1)
The my.cnf file is set in sections and this parameter should be set under the [mysqld] section. The error suggests that you might have it in the [mysql] or [client] section. There is a free online tool that might help you create the my.cnf correctly, you do have to register your email to access it though: https://tools.percona.com/
Ubuntu有一个分步示例,可以帮助您完成https://www.percona.com/doc/percona-xtradb-cluster/LATEST/howtos/ubuntu_howto.html