MySQL8轻松新建管理多实例

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

#

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

#

# Remove the leading "# " to disable binary logging

# Binary logging captures changes between backups and is enabled by

# default. It's default setting is log_bin=binlog

# disable_log_bin

#

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

#

# Remove leading # to revert to previous value for default_authentication_plugin,

# this will increase compatibility with older clients. For background, see:

# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin

# default-authentication-plugin=mysql_native_password

##########################################

#mkdir  -p  /data/mysql

#mkdir  -p  /data/mysql_binlog

#mkdir  -p  /data/mysql_sys_temp_dir

#chown  -R mysql.mysql /data/mysql

#chown  -R mysql.mysql /data/mysql_binlog

#chown  -R mysql.mysql /data/mysql_sys_temp_dir

#chmod  755 /data/mysql

#chmod  755 /data/mysql_binlog

#chmod  755 /data/mysql_sys_temp_dir

##########################################

[mysql]

default_character_set  =utf8mb4

socket=/data/mysql/mysql.sock

[mysqld@01]

###0、 base DIR

################################################

port=3306

mysqlx_port=33060

lower_case_table_names=1

datadir=/data/mysql

mysqlx_socket=/data/mysql/mysqlx.sock

socket=/data/mysql/mysql.sock

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

skip_name_resolve=ON

###tmpdir 

tmpdir=/data/mysql_sys_temp_dir

innodb_tmpdir=/data/mysql_sys_temp_dir

slave_load_tmpdir=/data/mysql_sys_temp_dir

max_heap_table_size=2g

tmp_table_size=2g

###1、 slow    300ms

################################################

long_query_time=0.6

slow_query_log=ON

log_queries_not_using_indexes=OFF

slow_query_log_file=/data/mysql/localhost-slow.log

###2、binlog gtid\复制优化:

################################################

#expire-logs-days=7

#independ dir /data/mysql_binlog

log_bin=/data/mysql_binlog/binlog

log_bin_index=/data/mysql_binlog/binlog.index

binlog_expire_logs_seconds=604800

binlog_format = ROW

log_timestamps = SYSTEM

gtid-mode                = ON

enforce-gtid-consistency = ON

server_id = 1000

log-slave-updates=ON

skip_slave_start=ON

relay_log_recovery=ON

slave_preserve_commit_order=ON

slave-parallel-type=LOGICAL_CLOCK

slave-parallel-workers=16

binlog_transaction_dependency_tracking = WRITESET

###3、REDO日志缓冲、COMMIT参数:

################################################

## 大日志  800M

##【2000、20000、64000】

innodb_log_file_size = 800M

innodb_log_files_in_group = 5

max_binlog_size = 4096M

innodb_io_capacity  = 10000

innodb_io_capacity_max = 80000

innodb_log_buffer_size = 1024M

innodb_flush_log_at_trx_commit = 2

autocommit=ON

sync_binlog=200

#transaction-isolation=REPEATABLE-READ

transaction-isolation=READ-COMMITTED

####4、线程和调度类参数

################################################

innodb_thread_concurrency=192

thread_cache_size=256

innodb_read_io_threads=80

innodb_write_io_threads=64

innodb_purge_threads=8

#innodb_thread_sleep_delay = 1000

innodb_adaptive_max_sleep_delay=1200000

####5、buffer类参数  96g/128GB

################################################

innodb_buffer_pool_size = 16g

innodb_buffer_pool_instances=2

innodb_change_buffer_max_size = 50

innodb_sort_buffer_size=32M

innodb_max_dirty_pages_pct = 60

innodb_max_dirty_pages_pct_lwm = 10

###6、内存LRU算法相关:

################################################

innodb_old_blocks_pct = 25

innodb_old_blocks_time = 2000

innodb_lru_scan_depth = 4096

###7、索引等其他非典型参数

################################################

##innodb_flush_method = fsync 默认

innodb_use_native_aio = ON

innodb_adaptive_hash_index = ON

max_allowed_packet=1G

###8、表和文件参数

################################################

innodb_file_per_table=1

innodb_open_files=50000

table_open_cache =50000

table_definition_cache=50000

table_open_cache_instances=32

###9、超时与连接参数等其他参数:

################################################

max_connections=20000

max_connect_errors=10000

connect_timeout =8

interactive_timeout=1000

###10、字符集、排序:

################################################

character-set-server =utf8mb4

collation-server =utf8mb4_0900_as_cs

###11、安全密码:

################################################

local_infile=OFF

secure_file_priv=/data/mysql_sys_temp_dir

validate_password.length=10

validate_password.policy=MEDIUM

validate_password.special_char_count=2

validate_password.mixed_case_count=2

validate_password.number_count=2

##########################################

#mkdir  -p  /data/mysql02

#mkdir  -p  /data/mysql02_binlog

#mkdir  -p  /data/mysql02_sys_temp_dir

#chown  -R mysql.mysql /data/mysql02

#chown  -R mysql.mysql /data/mysql02_binlog

#chown  -R mysql.mysql /data/mysql02_sys_temp_dir

#chmod  755 /data/mysql02

#chmod  755 /data/mysql02_binlog

#chmod  755 /data/mysql02_sys_temp_dir

##########################################

[mysqld@02]

###0、 base DIR

################################################

port=3316

mysqlx_port=33160

lower_case_table_names=1

datadir=/data/mysql02

mysqlx_socket=/data/mysql02/mysqlx.sock

socket=/data/mysql02/mysql.sock

log-error=/var/log/mysqld02.log

pid-file=/var/run/mysqld/mysqld02.pid

skip_name_resolve=ON

###tmpdir 

tmpdir=/data/mysql02_sys_temp_dir

innodb_tmpdir=/data/mysql02_sys_temp_dir

slave_load_tmpdir=/data/mysql02_sys_temp_dir

max_heap_table_size=2g

tmp_table_size=2g

###1、 slow    300ms

################################################

long_query_time=0.6

slow_query_log=ON

log_queries_not_using_indexes=OFF

slow_query_log_file=/data/mysql02/localhost-slow.log

###2、binlog gtid\复制优化:

################################################

#expire-logs-days=7

#independ dir /data/mysql02_binlog

log_bin=/data/mysql02_binlog/binlog

log_bin_index=/data/mysql02_binlog/binlog.index

binlog_expire_logs_seconds=604800

binlog_format = ROW

log_timestamps = SYSTEM

gtid-mode                = ON

enforce-gtid-consistency = ON

server_id = 1000

log-slave-updates=ON

skip_slave_start=ON

relay_log_recovery=ON

slave_preserve_commit_order=ON

slave-parallel-type=LOGICAL_CLOCK

slave-parallel-workers=16

binlog_transaction_dependency_tracking = WRITESET

###3、REDO日志缓冲、COMMIT参数:

################################################

## 大日志  800M

##【2000、20000、64000】

innodb_log_file_size = 800M

innodb_log_files_in_group = 5

max_binlog_size = 4096M

innodb_io_capacity  = 10000

innodb_io_capacity_max = 80000

innodb_log_buffer_size = 1024M

innodb_flush_log_at_trx_commit = 2

autocommit=ON

sync_binlog=200

#transaction-isolation=REPEATABLE-READ

transaction-isolation=READ-COMMITTED

####4、线程和调度类参数

################################################

innodb_thread_concurrency=192

thread_cache_size=256

innodb_read_io_threads=80

innodb_write_io_threads=64

innodb_purge_threads=8

#innodb_thread_sleep_delay = 1000

innodb_adaptive_max_sleep_delay=1200000

####5、buffer类参数  96g/128GB

################################################

innodb_buffer_pool_size = 16g

innodb_buffer_pool_instances=2

innodb_change_buffer_max_size = 50

innodb_sort_buffer_size=32M

innodb_max_dirty_pages_pct = 60

innodb_max_dirty_pages_pct_lwm = 10

###6、内存LRU算法相关:

################################################

innodb_old_blocks_pct = 25

innodb_old_blocks_time = 2000

innodb_lru_scan_depth = 4096

###7、索引等其他非典型参数

################################################

##innodb_flush_method = fsync 默认

innodb_use_native_aio = ON

innodb_adaptive_hash_index = ON

max_allowed_packet=1G

###8、表和文件参数

################################################

innodb_file_per_table=1

innodb_open_files=50000

table_open_cache =50000

table_definition_cache=50000

table_open_cache_instances=32

###9、超时与连接参数等其他参数:

################################################

max_connections=20000

max_connect_errors=10000

connect_timeout =8

interactive_timeout=1000

###10、字符集、排序:

################################################

character-set-server =utf8mb4

collation-server =utf8mb4_0900_as_cs

###11、安全密码:

################################################

local_infile=OFF

secure_file_priv=/data/mysql02_sys_temp_dir

validate_password.length=10

validate_password.policy=MEDIUM

validate_password.special_char_count=2

validate_password.mixed_case_count=2

validate_password.number_count=2

Problem shoot:

###########################################################################################################

2019-12-04T17:17:48.335342+08:00 1 [Warning] [MY-012582] [InnoDB] io_setup() failed with EAGAIN. Will make 5 attempts before giving up.

2019-12-04T17:17:48.335549+08:00 1 [Warning] [MY-012583] [InnoDB] io_setup() attempt 1.

2019-12-04T17:17:48.835843+08:00 1 [Warning] [MY-012583] [InnoDB] io_setup() attempt 2.

2019-12-04T17:17:49.336174+08:00 1 [Warning] [MY-012583] [InnoDB] io_setup() attempt 3.

2019-12-04T17:17:49.836813+08:00 1 [Warning] [MY-012583] [InnoDB] io_setup() attempt 4.

2019-12-04T17:17:50.337818+08:00 1 [Warning] [MY-012583] [InnoDB] io_setup() attempt 5.

2019-12-04T17:17:50.838223+08:00 1 [ERROR] [MY-012584] [InnoDB] io_setup() failed with EAGAIN after 5 attempts.

2019-12-04T17:17:50.839214+08:00 1 [ERROR] [MY-012954] [InnoDB] Cannot initialize AIO sub-system

2019-12-04T17:17:50.839419+08:00 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.

2019-12-04T17:17:50.839611+08:00 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine

2019-12-04T17:17:50.840013+08:00 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.

2019-12-04T17:17:50.840325+08:00 0 [ERROR] [MY-010119] [Server] Aborting

2019-12-04T17:17:50.841661+08:00 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18)  MySQL Community Server - GPL.

2019-12-04T17:22:24.052559+08:00 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 10000 (requested 120010)

2019-12-04T17:22:24.052571+08:00 0 [Warning] [MY-010141] [Server] Changed limits: max_connections: 9190 (requested 20000)

2019-12-04T17:22:24.052578+08:00 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 400 (requested 50000)

2019-12-04T17:22:24.361227+08:00 0 [Warning] [MY-000081] [Server] option 'max_binlog_size': unsigned value 4294967296 adjusted to 1073741824.

2019-12-04T17:22:24.363094+08:00 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a differ

ent directory.

2019-12-04T17:22:24.363190+08:00 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 19965

2019-12-04T17:22:24.368825+08:00 0 [Warning] [MY-000081] [Server] option 'innodb-read-io-threads': unsigned value 80 adjusted to 64.

2019-12-04T17:22:24.368927+08:00 0 [Warning] [MY-000081] [Server] option 'innodb-adaptive-max-sleep-delay': unsigned value 1200000 adjusted to 1000000.

2019-12-04T17:22:24.369516+08:00 0 [Warning] [MY-012364] [InnoDB] innodb_open_files should not be greater than the open_files_limit.

2019-12-04T17:22:24.391582+08:00 1 [Warning] [MY-012197] [InnoDB] Unable to open './ops/000/tt7.ibd'

100 200 300 400 500 600 700 800

100 200 300 400 500 600 700 800

100 200 300 400 500 600 700 800

100 200 300 400 500 600 700 800

100 200 300 400 500 600 700 800

2019-12-04T17:23:04.344866+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2019-12-04T17:23:04.383581+08:00 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/data/mysql02/mysql.sock'  port: 3316  MySQL

Community Server - GPL.

2019-12-04T17:23:04.465324+08:00 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, another process with PID 16528 is u

sing UNIX socket file'

2019-12-04T17:23:04.465393+08:00 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33160

[root@qaserver120 log]#

解决:

################################

echo  "fs.aio-max-nr=262144" >>  /etc/sysctl.conf

sysctl -p

2019-12-04T17:34:28.301373+08:00 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 26348

2019-12-04T17:34:28.308510+08:00 0 [Warning] [MY-000081] [Server] option 'innodb-read-io-threads': unsigned value 80 adjusted to 64.

2019-12-04T17:34:28.308652+08:00 0 [Warning] [MY-000081] [Server] option 'innodb-adaptive-max-sleep-delay': unsigned value 1200000 adjusted to 1000000.

2019-12-04T17:34:28.309514+08:00 0 [Warning] [MY-012364] [InnoDB] innodb_open_files should not be greater than the open_files_limit.

2019-12-04T17:34:28.392497+08:00 1 [ERROR] [MY-012209] [InnoDB] Multiple files found for the same tablespace ID:

2019-12-04T17:34:28.392786+08:00 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 97 = ['ops/000/tt7.ibd', 'ops2/tt7.ibd']

2019-12-04T17:34:28.393228+08:00 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Failed, retry may succeed.

2019-12-04T17:34:28.393420+08:00 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine

2019-12-04T17:34:28.393786+08:00 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.

2019-12-04T17:34:28.394080+08:00 0 [ERROR] [MY-010119] [Server] Aborting

2019-12-04T17:34:28.395139+08:00 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18)  MySQL Community Server - GPL.

解决:

ops/000/tt7.ibd 是copy的表空间文件

###############################################

Multiple files found for the same tablespace ID:

删除即可,重复了

###################################################################

##################################################################

2019-12-05T11:13:24.574282+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2019-12-05T11:13:24.583081+08:00 0 [ERROR] [MY-000067] [Server] unknown variable 'validate_password.length=16'.

2019-12-05T11:13:24.583675+08:00 0 [ERROR] [MY-010119] [Server] Aborting

2019-12-05T11:13:25.866908+08:00 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18)  MySQL Community Server - GPL.

##############################################################################

数据库初始化方法不正确,导致组件没有启用, 下面的不存在:

component_id  component_group_id  component_urn                     

------------  ------------------  ------------------------------------

          1                  1  file://component_validate_password 

###################################################################

##################################################################

2019-12-04T17:37:23.214806+08:00 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 10000 (requested 120010)

2019-12-04T17:37:23.214832+08:00 0 [Warning] [MY-010141] [Server] Changed limits: max_connections: 9190 (requested 20000)

2019-12-04T17:37:23.214844+08:00 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 400 (requested 50000)

2019-12-04T17:37:23.530512+08:00 0 [Warning] [MY-000081] [Server] option 'max_binlog_size': unsigned value 4294967296 adjusted to 1073741824.

2019-12-04T17:37:23.532496+08:00 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.

2019-12-04T17:37:23.532607+08:00 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 27784

2019-12-04T17:37:23.538549+08:00 0 [Warning] [MY-000081] [Server] option 'innodb-read-io-threads': unsigned value 80 adjusted to 64.

2019-12-04T17:37:23.538729+08:00 0 [Warning] [MY-000081] [Server] option 'innodb-adaptive-max-sleep-delay': unsigned value 1200000 adjusted to 1000000.

2019-12-04T17:37:23.539438+08:00 0 [Warning] [MY-012364] [InnoDB] innodb_open_files should not be greater than the open_files_limit.

2019-12-04T17:37:25.867148+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2019-12-04T17:37:25.914579+08:00 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/data/mysql02/mysql.sock'  port: 3316  MySQL Community Server - GPL.

2019-12-04T17:37:25.977604+08:00 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, another process with PID 16528 is using UNIX socket file'

2019-12-04T17:37:25.977762+08:00 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33160

[ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed,

another process with PID 16528 is using UNIX socket file'

##############################################################################################################

解决:

mysqlx.sock在同一个服务器上重复了

###############################################

mysql> show variables  like '%socket%';

+-----------------------------------------+-----------------------------+

| Variable_name                          | Value                      |

+-----------------------------------------+-----------------------------+

| mysqlx_socket                          | /var/run/mysqld/mysqlx.sock |

| performance_schema_max_socket_classes  | 10                          |

| performance_schema_max_socket_instances | -1                          |

| socket                                  | /data/mysql/mysql.sock      |

+-----------------------------------------+-----------------------------+

4 rows in set (0.01 sec)

mysql>

[root@qaserver120 log]# netstat -anp |grep "3306\|3316"

tcp6      0      0 :::33160                :::*                    LISTEN      31936/mysqld       

tcp6      0      0 :::3306                :::*                    LISTEN      16528/mysqld       

tcp6      0      0 :::3316                :::*                    LISTEN      31936/mysqld       

tcp6      0      0 :::33060                :::*                    LISTEN      16528/mysqld       

[root@qaserver120 log]#

解决后,日志:

[System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/data/mysql02/mysqlx.sock' bind-address: '::' port: 33160

###############################################

2019-12-04T17:43:50.006244+08:00 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18)  MySQL Community Server - GPL.

2019-12-04T17:43:52.499102+08:00 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 10000 (requested 120010)

2019-12-04T17:43:52.499116+08:00 0 [Warning] [MY-010141] [Server] Changed limits: max_connections: 9190 (requested 20000)

2019-12-04T17:43:52.499123+08:00 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 400 (requested 50000)

2019-12-04T17:43:52.844200+08:00 0 [Warning] [MY-000081] [Server] option 'max_binlog_size': unsigned value 4294967296 adjusted to 1073741824.

2019-12-04T17:43:52.846443+08:00 0 [Warning] [MY-010101] [Server] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.

2019-12-04T17:43:52.846571+08:00 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 31936

2019-12-04T17:43:52.854371+08:00 0 [Warning] [MY-000081] [Server] option 'innodb-read-io-threads': unsigned value 80 adjusted to 64.

2019-12-04T17:43:52.854510+08:00 0 [Warning] [MY-000081] [Server] option 'innodb-adaptive-max-sleep-delay': unsigned value 1200000 adjusted to 1000000.

2019-12-04T17:43:52.855436+08:00 0 [Warning] [MY-012364] [InnoDB] innodb_open_files should not be greater than the open_files_limit.

2019-12-04T17:43:54.944605+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2019-12-04T17:43:54.981407+08:00 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/data/mysql02/mysql.sock'  port: 3316  MySQL Community Server - GPL.

2019-12-04T17:43:55.028545+08:00 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/data/mysql02/mysqlx.sock' bind-address: '::' port: 33160

###############################################

不同子目录不能有相同的idb文件,rm就搞定

###############################################

[root@txy93 log]# tail  mysqld.log

2019-12-05T13:48:49.231955+08:00 0 [Warning] [MY-012364] [InnoDB] innodb_open_files should not be greater than the open_files_limit.

2019-12-05T13:48:49.312062+08:00 1 [ERROR] [MY-012209] [InnoDB] Multiple files found for the same tablespace ID:

2019-12-05T13:48:49.312192+08:00 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 97 = ['ops/000/tt7.ibd', 'ops2/tt7.ibd']

2019-12-05T13:48:49.312448+08:00 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Failed, retry may succeed.

2019-12-05T13:48:49.312576+08:00 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine

2019-12-05T13:48:49.312872+08:00 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.

2019-12-05T13:48:49.313085+08:00 0 [ERROR] [MY-010119] [Server] Aborting

2019-12-05T13:48:49.314105+08:00 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.18)  MySQL Community Server - GPL.

[root@txy93 log]#

###############################################

###############################################

mysql>

mysql> revoke all on sys.* from 'dbuer'@'%';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql>

mysql>

mysql> revoke all on ops.* from 'dbuer'@'%';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> revoke all on ops.* from 'dbuser'@'%';

ERROR 1141 (42000): There is no such grant defined for user 'dbuser' on host '%'

mysql>

mysql> revoke all on ops2.* from 'dbuser'@'%';

ERROR 1141 (42000): There is no such grant defined for user 'dbuser' on host '%'

mysql>

###############################################

实际上是写错了用户名'dbuer'@'%'

###############################################

[root@txy93 mysql02]#

[root@txy93 mysql02]# netstat  -anp |grep mysqld

tcp6      0      0 :::33160                :::*                    LISTEN      30073/mysqld       

tcp6      0      0 :::3306                :::*                    LISTEN      11076/mysqld       

tcp6      0      0 :::3316                :::*                    LISTEN      30073/mysqld       

tcp6      0      0 :::33060                :::*                    LISTEN      11076/mysqld       

tcp6      0      0 172.31.71.93:3316      103.113.60.164:56999    ESTABLISHED 30073/mysqld       

tcp6      0      0 172.31.71.93:3316      103.113.60.164:20770    ESTABLISHED 30073/mysqld       

unix  2      [ ACC ]    STREAM    LISTENING    2542510600 30073/mysqld        /data/mysql02/mysql.sock

unix  2      [ ACC ]    STREAM    LISTENING    2542509812 30073/mysqld        /data/mysql02/mysqlx.sock

unix  2      [ ACC ]    STREAM    LISTENING    2542415841 11076/mysqld        /data/mysql/mysql.sock

unix  2      [ ACC ]    STREAM    LISTENING    2542425633 11076/mysqld        /data/mysql/mysqlx.sock

unix  2      [ ]        DGRAM                    2542472171 30073/mysqld       

unix  2      [ ]        DGRAM                    2542415769 11076/mysqld       

MySQL8.0多实例管理

###############################################

systemctl enable mysqld@01

systemctl enable mysqld@02

systemctl daemon-reload

systemctl daemon-reload

systemctl start mysqld@01

systemctl start mysqld@02

systemctl status mysqld@01

systemctl status mysqld@02

systemctl stop mysqld@01

systemctl stop mysqld@02

systemctl restart mysqld@01

systemctl restart mysqld@02

systemctl status mysqld@01

systemctl status mysqld@02

netstat -anp |grep "3306\|3316"

netstat -anp |grep "3306\|3316"

netstat  -anp |grep mysqld

netstat  -anp |grep mysqld

###############################################

47.56.108.174  双实例环境

yum  install  -y    /pkg/mysql-community*rpm

##########################################

mkdir  -p  /data/mysql

mkdir  -p  /data/mysql_binlog

mkdir  -p  /data/mysql_sys_temp_dir

chown  -R mysql.mysql /data/mysql

chown  -R mysql.mysql /data/mysql_binlog

chown  -R mysql.mysql /data/mysql_sys_temp_dir

chmod  755 /data/mysql

chmod  755 /data/mysql_binlog

chmod  755 /data/mysql_sys_temp_dir

##########################################

##########################################

mkdir  -p  /data/mysql02

mkdir  -p  /data/mysql02_binlog

mkdir  -p  /data/mysql02_sys_temp_dir

chown  -R mysql.mysql /data/mysql02

chown  -R mysql.mysql /data/mysql02_binlog

chown  -R mysql.mysql /data/mysql02_sys_temp_dir

chmod  755 /data/mysql02

chmod  755 /data/mysql02_binlog

chmod  755 /data/mysql02_sys_temp_dir

##########################################

chown  -R mysql.mysql /data/mysql02

chown  -R mysql.mysql /data/mysql

scp -i  id111.pem    mysql-community*rpm    172.31.71.93:/pkg

scp -i  id111.pem    -r /data/mysql/*    172.31.71.93:/data/mysql/

  scp -i  id111.pem    -r /data/mysql02/*      172.31.71.93:/data/mysql02/

*//

[root@txy93 data]# systemctl enable mysqld@01

systemctl enable mysqld@02

Created symlink from /etc/systemd/system/multi-user.target.wants/[email protected] to /usr/lib/systemd/system/[email protected].

systemctl start mysqld@01[root@txy93 data]# systemctl enable mysqld@02

Created symlink from /etc/systemd/system/multi-user.target.wants/[email protected] to /usr/lib/systemd/system/[email protected].

[root@txy93 data]#

[root@txy93 data]#

/etc/systemd/system/multi-user.target.wants/[email protected]

sed -i 's/LimitNOFILE = 10000/LimitNOFILE = 320000/g'  /etc/systemd/system/multi-user.target.wants/[email protected]

sed -i 's/LimitNOFILE = 200000/LimitNOFILE = 320000/g'  /etc/systemd/system/multi-user.target.wants/[email protected]

cat    /etc/systemd/system/multi-user.target.wants/[email protected] |grep  LimitNOFILE

sed -i 's/LimitNOFILE = 10000/LimitNOFILE = 320000/g'  /etc/systemd/system/multi-user.target.wants/[email protected]

sed -i 's/LimitNOFILE = 200000/LimitNOFILE = 320000/g'  /etc/systemd/system/multi-user.target.wants/[email protected]

cat  /etc/systemd/system/multi-user.target.wants/[email protected]|grep  LimitNOFILE

systemctl daemon-reload

systemctl daemon-reload





mysql> set autocommit=OFF;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> START TRANSACTION

    -> ;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> SELECT COUNT(*) FROM  dt_game_data.round  ;

+----------+

| COUNT(*) |

+----------+

|  779247 |

+----------+

1 row in set (0.03 sec)

mysql>

mysql> SELECT COUNT(*) FROM  dt_game_data.round_card ;

SELECT COUNT(*) FROM  dt_game_data.round  WHERE created_at <='2019-12-1';

+----------+

| COUNT(*) |

+----------+

|  3876744 |

+----------+

1 row in set (0.09 sec)

mysql>

mysql>

mysql> SELECT COUNT(*) FROM  dt_game_data.round  WHERE created_at <='2019-12-1';

SELECT COUNT(*) FROM  dt_game_data.round_card  WHERE created_at <='2019-12-1';+----------+

| COUNT(*) |

+----------+

|  682691 |

+----------+

1 row in set (0.15 sec)

mysql>

mysql>

mysql> SELECT COUNT(*) FROM  dt_game_data.round_card  WHERE created_at <='2019-12-1';

+----------+

| COUNT(*) |

+----------+

|  3432773 |

+----------+

1 row in set (0.66 sec)

mysql>

mysql> DELETE    FROM  dt_game_data.round  WHERE created_at <='2019-12-1';

Query OK, 682691 rows affected (22.99 sec)

mysql>

mysql>

mysql> COMMIT;

Query OK, 0 rows affected (2.99 sec)

mysql>

mysql>  set autocommit=OFF;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> 

mysql>  START TRANSACTION ;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql>

mysql> DELETE  FROM  dt_game_data.round_card  WHERE created_at <='2019-12-1';

Query OK, 3432773 rows affected (2 min 30.32 sec)

mysql>  SELECT COUNT(*) FROM  dt_game_data.round_card;

+----------+

| COUNT(*) |

+----------+

|  444506 |

+----------+

1 row in set (0.06 sec)

mysql> commit;

Query OK, 0 rows affected (6.03 sec)

mysql>  SELECT COUNT(*) FROM  dt_game_data.round_card;

+----------+

| COUNT(*) |

+----------+

|  444860 |

+----------+

1 row in set (0.02 sec)

mysql>

mysql>

mysql>

mysql>  SELECT COUNT(*) FROM  dt_game_data.round_card;

+----------+

| COUNT(*) |

+----------+

|  445078 |

+----------+

1 row in set (0.01 sec)

mysql> commit;

Query OK, 0 rows affected (0.00 sec)

mysql>

你可能感兴趣的:(MySQL8轻松新建管理多实例)