欢送来到 GreatSQL社区分享的MySQL技术文章,如有疑难或想学习的内容,能够在下方评论区留言,看到后会进行解答
- GreatSQL社区原创内容未经受权不得随便应用,转载请分割小编并注明起源。
1、对于systemd
systemd 是Linux系统启动和服务器守护过程管理器,负责在系统启动或运行时,激活系统资源,服务器过程和其它过程,systemd被设计用来改良原来sysvinit中的多个毛病。
CentOS 7的systemd服务程序脚本寄存在 /usr/lib/systemd/目录下,并辨别 system 和 user,每一个服务程序脚本以 .service 结尾,例如 /usr/lib/systemd/system/sshd.service。
2、编辑systemd服务程序脚本
设定 GreatSQL 二进制文件放在 /usr/local/GreatSQL-8.0.23-14/ 目录下,即设定 basedir 为此目录,先进入到这个工作目录中。
[root@greatsql~]# cd /usr/local/GreatSQL-8.0.23-14/
复制 support-files/greatsql.server 程序脚本到 /usr/lib/systemd/system/ 目录下:
[root@greatsql~]# cp -f ./support-files/greatsql.server /usr/lib/systemd/system/
该脚本内容如下,基本上不须要再批改什么内容:
[root@greatsql~]# cat /usr/lib/systemd/system/greatsql.service[Unit]Description=GreatSQL ServerDocumentation=man:mysqld(8)Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.htmlAfter=network.targetAfter=syslog.target[Install]WantedBy=multi-user.target[Service]User=mysqlGroup=mysqlType=notifyTimeoutSec=0PermissionsStartOnly=trueExecStartPre=/usr/local/GreatSQL-8.0.23-14/bin/mysqld_pre_systemdExecStart=/usr/local/GreatSQL-8.0.23-14/bin/mysqld $MYSQLD_OPTSEnvironmentFile=-/etc/sysconfig/mysqlLimitNOFILE = 10000Restart=on-failureRestartPreventExitStatus=1Environment=MYSQLD_PARENT_PID=1PrivateTmp=false
3、筹备my.cnf及其他配置文件
复制 support-files/my.cnf 到 /etc/ 目录下,替换原来的配置文件(原来的 /etc/my.cnf 倡议先备份),并确认 datadir、port、server_id 等参数是否要批改:
[root@greatsql~]# cp -f ./support-files/my.cnf /etc/my.cnf[root@greatsql~]# cat /etc/my.cnf#my.cnf[mysqld]user = mysqlport = 3306server_id = 3306basedir=/usr/local/GreatSQL-8.0.23-14datadir = /data/GreatSQLsocket = /data/GreatSQL/mysql.sockpid-file = mysql.pidcharacter-set-server = UTF8MB4skip_name_resolve = 1#若你的MySQL数据库次要运行在境外,请务必依据理论状况调整本参数default_time_zone = "+8:00"#performance setttingslock_wait_timeout = 3600open_files_limit = 65535back_log = 1024max_connections = 512max_connect_errors = 1000000table_open_cache = 1024table_definition_cache = 1024thread_stack = 512Ksort_buffer_size = 4Mjoin_buffer_size = 4Mread_buffer_size = 8Mread_rnd_buffer_size = 4Mbulk_insert_buffer_size = 64Mthread_cache_size = 768interactive_timeout = 600wait_timeout = 600tmp_table_size = 32Mmax_heap_table_size = 32M#log settingslog_timestamps = SYSTEMlog_error = /data/GreatSQL/error.loglog_error_verbosity = 3slow_query_log = 1log_slow_extra = 1slow_query_log_file = /data/GreatSQL/slow.loglong_query_time = 0.1log_queries_not_using_indexes = 1log_throttle_queries_not_using_indexes = 60min_examined_row_limit = 100log_slow_admin_statements = 1log_slow_slave_statements = 1log_bin = /data/GreatSQL/binlogbinlog_format = ROWsync_binlog = 1binlog_cache_size = 4Mmax_binlog_cache_size = 2Gmax_binlog_size = 1Gbinlog_rows_query_log_events = 1binlog_expire_logs_seconds = 604800#MySQL 8.0.22前,想启用MGR的话,须要设置binlog_checksum=NONE才行binlog_checksum = CRC32gtid_mode = ONenforce_gtid_consistency = TRUE#myisam settingskey_buffer_size = 32Mmyisam_sort_buffer_size = 128M#replication settingsmaster_info_repository = TABLErelay_log_info_repository = TABLErelay_log_recovery = 1slave_parallel_type = LOGICAL_CLOCK#能够设置为逻辑CPU数量的2倍slave_parallel_workers = 64binlog_transaction_dependency_tracking = WRITESETslave_preserve_commit_order = 1slave_checkpoint_period = 2#mgr settingsloose-plugin_load_add = 'mysql_clone.so'loose-plugin_load_add = 'group_replication.so'loose-group_replication_group_name = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1"#MGR本地节点IP:PORT,请自行替换loose-group_replication_local_address = "172.16.16.10:33061"#MGR集群所有节点IP:PORT,请自行替换loose-group_replication_group_seeds = "172.16.16.10:33061,172.16.16.11:33061,172.16.16.12:33061"loose-group_replication_start_on_boot = OFFloose-group_replication_bootstrap_group = OFFloose-group_replication_exit_state_action = READ_ONLYloose-group_replication_flow_control_mode = "DISABLED"loose-group_replication_single_primary_mode = ON#innodb settingstransaction_isolation = REPEATABLE-READinnodb_buffer_pool_size = 2Ginnodb_buffer_pool_instances = 8innodb_data_file_path = ibdata1:12M:autoextendinnodb_flush_log_at_trx_commit = 1innodb_log_buffer_size = 32Minnodb_log_file_size = 1Ginnodb_log_files_in_group = 3innodb_max_undo_log_size = 4G# 依据您的服务器IOPS能力适当调整# 个别配一般SSD盘的话,能够调整到 10000 - 20000# 配置高端PCIe SSD卡的话,则能够调整的更高,比方 50000 - 80000innodb_io_capacity = 4000innodb_io_capacity_max = 8000innodb_open_files = 65535innodb_flush_method = O_DIRECTinnodb_lru_scan_depth = 4000innodb_lock_wait_timeout = 10innodb_rollback_on_timeout = 1innodb_print_all_deadlocks = 1innodb_online_alter_log_max_size = 4Ginnodb_print_ddl_logs = 1innodb_status_file = 1#留神: 开启 innodb_status_output & innodb_status_output_locks 后, 可能会导致log_error文件增长较快innodb_status_output = 0innodb_status_output_locks = 1innodb_sort_buffer_size = 67108864#innodb monitor settingsinnodb_monitor_enable = "module_innodb"innodb_monitor_enable = "module_server"innodb_monitor_enable = "module_dml"innodb_monitor_enable = "module_ddl"innodb_monitor_enable = "module_trx"innodb_monitor_enable = "module_os"innodb_monitor_enable = "module_purge"innodb_monitor_enable = "module_log"innodb_monitor_enable = "module_lock"innodb_monitor_enable = "module_buffer"innodb_monitor_enable = "module_index"innodb_monitor_enable = "module_ibuf_system"innodb_monitor_enable = "module_buffer_page"innodb_monitor_enable = "module_adaptive_hash"#pfs settingsperformance_schema = 1#performance_schema_instrument = '%memory%=on'performance_schema_instrument = '%lock%=on'
再复制 support-files/sysconfig/mysql 文件到 /etc/sysconfig 目录下。
[root@greatsql~]# cp -f ./support-files/sysconfig/mysql /etc/sysconfig/mysql[root@greatsql~]# cat /etc/sysconfig/mysqlLD_PRELOAD=/usr/lib64/libjemalloc.so.1
这是为了能让GreatSQL启动时加载jemalloc,取得更好的内存治理性能。
4、启动GreatSQL服务
上述筹备工作实现后,还要将 GreatSQL 服务正式加载到 systemd 列表中:
[root@greatsql~]# systemctl daemon-reload
这就会主动将GreatSQL这个新服务加载进来了。
而后开始启动服务:
[root@greatsql~]# systemctl start greatsql#如果加上 .service 后缀也能够,例如[root@greatsql~]# systemctl start greatsql.service
如果启动失败,可能会输入相似的报错提醒:
[root@greatsql~]# systemctl start greatsqlJob for greatsql.service failed because the control process exited with error code. See "systemctl status greatsql.service" and "journalctl -xe" for details.
依照谬误提醒,执行 systemctl status greatsql.service 或 journalctl -xe 查看失败的起因,亦可查看系统日志 /var/log/messages 或 GreatSQL日志 /data/GreatSQL/error.log 确认失败起因。
第一次会比较慢,因为还要初始化InnoDB零碎表空间、redo、undo日志等。初始化时,还会为root生成长期明码,例如这样:
...[MY-010454] [Server] A temporary password is generated for root@localhost: dofI,0HE#E>C...
首次登入须要用这个明码,并立刻批改成新密码,新密码还必须合乎平安标准才行,不能是弱明码:
# 先登入[root@greatsql~]# mysql -uroot -p -S/data/GreatSQL/mysql.sockEnter password: ************# 而后批改明码,否则不能做其余操作[root@GreatSQL][(none)]> ALTER USER CURRENT_USER() IDENTIFIED BY 'GreatSQL3##)^';
这是因为用默认加载了 validate_password 组件(component),对明码有合规性要求。
[root@GreatSQL][(none)]> SELECT * FROM mysql.component;+--------------+--------------------+------------------------------------+| component_id | component_group_id | component_urn |+--------------+--------------------+------------------------------------+| 1 | 1 | file://component_validate_password |+--------------+--------------------+------------------------------------+
如果嫌麻烦能够卸载掉(但十分不倡议这么做):
[root@GreatSQL][(none)]> UNINSTALL COMPONENT 'file://component_validate_password';
最初,介绍systemctl次要几个的命令:
- 重载零碎服务:systemctl daemon-reload
- 启用开机启动:systemctl enable greatsql
- 禁用开机启动:systemctl disable greatsql
- 启动服务:systemctl start greatsql
- 进行服务:systemctl stop greatsql
- 重启服务:systemctl restart greatsql
- 查看服务状态:systemctl status greatsql
全文完。
Enjoy GreatSQL :)
文章举荐:
GreatSQL MGR FAQ
https://mp.weixin.qq.com/s/J6...
万答#12,MGR整个集群挂掉后,如何能力主动选主,不必手动干涉
https://mp.weixin.qq.com/s/07...
『2021数据技术嘉年华·ON LINE』:《MySQL高可用架构演进及实际》
https://mp.weixin.qq.com/s/u7...
一条sql语句慢在哪之抓包剖析
https://mp.weixin.qq.com/s/AY...
万答#15,都有哪些状况可能导致MGR服务无奈启动
https://mp.weixin.qq.com/s/in...
技术分享 | 为什么MGR一致性模式不举荐AFTER
https://mp.weixin.qq.com/s/rN...
对于 GreatSQL
GreatSQL是由万里数据库保护的MySQL分支,专一于晋升MGR可靠性及性能,反对InnoDB并行查问个性,是实用于金融级利用的MySQL分支版本。
Gitee:
https://gitee.com/GreatSQL/Gr...
GitHub:
https://github.com/GreatSQL/G...
Bilibili:
https://space.bilibili.com/13...
微信&QQ群:
可搜寻增加GreatSQL社区助手微信好友,发送验证信息“加群”退出GreatSQL/MGR交换微信群
QQ群:533341697
微信小助手:wanlidbc
本文由博客一文多发平台 OpenWrite 公布!