毕竟做的是主从集群,自然有一些必要的配置。进入配置字典:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
server_id=1
log-bin=mysql-bin
read-only=0
binlog-do-db=car_receiver_pre
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
server_id=2
log-bin=mysql-bin
read-only=1
binlog-do-db=car_receiver_pre
replicate-ignore-db=mysql
replicate-ignore-db=sys
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema
我们还需要存储空间对吧,数据要存在哪里,那就造个 pvc。
同理,再创建一个从节点的:
创建服务:
默认端口设置:
资源配置:
环境变量:
容器组调度规则:
先点击这个:
选择对应的配置字典:
挂载配置:
之后点击✅:
再点击这个:
选择持久卷:
点击✅:
点击“下一步”。
保持默认:
服务创建成功:
进入mysql-master-v1-0容器组
进入容器终端,验证配置文件没问题:
同理的操作。
回到服务:
基本信息:
容器组设置:
资源配置:
环境变量,MYSQL_ROOT_PASSWORD:
调度规则:
挂载配置字典:
挂载路径,/etc/mysql/conf.d:
挂载卷:
挂载路径,/var/lib/mysql:
打钩,并下一步。
保持默认,点击创建:
sh-4.4# cd /etc/mysql/conf.d
sh-4.4# ls
my.cnf
sh-4.4# cat my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
server_id=2
log-bin=mysql-bin
read-only=1
binlog-do-db=car_receiver_pre
replicate-ignore-db=mysql
replicate-ignore-db=sys
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schemash-4.4#