关闭防火墙; 安装 MysqL依赖于libaio 库;下载,解压,重命名 MysqL的执行文件;新建用户组和用户 等准备工作在此不再赘述。
可执行文件目录为 /data/MysqL57
添加用户和组的指令
groupadd MysqL
useradd MysqL -g MysqL
Step 2 . 添加环境变量在/etc/profile文件中,追加 PATH=${PATH}:/data/MysqL57/bin/
保存后,如需要立即生效,可执行 source /etc/profile 。
step 3 . 创建目录并授权在data根目录下执行
mkdir -p MysqL3306/data MysqL3306/MysqL_log MysqL3306/tmp MysqL3307/data MysqL3307/MysqL_log MysqL3307/tmp MysqLd_multi/log
创建记录log的文件,此步骤不可少。
touch /data/MysqL3306/MysqL_log/MysqL3306.errtouch /data/MysqL3307/MysqL_log/MysqL3307.err
赋予目录和文件权限
chown -R MysqL.MysqL MysqL3* MysqLd_multi
在本测试案例中,MysqL57是从其它服务上copy来的,不是直接下载解压的,所以多了下面的两步授权 *** 作。
chmod -R 755 /data/MysqL57/bin
755 /data/MysqL57/support-files
step 4 . 编辑my.cnf[clIEnt]host=localhostsocket = /tmp/MysqL.sock default-character-set=utf8mb4#loose-local-infile=0[MysqLd]user=MysqLlog_bin_trust_function_creators=1secure_file_priv='/tmp'########server setting#######sql_mode = "ONLY_FulL_GROUP_BY,STRICT_TRANS_tableS,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_divISION_BY_ZERO,NO_auto_CREATE_USER,NO_ENGINE_SUBSTITUTION"character-set-server=utf8mb4collation_server=utf8mb4_unicode_cilower_case_table_names = skip_name_resolve = #max_connect_errors = 1000max_connections = 2000thread_cache_size=256#thread_stack= 262144#back_log=80max_allowed_packet = 134217728event_scheduler = local-infile=#lower_case_table_names = explicit_defaults_for_timestamp = expire_logs_days = 7log_bin_trust_function_creators =####.frm/.ibd files qty relatedopen_files_limit=65535innodb_open_files=table_open_cache=table_deFinition_cache=#### seesion buffer relatedread_buffer_size = read_rnd_buffer_size = 524288sort_buffer_size = 8388608join_buffer_size = ####memory table size tmp_table_size =67108864max_heap_table_size=####timeoutinteractive_timeout = 1800wait_timeout = # connect_timeout=10########slow query ########slow_query_log = log_slow_slave_statements = #log_querIEs_not_using_indexes = log_throttle_querIEs_not_using_indexes = long_query_time = #min_examined_row_limit = 10000########innodb settings########innodb_buffer_pool_size = 10737418240innodb_buffer_pool_instances = 16 innodb_buffer_pool_dump_pct = 40innodb_lru_scan_depth = 2048innodb_page_cleaners = #innodb_purge_threads = 4innodb_sort_buffer_size = #innodb_file_per_table = #innodb_flush_log_at_trx_commit = innodb_undo_log_truncate = innodb_undo_tablespaces = 3 innodb_max_undo_log_size = 2147483648innodb_purge_rseg_truncate_frequency = 128innodb_log_file_size = 1073741824innodb_log_files_in_group = innodb_log_buffer_size = 16777216innodb_flush_method = O_DIRECTinnodb_flush_neighbors = innodb_print_all_deadlocks = innodb_strict_mode = #innodb_lock_wait_timeout = 50innodb_io_capacity = 32768innodb_io_capacity_max = 65536innodb_thread_concurrency = 32innodb_write_io_threads = 8innodb_read_io_threads = ########replication settings########master_info_repository = tablerelay_log_info_repository = tablegtID_mode = onenforce_gtID_consistency = binlog_gtID_simple_recovery=relay_log_recovery = slave-parallel-type = LOGICAL_CLOCKslave-parallel-workers = slave_transaction_retrIEs=slave_preserve_commit_order=log_slave_updates=binlog_format = ROWlog_timestamps=systembinlog_rows_query_log_events = binlog_row_image=full slave_skip_errors = ddl_exist_errors########semi sync replication settings##########plugin_dir=/data/MysqL/plugin/#plugin_load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so#rpl_semi_sync_master_enabled = #rpl_semi_sync_master_timeout = 5000#rpl_semi_sync_slave_enabled = [MysqLd_multi]MysqLd = /data/MysqL57/bin/MysqLd_safeMysqLadmin = /data/MysqL57/bin/MysqLadminlog = /data/MysqLd_multi/log/MysqLd_multi.log[MysqLd3306] basedir = /data/MysqL57MysqLadmin=MysqLadmindatadir=/data/MysqL3306/dataport=3306 server_ID=102473306socket= /tmp/MysqL_3306.socktmpdir = /data/MysqL3306/tmppID-file = /data/MysqL3306/MysqL_log/MysqL3306.pIDslow_query_log_file = /data/MysqL3306/MysqL_log/MysqL3306_slow_new.log log-error = /data/MysqL3306/MysqL_log/MysqL3306.errgeneral_log_file= /data/MysqL3306/MysqL_log/MysqL3306.genloglog-bin = /data/MysqL3306/MysqL_log/MysqL3306_binrelay_log = /data/MysqL3306/MysqL_log/relay3306.loginnodb_buffer_pool_size = 90Ginnodb_buffer_pool_instances = [MysqLd3307]basedir = /data/MysqLadmindatadir=/data/MysqL3307/3307server_ID=102473307MysqL_3307.socktmpdir = /data/MysqL3307/file = /data/MysqL3307/MysqL_log/MysqL3307.pIDslow_query_log_file = /data/MysqL3307/MysqL_log/MysqL3307_slow_new.loglog-error = /data/MysqL3307/MysqL_log/MysqL3307.errgeneral_log_file= /data/MysqL3307/MysqL_log/MysqL3307.genloglog-bin = /data/MysqL3307/MysqL_log/MysqL3307_binrelay_log = /data/MysqL3307/MysqL_log/relay3307.loginnodb_buffer_pool_size =[MysqLdump]quickstep 5 . 初始化实例
初始化3306端口的实例,注意产生的临时密码。
/data/MysqL57/bin/MysqLd --defaults-file=/etc/my.cnf --initialize --user=MysqL --basedir=/data/MysqL57 --datadir=/data/MysqL3306/data
初始化3307端口的实例,注意产生的临时密码。
/data/MysqL57/bin/MysqLd --defaults-file=/etc/my.cnf --initialize --user=MysqL --basedir=/data/MysqL57 --datadir=/data/MysqL3307/data
step 6 . 复制生成MysqLd_multi并添加到开机启动cp /data/MysqL57/support-files/MysqLd_multi.server /etc/init.d/MysqLd_multi
chkconfig --add MysqLd_multistep 7 . 多实例MysqLd的开启
开启全部实例
MysqLd_multi start
查看开启情况(查看全部实例状态)
MysqLd_multi report
开启指定实例
开启/etc/my.cnf中[MysqLd3306]其中MysqLd后面的数字为标签,例如3306标签
MysqLd_multi start 3306
同样开启3307标签实例
MysqLd_multi start 3307
(注意:此处没有说通过 MysqLd_multi stop 命令进行关闭实例,为什么不说,因为命令无效。Step 9 的 *** 作会让它变成有效)
step 8 . 第一次登入实例,修改root账号密码多实例登入需指定 socket 参数
本测试3306实例登入的方式为:
MysqL -S /tmp/MysqL_3306.sock -uroot --port 3306 -p
step 9 . 赋予通过MysqLd_multi stop关闭实例的权限。
关闭实例需要配置root用户及密码, 修改 /etc/my.cnf文件。
在 [clIEnt] 位置添加
user=rootpassword=密码
因为文件中需要保留账号密码,有安全风险。实际环境中要不要如此设置,还需根据具体情况和安全要求而定。
经过以上步骤的 *** 作,此服务器成功安装了2个MysqL实例,一个Port为3306,另一个Port为3307
感谢:以上文档在同事Fly Chen的基础梳理完成。
总结以上是内存溢出为你收集整理的MySQL 多实例的安装全部内容,希望文章能够帮你解决MySQL 多实例的安装所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)