首页 > 其他分享 >介绍和安装

介绍和安装

时间:2023-03-20 23:46:23浏览次数:55  
标签:log mysql 介绍 replication innodb MySQL mysqld 安装

一. MySQL版本选择

  • MySQL5.6以后推荐使用官方版本
  • Percona:在5.6版本之后,MySQL将之前优化集成到官方版本之中
  • MariaDB:无INNODB,且版本较老
  • MySQL5.6以后不断重构源码,安装包越来越大,功能和性能在持续改进

 

二. MySQL官方网站介绍(https://www.mysql.com)

1. Developer Zone:MySQL开发工程师板块

  • Airticle:Oracle工程师自己的博客
  • Plant MySQL:和MySQL相关从业人员的博客
  • Bugs:MySQL BugList
  • Worklog:开发记录
  • Labs:MySQL实验项目

2. Downloads:MySQL下载

  • Enterprise:MySQL企业版相关,略过
  • Community:社区版,我们下载和使用社区版
    • MySQL Community Server:MySQL Server
    • MySQL Fabric:和管理相关的工具
    • MySQL Route:路由中间件
    • MySQL Utilities:MySQL 应用程序包
    • MySQL Workbench:官方图形化管理界面
    • MySQL Proxy:MySQL 代理。Alpha版本,不推荐

3. Documentation:MySQL 文档

  • 官方文档版面更改,下载离线文档在左侧的Menu的下面
    • PDF A4
    • EPUB
    • HML

 

三. MySQL下载

  • 推荐下载Linux-Generic版本
  • Source Code版本主要用于让开发人员研究源码使用,自己编译对性能提升不明显
  • 不推荐使用Version 5.5.X,有部分Bug
  • 推荐使用Version 5.6.X5.7.X

 

四. MySQL安装

  • 安装通用步骤:
    1. 解压mysql-version-linux-glibc2.12-x86_64.tar
    2. 打开INSTALL_BINARY文件,按照shell>开头的步骤执行操作
    3. export PATH=/安装路径/mysql/bin:$PATH添加到/etc/profile
    4. 添加开机自启(视当前环境而定)
  • MySQL5.6安装
查看代码
yum install libaio
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /data/mysql_data
chown -R /data ./scripts/mysql_install_db --user=mysql  #mysql5.6无初始密码
./bin/mysqld_safe --user=mysql &
cp -a support-files/mysql.server /etc/init.d/mysqld
chmod 744 /etc/init.d/mysqld
 
  • MySQL5.7安装
 
查看代码
 yum install libaio
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /data/mysql_data
chown -R mysql.mysql /data
./mysqld --initialize --user=mysql  #此步骤会产生初始密码,在error.log中可查看
./bin/mysql_ssl_rsa_setup
./bin/mysqld_safe --user=mysql &
cp -a support-files/mysql.server
/etc/init.d/mysqld
chmod 744 /etc/init.d/mysqld
set password = password('123456');
  • 验证安装
    • data目录安装之前是空目录,安装完成后应该有ibXXX等文件
    • 安装过程输出的信息中,不应该包含error信息,错误信息默认会写到error日志中
    • 通过bin/mysql命令可以正常登陆
  • MySQL启动
    • ./bin/mysqld_safe --user=mysql &即可启动,mysqld_safe是一个守护mysqld进程的脚本程序,旨在mysqld意外停止时,可以重启mysqld进程
    • 也可以通过INSTALL_BINARY中的步骤,使用/etc/init.d/mysql.server start启动(启动脚本以你复制的实际名字为准,通常改名为mysqld,即/etc/init.d/mysqld start

 

五. 附录

  • my.cnf配置(以下配置不对,需要重新)
查看代码
 [client]
user = root
password = 1111aaA_
[mysql]
prompt = [\u@\p][\d]>\_
no-auto-rehash
[mysqld_safe]
malloc-lib=tcmalloc
[mysqldump]
single-transaction
[mysqld]
##basic settings
user = mysql
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
autocommit = 1
server-id = 8888
character_set_server=utf8mb4
datadir=/mysql_data/data
transaction_isolation = READ-COMMITTED
explicit_defaults_for_timestamp = 1
max_allowed_packet = 64M
event_scheduler = 1
##connection
interactive_timeout = 1800
wait_timeout = 1800
lock_wait_timeout = 1800
skip_name_resolve = 1
max_connections = 1024
max_user_connections = 256
max_connect_errors = 1000000
##table cache performance settings
table_open_cache = 4096
table_definition_cache = 4096
table_open_cache_instances = 64
##session memory settings
read_buffer_size = 16M
read_rnd_buffer_size = 32M
sort_buffer_size = 32M
tmp_table_size = 64M
join_buffer_size = 128M
thread_cache_size = 64
##log settings
log_error = error.log
log_bin = binlog
log_error_verbosity = 2
general_log_file = general.log
slow_query_log = 1
slow_query_log_file = slow.log
log_queries_not_using_indexes = 1
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_throttle_queries_not_using_indexes = 10
expire_logs_days = 90
long_query_time = 2
min_examined_row_limit = 100
log-bin-trust-function-creators = 1
log-slave-updates = 1
##innodb settings
innodb_page_size = 16384
innodb_buffer_pool_size = 160G
innodb_buffer_pool_instances = 16
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 4096
innodb_lock_wait_timeout = 5
innodb_io_capacity = 10000
innodb_io_capacity_max = 20000
innodb_flush_method = O_DIRECT
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_neighbors = 0
innodb_log_file_size = 16G
innodb_log_files_in_group = 2
innodb_log_buffer_size = 64M
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 32
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 64M
innodb_write_io_threads = 16
innodb_read_io_threads = 16
innodb_file_per_table = 1
innodb_stats_persistent_sample_pages = 64
innodb_autoinc_lock_mode = 2
innodb_online_alter_log_max_size=1G
innodb_open_files=4096
##replication settings
master_info_repository = TABLE
relay_log_info_repository = TABLE
sync_binlog = 1
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = ROW
binlog_rows_query_log_events = 1
relay_log = relay.log
relay_log_recovery = 1
slave_skip_errors = ddl_exist_errors
slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN'
semi sync replication settings
plugin-load = "group_replication.so;validate_password.so;semisync_master.so;semisync_slave.so"
loose_rpl_semi_sync_master_enabled = 1
loose_rpl_semi_sync_master_timeout = 3000
loose_rpl_semi_sync_slave_enabled = 1
##password plugin
validate_password_policy = STRONG
validate-password = FORCE_PLUS_PERMANENT
##perforamnce_schema settings
performance-schema-instrument='memory/%=COUNTED'
performance_schema_digests_size = 40000
performance_schema_max_table_handles = 40000
performance_schema_max_table_instances = 40000
performance_schema_max_sql_text_length = 4096
performance_schema_max_digest_length = 4096
[mysqld-5.6]
##metalock performance settings
metadata_locks_hash_instances = 64
[mysqld-5.7]
##new innodb settings
loose_innodb_numa_interleave = 1
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 16
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 2G
innodb_purge_rseg_truncate_frequency = 128
##new replication settings
slave-parallel-type = LOGICAL_CLOCK
slave-parallel-workers = 16
slave_preserve_commit_order = 1
slave_transaction_retries = 128
##other change settings
binlog_gtid_simple_recovery = 1
log_timestamps = system
show_compatibility_56 = on
##group replication settings
plugin-load = "group_replication.so;validate_password.so;semisync_master.so;semisync_slave.so"
transaction-write-set-extraction = XXHASH64
report_host = 127.0.0.1 # optional for group replication
binlog_checksum = NONE # only for group replication
loose_group_replication = FORCE_PLUS_PERMANENT
loose_group_replication_group_name = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
loose_group_replication_compression_threshold = 100
loose_group_replication_flow_control_mode = 0
loose_group_replication_single_primary_mode = 0
loose_group_replication_enforce_update_everywhere_checks = 1
loose_group_replication_transaction_size_limit = 10485760
loose_group_replication_unreachable_majority_timeout = 120
loose_group_replication_start_on_boot = 0
  •  几个重要参数配置和说明
    1. innodb_log_file_size = 4G:做实验可以小于这个值,线上环境推荐使用4G,以前5.55.1等版本之所以官方给的值很小,是因为太大后有bug,现bug已修复
    2. innodb_undo_logs = 128innodb_undo_tablespaces = 3建议在安装之前就确定好该值,后续修改比较麻烦
    3. [mysqld][mysqld-5.7]这种tag表明了下面的配置在什么版本下才生效,[mysqld]下均生效
    4. autocommit这个参数在5.5.X之后才有,安装5.6.X的时候要注意现把该参数注释掉,等安装完成后再打开。安装5.7.X无需注释
    5. datadirinnodb_log_group_home_dirinnodb_undo_directory一定要注意它的权限是mysql:mysql
  • my.cnf问题
    1. 使用mysqld --help -vv | grep my.cnf查看mysql的配置文件读取顺序
    2. 后读取的my.cnf中的配置,如果有相同项,会覆盖之前的配置
    3. 使用--default-files可指定配置文件

 

标签:log,mysql,介绍,replication,innodb,MySQL,mysqld,安装
From: https://www.cnblogs.com/gavin-zheng/p/17238434.html

相关文章

  • 1、Docker下安装mysql主从复制
    一、新建主服务实例容器挂载日志、数据、配置启动:dockerrun-p3307:3306--namemysql-master\-v/mydata/mysql-master/log:/var/log/mysql\-v/mydata/mysql-mas......
  • vue-element-admin安装趟坑
    1、下载源码2、执行npminstall--registry=https://registry.npm.taobao.org如果遇到"gitls-remote-h-t"之类的错误,执行以下代码:gitconfig--globalurl."htt......
  • Unbuntu22.04使用NVM安装NodeJS
    一、使用NVM(NodeVersionManager)1.在NVMgithub上的readme获取一行命令curl-o-https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh|bash或wge......
  • 02 Power Shell介绍
    PowerShell介绍特点win7以上默认安装脚本可以在内存中运行,不需要写入磁盘几乎不会出发杀软可以远程执行是windows脚本执行更容易cmd.exe的运行通常会被阻止,但是Po......
  • OpenWRT安装
    1.修改IMG镜像分区大小1-1.首先准备一个Linux系统,我是用workstation装的一个虚拟机来弄的,把要修改的IMG镜像用winscp或者其它工具上传到这个系统里,注意一下Ubuntu系统不要......
  • 第三方模块的安装
    内置模块不能满足我们的开发需求,因此,我们需要借助于第三方模块来实现一些更复杂的需求重点:第三方模块需要基于网络下载第三方模块的下载需要借助于pip工具(解释器Script......
  • amd64/UEFI/systemd/gnome/gentoo安装过程记录
    注意本人使用install-amd64-minimal-20220123T170538Z.isostage3-amd64-desktop-systemd-20220116T170534Z.tar.xz配置信息CPU:Inteli5-8300H(8)@4.000GHzGPU:NVIDIA......
  • docker安装minio
    拉取镜像dockerpullminio/minio创建容器dockerrun-d-p9000:9000--nameminio\-p9001:9001\-e'MINIO_ACCESS_KEY=minioadmin'\-e'MINIO_SECRET_KEY=......
  • 关于VMWare2.0上安装Windows Server 2003虚拟机无法识别网卡问题的求助
     VMwareTools的安装过程VMwareTools的安装程序事实上位于一个镜像文件里面(windows.iso),而且这个文件是和VMware主程序是在同一目录下的,首先我们要在CD-ROM这里把这个镜像......
  • Linux 硬盘存储和文件系统介绍
    一:硬盘存储1、存储类型根据存储的可以将存储分为内存和外存两类。内存:又叫做主存储器,计算机中所有程序的运行都是在内存中进行。外存:又叫做辅助存储器,因为内存容量......