【发布时间】:2020-12-31 17:51:51
【问题描述】:
我是 MySQL 新手,我正在尝试在具有不同端口号的同一主机上创建多个 mysql 集群。我知道默认端口是 3306,所以我尝试将 my.cnf 配置为:
[mysqld2]
datadir=/var/lib/mysql2
port=3307
然后运行 mysql -P 3307 但这不起作用。我不知道如何在这个端口上启动集群。 请发送帮助:)
编辑:
所以我发现我需要创建另一个配置文件并把它放到这里:
mkdir -p /var/lib/mysql2
chmod --reference /var/lib/mysql /var/lib/mysql2
chown --reference /var/lib/mysql /var/lib/mysql2
cp -p /etc/my.cnf /etc/my2.cnf
vi /etc/my2.cnf
--------------------------------------
[mysqld]
datadir=/var/lib/mysql2
socket=/var/lib/mysql/mysql2.sock
port=3337
[mysqld_safe]
log-error=/var/log/mysqld2.log
pid-file=/var/run/mysqld/mysqld2.pid
--------------------------------------
mysqld --initialize-insecure --user=mysql --datadir=/var/lib/mysql2
现在我有一个新的数据目录集和一个配置文件,问题是我不知道如何启动这个特定的集群(使用我制作的这个配置文件)
编辑2:
现在当我运行 mysqld --defaults-file=/etc/my2.cnf 我得到这个错误:
[root@pg66 ~]# mysqld --defaults-file=/etc/my2.cnf
2020-12-31T09:50:08.821792Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.22) starting as process 28085
2020-12-31T09:50:08.838198Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-12-31T09:50:09.551655Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-12-31T09:50:10.670160Z 0 [ERROR] [MY-011292] [Server] Plugin mysqlx reported: 'Preparation of I/O interfaces failed, X Protocol won't be accessible'
2020-12-31T09:50:10.670328Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of bind-address: '*' port: 33060 failed, `bind()` failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx ?'
2020-12-31T09:50:10.670440Z 0 [ERROR] [MY-013597] [Server] Plugin mysqlx reported: 'Value '*' set to `Mysqlx_bind_address`, X Plugin can't bind to it. Skipping this value.'
2020-12-31T09:50:10.670592Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, another process with PID 26783 is using UNIX socket file'
2020-12-31T09:50:11.007743Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-12-31T09:50:11.007904Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2020-12-31T09:50:11.063486Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.22' socket: '/var/lib/mysql/mysql2.sock' port: 3337 MySQL Community Server - GPL.
^C^C^[[A^C
【问题讨论】:
-
我认为您必须使用第二个实例的配置创建另一个
my.cnf配置文件(例如:my2.cnf)。顺便说一句,我认为你必须使用[mysqld]而不是[mysqld2] -
是的,我刚刚发现了。编辑了我的问题。还需要弄清楚如何启动集群