Mysql 5.7无法创建UNIX套接字锁定文件

问题描述 投票:7回答:1

我正在尝试在同一个Ubuntu 16.10 32位框中创建MySQL 5.7的多个实例。我已经将原始数据目录复制到了新目录。为新实例创建单独的日志文件夹(日志正在工作)。将所有者更改为mysql:mysql以获取新数据目录/ var / lib / mysql2和日志目录/ var / log / mysql2 /。我已经删除了应用程序装甲。我仅在经历了其他SO答案之后才发布此问题...这些都没有解决多实例问题。

这是我的my2.cnf:

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld2.pid
socket          = /var/run/mysqld/mysqld2.sock
port            = 3307
basedir         = /usr
datadir         = /var/lib/mysql2
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
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
#
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP
#max_connections        = 100
#table_open_cache       = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M

[mysqld_safe]
socket          = /var/run/mysqld/mysqld2.sock
nice            = 0

您可以看到,我分别将端口更改为3307和其他端口。现在,当我运行时(必须将sudo添加到mysqld中):

sudo mysqld --defaults-file=/etc/mysql/my2.cnf &

我收到:

2017-03-22T08:31:21.684121Z 0 [Note] mysqld (mysqld 5.7.17-0ubuntu0.16.10.1) starting as process 13676 ...
2017-03-22T08:31:21.687115Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-03-22T08:31:21.687131Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-03-22T08:31:21.687135Z 0 [Note] InnoDB: Uses event mutexes
2017-03-22T08:31:21.687140Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-03-22T08:31:21.687143Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-03-22T08:31:21.687147Z 0 [Note] InnoDB: Using Linux native AIO
2017-03-22T08:31:21.687281Z 0 [Note] InnoDB: Number of pools: 1
2017-03-22T08:31:21.687344Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2017-03-22T08:31:21.688116Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-03-22T08:31:21.693801Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-03-22T08:31:21.694846Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the $
2017-03-22T08:31:21.708807Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-03-22T08:31:21.776053Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-03-22T08:31:21.776228Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-03-22T08:31:21.825266Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-03-22T08:31:21.826338Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-03-22T08:31:21.826359Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-03-22T08:31:21.826695Z 0 [Note] InnoDB: Waiting for purge to start
2017-03-22T08:31:21.880277Z 0 [Note] InnoDB: 5.7.17 started; log sequence number 2535531
2017-03-22T08:31:21.881286Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql2/ib_buffer_pool
2017-03-22T08:31:21.881581Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-03-22T08:31:21.887687Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170322 14:01:21
2017-03-22T08:31:21.890330Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without cer$
2017-03-22T08:31:21.890380Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3307
2017-03-22T08:31:21.890407Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2017-03-22T08:31:21.890695Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2017-03-22T08:31:21.890791Z 0 [ERROR] Could not create unix socket lock file /var/run/mysqld/mysqld2.sock.lock.
2017-03-22T08:31:21.890807Z 0 [ERROR] Unable to setup unix socket lock file.
2017-03-22T08:31:21.890819Z 0 [ERROR] Aborting

我想念什么?

mysql sockets instances
1个回答
0
投票

对于使用apparmor的用户,/etc/apparmor.d/usr.sbin.mysqld中的以下权限允许mysqld创建和使用锁定文件。

/var/run/mysqld/mysqld2.pid rw,
/var/run/mysqld/mysqld2.sock rw,
/var/run/mysqld/mysqld2.sock.lock rw,

然后以root用户身份运行以下命令以重新加载配置文件。

apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld

由于某种原因,我在所有这三个文件上都没有rw权限就收到了OP的错误。

© www.soinside.com 2019 - 2024. All rights reserved.