《上古卷軸5》NPC外貌Mod釋出 妹子們更漂亮了
MySQL多例項
一、什麼是MySQL多例項
MySQL的多例項就是在一臺機器上開啟多個不同的服務埠,執行多個MySQL服務程序,使用不同的socket來監聽這多個不同的埠以此提供服務,這一點和Oracle的多例項類似。這些MySQL的例項共用相同的MySQL但是使用的引數檔案是不一樣的,相應的資料檔案也不同。提供服務的時候從邏輯上看各自獨立,各自獲取的硬體資源可以靈活設定。
二、MySQL多例項優劣勢
- 有效的利用伺服器資源。當單個伺服器的資源有剩餘的時候可以將多餘的資源有效的利用起來,而且還實現了資源的邏輯隔離。
- 節約經濟消耗。例如需要多個數據庫來搭建主從,但是又只有一臺伺服器。
- 當單個數據庫併發很高或計算資源需求很高時。整個例項會消耗大量系統的CPU,IO等資源。這樣其他例項的可利用資源就會變少產生問題。無法實現例項資源的絕對隔離。
三、如何部署MySQL多例項
部署的方式有兩種:
1.使用mysqld_multi工具,用單獨的配置檔案實現多例項配置複雜但是管理方便。
2.設定多個配置檔案啟動,這樣啟動不同程序實現多例項。原理簡單,但是不易管理。
mysql軟體包網址:https://downloads.mysql.com/archives/community/
mysql多例項部署例項
1、下載mysql壓縮包拉進/usr/src下面 [root@localhost ~]# cd /usr/src/ [root@localhost src]# ls debug kernels mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz 2、解壓軟體至/usr/local [root@localhost src]# tar xf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ [root@localhost src]# cd .. [root@localhost usr]# cd local/ [root@localhost local]# ls bin games lib libexec sbin src etc include lib64 mysql-5.7.34-linux-glibc2.12-x86_64 share 3、做一個軟連線 [root@localhost local]# ln -s /usr/local/mysql-5.7.34-linux-glibc2.12-x86_64/ /usr/local/mysql [root@localhost local]# ll 總用量 0 drwxr-xr-x. 2 root root 6 8月 12 2018 bin drwxr-xr-x. 2 root root 6 8月 12 2018 etc drwxr-xr-x. 2 root root 6 8月 12 2018 games drwxr-xr-x. 2 root root 6 8月 12 2018 include drwxr-xr-x. 2 root root 6 8月 12 2018 lib drwxr-xr-x. 2 root root 6 8月 12 2018 lib64 drwxr-xr-x. 2 root root 6 8月 12 2018 libexec lrwxrwxrwx. 1 root root 47 8月 29 20:23 mysql -> /usr/local/mysql-5.7.34-linux-glibc2.12-x86_64/ drwxr-xr-x. 9 root root 129 8月 29 20:19 mysql-5.7.34-linux-glibc2.12-x86_64 drwxr-xr-x. 2 root root 6 8月 12 2018 sbin drwxr-xr-x. 5 root root 49 8月 24 23:44 share drwxr-xr-x. 2 root root 6 8月 12 2018 src 4、建立使用者和組及修改屬主屬組 [root@localhost src]# useradd -r -M -s /sbin/nologin mysql [root@localhost src]# grep mysql /etc/group mysql:x:975: [root@localhost local]# chown -R mysql.mysql mysql* [root@localhost local]# ll 總用量 0 drwxr-xr-x. 2 root root 6 8月 12 2018 bin drwxr-xr-x. 2 root root 6 8月 12 2018 etc drwxr-xr-x. 2 root root 6 8月 12 2018 games drwxr-xr-x. 2 root root 6 8月 12 2018 include drwxr-xr-x. 2 root root 6 8月 12 2018 lib drwxr-xr-x. 2 root root 6 8月 12 2018 lib64 drwxr-xr-x. 2 root root 6 8月 12 2018 libexec lrwxrwxrwx. 1 mysql mysql 47 8月 29 20:30 mysql -> /usr/local/mysql-5.7.34-linux-glibc2.12-x86_64/ drwxr-xr-x. 9 mysql mysql 129 8月 29 20:29 mysql-5.7.34-linux-glibc2.12-x86_64 drwxr-xr-x. 2 root root 6 8月 12 2018 sbin drwxr-xr-x. 5 root root 49 8月 24 23:44 share drwxr-xr-x. 2 root root 6 8月 12 2018 src 5、新增環境變數 [root@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh [root@localhost ~]# . /etc/profile.d/mysql.sh [root@localhost ~]# echo $PATH /usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@localhost ~]#
建立各例項資料事件的目錄
[root@localhost ~]# mkdir -p /opt/data/{3306,3307,3308} [root@localhost ~]# chown -R mysql.mysql /opt/data/ [root@localhost ~]# ll /opt/data/ 總用量 0 drwxr-xr-x. 2 mysql mysql 6 8月 29 20:39 3306 drwxr-xr-x. 2 mysql mysql 6 8月 29 20:39 3307 drwxr-xr-x. 2 mysql mysql 6 8月 29 20:39 3308 [root@localhost ~]# tree /opt/data/ /opt/data/ ├── 3306 ├── 3307 └── 3308 3 directories, 0 files
初始化各例項
[root@localhost ~]# mysqld --lnitialize --user mysql --datadir /opt/data/3306
2021-08-29T12:54:52.708476Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-29T12:54:52.708527Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-08-29T12:54:52.708542Z 0 [Note] mysqld (mysqld 5.7.34) starting as process 28779 ...
2021-08-29T12:54:52.723568Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-08-29T12:54:52.723603Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-08-29T12:54:52.723605Z 0 [Note] InnoDB: Uses event mutexes
2021-08-29T12:54:52.723607Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2021-08-29T12:54:52.723609Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-08-29T12:54:52.723611Z 0 [Note] InnoDB: Using Linux native AIO
2021-08-29T12:54:52.723819Z 0 [Note] InnoDB: Number of pools: 1
2021-08-29T12:54:52.723929Z 0 [Note] InnoDB: Using CPU crc32 instructions
2021-08-29T12:54:52.727696Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-08-29T12:54:52.740779Z 0 [Note] InnoDB: Completed initialization of buffer pool
2021-08-29T12:54:52.744859Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-08-29T12:54:52.761937Z 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2021-08-29T12:54:52.762292Z 0 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2021-08-29T12:54:52.788277Z 0 [Note] InnoDB: File './ibdata1' size is now 12 MB.
2021-08-29T12:54:52.788590Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2021-08-29T12:54:52.873092Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2021-08-29T12:54:52.950079Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2021-08-29T12:54:52.950168Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-08-29T12:54:52.950180Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-08-29T12:54:52.950338Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-08-29T12:54:52.961626Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-08-29T12:54:52.961744Z 0 [Note] InnoDB: Doublewrite buffer not found: creating new
2021-08-29T12:54:52.966460Z 0 [Note] InnoDB: Doublewrite buffer created
2021-08-29T12:54:52.970928Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2021-08-29T12:54:52.970937Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2021-08-29T12:54:52.971295Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-08-29T12:54:52.976621Z 0 [Note] InnoDB: Foreign key constraint system tables created
2021-08-29T12:54:52.976654Z 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2021-08-29T12:54:52.977082Z 0 [Note] InnoDB: Tablespace and datafile system tables created.
2021-08-29T12:54:52.977098Z 0 [Note] InnoDB: Creating sys_virtual system tables.
2021-08-29T12:54:52.977295Z 0 [Note] InnoDB: sys_virtual table created
2021-08-29T12:54:52.977490Z 0 [Note] InnoDB: Waiting for purge to start
2021-08-29T12:54:53.028210Z 0 [Note] InnoDB: 5.7.34 started; log sequence number 0
2021-08-29T12:54:53.029092Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2021-08-29T12:54:53.029185Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2021-08-29T12:54:53.029243Z 0 [ERROR] unknown option '--lnitialize'
2021-08-29T12:54:53.029247Z 0 [ERROR] Aborting
2021-08-29T12:54:53.029250Z 0 [Note] Binlog end
2021-08-29T12:54:53.029274Z 0 [Note] Shutting down plugin 'ngram'
2021-08-29T12:54:53.029277Z 0 [Note] Shutting down plugin 'partition'
2021-08-29T12:54:53.029279Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2021-08-29T12:54:53.029281Z 0 [Note] Shutting down plugin 'ARCHIVE'
2021-08-29T12:54:53.029282Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2021-08-29T12:54:53.029304Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2021-08-29T12:54:53.029305Z 0 [Note] Shutting down plugin 'MyISAM'
2021-08-29T12:54:53.029311Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2021-08-29T12:54:53.029312Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2021-08-29T12:54:53.029314Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2021-08-29T12:54:53.029315Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2021-08-29T12:54:53.029316Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2021-08-29T12:54:53.029317Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2021-08-29T12:54:53.029318Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2021-08-29T12:54:53.029319Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2021-08-29T12:54:53.029320Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2021-08-29T12:54:53.029321Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2021-08-29T12:54:53.029323Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2021-08-29T12:54:53.029324Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2021-08-29T12:54:53.029325Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2021-08-29T12:54:53.029326Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2021-08-29T12:54:53.029327Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2021-08-29T12:54:53.029328Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2021-08-29T12:54:53.029329Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2021-08-29T12:54:53.029330Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2021-08-29T12:54:53.029331Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2021-08-29T12:54:53.029332Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2021-08-29T12:54:53.029334Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2021-08-29T12:54:53.029335Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2021-08-29T12:54:53.029336Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2021-08-29T12:54:53.029337Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2021-08-29T12:54:53.029338Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2021-08-29T12:54:53.029339Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2021-08-29T12:54:53.029340Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2021-08-29T12:54:53.029341Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2021-08-29T12:54:53.029342Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2021-08-29T12:54:53.029343Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2021-08-29T12:54:53.029344Z 0 [Note] Shutting down plugin 'InnoDB'
2021-08-29T12:54:53.029664Z 0 [Note] InnoDB: FTS optimize thread exiting.
2021-08-29T12:54:53.030052Z 0 [Note] InnoDB: Starting shutdown...
2021-08-29T12:54:53.130850Z 0 [Note] InnoDB: Dumping buffer pool(s) to /opt/data/3306/ib_buffer_pool
2021-08-29T12:54:53.130967Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 210829 20:54:53
2021-08-29T12:54:54.643890Z 0 [Note] InnoDB: Shutdown completed; log sequence number 1209961
2021-08-29T12:54:54.644295Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2021-08-29T12:54:54.644304Z 0 [Note] Shutting down plugin 'MEMORY'
2021-08-29T12:54:54.644307Z 0 [Note] Shutting down plugin 'CSV'
2021-08-29T12:54:54.644310Z 0 [Note] Shutting down plugin 'sha256_password'
2021-08-29T12:54:54.644311Z 0 [Note] Shutting down plugin 'mysql_native_password'
2021-08-29T12:54:54.644455Z 0 [Note] Shutting down plugin 'binlog'
2021-08-29T12:54:54.644540Z 0 [Note] mysqld: Shutdown complete
[root@localhost ~]# echo 'jf:*4eh;*jq5' > 6pass
[root@localhost ~]# mysqld --lnitialize --user mysql --datadir /opt/data/3307
mysqld: Can't change dir to '/opt/data/3307/' (Errcode: 2 - No such file or directory)
2021-08-29T12:55:02.120394Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-29T12:55:02.120451Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-08-29T12:55:02.120464Z 0 [Note] mysqld (mysqld 5.7.34) starting as process 29102 ...
2021-08-29T12:55:02.121687Z 0 [Warning] Can't create test file /opt/data/3307/localhost.lower-test
2021-08-29T12:55:02.121696Z 0 [Warning] Can't create test file /opt/data/3307/localhost.lower-test
2021-08-29T12:55:02.123527Z 0 [ERROR] failed to set datadir to /opt/data/3307/
2021-08-29T12:55:02.123534Z 0 [ERROR] Aborting
2021-08-29T12:55:02.123537Z 0 [Note] Binlog end
2021-08-29T12:55:02.123552Z 0 [Note] mysqld: Shutdown complete
[root@localhost ~]# echo 'jf:*4eh;*jq5' > 7pass
[root@localhost ~]# mysqld --lnitialize --user mysql --datadir /opt/data/3308
2021-08-29T12:55:18.711442Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-29T12:55:18.711493Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-08-29T12:55:18.711505Z 0 [Note] mysqld (mysqld 5.7.34) starting as process 29565 ...
2021-08-29T12:55:18.718185Z 0 [Note] InnoDB: PUNCH HOLE support available
2021-08-29T12:55:18.718197Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-08-29T12:55:18.718199Z 0 [Note] InnoDB: Uses event mutexes
2021-08-29T12:55:18.718201Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2021-08-29T12:55:18.718203Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-08-29T12:55:18.718204Z 0 [Note] InnoDB: Using Linux native AIO
2021-08-29T12:55:18.718324Z 0 [Note] InnoDB: Number of pools: 1
2021-08-29T12:55:18.718373Z 0 [Note] InnoDB: Using CPU crc32 instructions
2021-08-29T12:55:18.720380Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-08-29T12:55:18.724890Z 0 [Note] InnoDB: Completed initialization of buffer pool
2021-08-29T12:55:18.727710Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-08-29T12:55:18.736462Z 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
2021-08-29T12:55:18.736654Z 0 [Note] InnoDB: Setting file './ibdata1' size to 12 MB. Physically writing the file full; Please wait ...
2021-08-29T12:55:18.749680Z 0 [Note] InnoDB: File './ibdata1' size is now 12 MB.
2021-08-29T12:55:18.749898Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2021-08-29T12:55:18.814710Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2021-08-29T12:55:18.881061Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2021-08-29T12:55:18.881097Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-08-29T12:55:18.881104Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-08-29T12:55:18.881141Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-08-29T12:55:18.896581Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-08-29T12:55:18.896716Z 0 [Note] InnoDB: Doublewrite buffer not found: creating new
2021-08-29T12:55:18.901884Z 0 [Note] InnoDB: Doublewrite buffer created
2021-08-29T12:55:18.907194Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2021-08-29T12:55:18.907212Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2021-08-29T12:55:18.907363Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-08-29T12:55:18.908983Z 0 [Note] InnoDB: Foreign key constraint system tables created
2021-08-29T12:55:18.909001Z 0 [Note] InnoDB: Creating tablespace and datafile system tables.
2021-08-29T12:55:18.909437Z 0 [Note] InnoDB: Tablespace and datafile system tables created.
2021-08-29T12:55:18.909453Z 0 [Note] InnoDB: Creating sys_virtual system tables.
2021-08-29T12:55:18.909710Z 0 [Note] InnoDB: sys_virtual table created
2021-08-29T12:55:18.910051Z 0 [Note] InnoDB: Waiting for purge to start
2021-08-29T12:55:18.960607Z 0 [Note] InnoDB: 5.7.34 started; log sequence number 0
2021-08-29T12:55:18.961062Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2021-08-29T12:55:18.961138Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2021-08-29T12:55:18.961266Z 0 [ERROR] unknown option '--lnitialize'
2021-08-29T12:55:18.961273Z 0 [ERROR] Aborting
2021-08-29T12:55:18.961277Z 0 [Note] Binlog end
2021-08-29T12:55:18.961317Z 0 [Note] Shutting down plugin 'ngram'
2021-08-29T12:55:18.961320Z 0 [Note] Shutting down plugin 'partition'
2021-08-29T12:55:18.961321Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2021-08-29T12:55:18.961323Z 0 [Note] Shutting down plugin 'ARCHIVE'
2021-08-29T12:55:18.961324Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2021-08-29T12:55:18.961345Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2021-08-29T12:55:18.961367Z 0 [Note] Shutting down plugin 'MyISAM'
2021-08-29T12:55:18.961374Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2021-08-29T12:55:18.961376Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2021-08-29T12:55:18.961377Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2021-08-29T12:55:18.961378Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2021-08-29T12:55:18.961380Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2021-08-29T12:55:18.961396Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2021-08-29T12:55:18.961397Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2021-08-29T12:55:18.961398Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2021-08-29T12:55:18.961399Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2021-08-29T12:55:18.961400Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2021-08-29T12:55:18.961401Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2021-08-29T12:55:18.961402Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2021-08-29T12:55:18.961403Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2021-08-29T12:55:18.961425Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2021-08-29T12:55:18.961426Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2021-08-29T12:55:18.961428Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2021-08-29T12:55:18.961429Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2021-08-29T12:55:18.961430Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2021-08-29T12:55:18.961431Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2021-08-29T12:55:18.961433Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2021-08-29T12:55:18.961450Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2021-08-29T12:55:18.961451Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2021-08-29T12:55:18.961453Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2021-08-29T12:55:18.961454Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2021-08-29T12:55:18.961455Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2021-08-29T12:55:18.961456Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2021-08-29T12:55:18.961457Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2021-08-29T12:55:18.961479Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2021-08-29T12:55:18.961480Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2021-08-29T12:55:18.961482Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2021-08-29T12:55:18.961483Z 0 [Note] Shutting down plugin 'InnoDB'
2021-08-29T12:55:18.961828Z 0 [Note] InnoDB: FTS optimize thread exiting.
2021-08-29T12:55:18.962093Z 0 [Note] InnoDB: Starting shutdown...
2021-08-29T12:55:19.063555Z 0 [Note] InnoDB: Dumping buffer pool(s) to /opt/data/3308/ib_buffer_pool
2021-08-29T12:55:19.063674Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 210829 20:55:19
2021-08-29T12:55:20.577541Z 0 [Note] InnoDB: Shutdown completed; log sequence number 1209961
2021-08-29T12:55:20.577997Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2021-08-29T12:55:20.578007Z 0 [Note] Shutting down plugin 'MEMORY'
2021-08-29T12:55:20.578010Z 0 [Note] Shutting down plugin 'CSV'
2021-08-29T12:55:20.578014Z 0 [Note] Shutting down plugin 'sha256_password'
2021-08-29T12:55:20.578015Z 0 [Note] Shutting down plugin 'mysql_native_password'
2021-08-29T12:55:20.578101Z 0 [Note] Shutting down plugin 'binlog'
2021-08-29T12:55:20.578264Z 0 [Note] mysqld: Shutdown complete
[root@localhost ~]# echo 'jf:*4eh;*jq5' > 8pass
[root@localhost ~]# ls
6pass 8pass 模板 圖片 下載 桌面 initial-setup-ks.cfg
7pass 公共 視訊 文件 音樂 anaconda-ks.cfg
[root@localhost ~]#
安裝prel
[root@localhost ~]# yum -y install perl
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
AppStream 3.1 MB/s | 3.2 kB 00:00
BaseOS 2.7 MB/s | 2.7 kB 00:00
依賴關係解決。
=====================================================================================
軟體包 架構 版本 倉庫 大小
=====================================================================================
Installing:
安裝mysql命令
[root@localhost ~]# ldd /usr/local/mysql/bin/mysql
linux-vdso.so.1 (0x00007ffdfef3a000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa19ea4a000)
librt.so.1 => /lib64/librt.so.1 (0x00007fa19e841000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fa19e63d000)
libncurses.so.5 => not found
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fa19e2a8000)
libm.so.6 => /lib64/libm.so.6 (0x00007fa19df26000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fa19dd0e000)
libc.so.6 => /lib64/libc.so.6 (0x00007fa19d94a000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa19ec6a000)
libtinfo.so.5 => not found
[root@localhost ~]# yum whatprovides libncurses.so.5
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元資料過期檢查:0:02:11 前,執行於 2021年08月29日 星期日 20時56分40秒。
ncurses-compat-libs-6.1-7.20180224.el8.i686 : Ncurses compatibility libraries
倉庫 :BaseOS
匹配來源:
提供 : libncurses.so.5
[root@localhost ~]# yum whatprovides libtinfo.so.5
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元資料過期檢查:0:02:33 前,執行於 2021年08月29日 星期日 20時56分40秒。
ncurses-compat-libs-6.1-7.20180224.el8.i686 : Ncurses compatibility libraries
倉庫 :BaseOS
匹配來源:
提供 : libtinfo.so.5
[root@localhost ~]# yum -y install ncurses-compat-libs
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元資料過期檢查:0:02:48 前,執行於 2021年08月29日 星期日 20時56分40秒。
依賴關係解決。
====================================================================================
軟體包 架構 版本 倉庫 大小
====================================================================================
Installing:
ncurses-compat-libs x86_64 6.1-7.20180224.el8 BaseOS 331 k
事務概要
====================================================================================
安裝 1 軟體包
總計:331 k
安裝大小:1.2 M
下載軟體包:
執行事務檢查
事務檢查成功。
執行事務測試
事務測試成功。
執行事務
準備中 : 1/1
Installing : ncurses-compat-libs-6.1-7.20180224.el8.x86_64 1/1
執行指令碼 : ncurses-compat-libs-6.1-7.20180224.el8.x86_64 1/1
驗證 : ncurses-compat-libs-6.1-7.20180224.el8.x86_64 1/1
Installed products updated.
已安裝:
ncurses-compat-libs-6.1-7.20180224.el8.x86_64
完畢!
配置配置檔案/etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
[mysqld3306]
datadir = /opt/data/3306
port = 3306
socket = /tmp/mysql3306.sock
pid-file = /opt/data/3306/mysql_3306.pid
log-error=/var/log/3306.log
[mysqld3307]
datadir = /opt/data/3307
port = 3307
socket = /tmp/mysql3307.sock
pid-file = /opt/data/3307/mysql_3307.pid
log-error=/var/log/3307.log
[mysqld3308]
datadir = /opt/data/3308
port = 3308
socket = /tmp/mysql3308.sock
pid-file = /opt/data/3308/mysql_3308.pid
log-error=/var/log/3308.log
啟動各例項
[root@localhost ~]# mysqld_multi start
Wide character in print at /usr/local/mysql/bin/mysqld_multi line 678.
Installing new database in /opt/data/3306
2021-08-29T13:03:38.165504Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-29T13:03:38.166352Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2021-08-29T13:03:38.166367Z 0 [ERROR] Aborting
FATAL ERROR: Tried to start mysqld under group [mysqld3306],
but no data directory was found or could be created.
data directory used: /opt/data/3306
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 128 [::]:111 [::]:*
[root@localhost ~]# ps -ef|grep mysqld
root 73694 10482 0 21:04 pts/1 00:00:00 grep --color=auto mysqld
[root@localhost ~]#
初始化密碼
[root@localhost ~]# mysql -uroot -p'Jf:*4eh;*jq5' -h127.0.0.1 -P3306
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password = password('wjj');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
Bye
[root@localhost ~]# cat 7pass
soh48HPZmC&f
[root@localhost ~]# mysql -uroot -p'soh48HPZmC&f' -h127.0.0.1 -P3307
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password = password('wjj');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
Bye
[root@localhost ~]# cat 8pass
w)Lo>+qki3OV
[root@localhost ~]# mysql -uroot -p'w)Lo>+qki3OV' -h127.0.0.1 -P3308
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password = password('wjj');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
Bye
設定開機自啟
一、多例項設定開機自啟
- 把/usr/local/mysql/bin/support_files/mysqld_multi.service檔案複製到/etc/init.d/mysqld_multi
- 在/etc/init.d/mysqld_multi檔案中增加環境變數設定exoprt PATH=/usr/local/mysql/bin:$PATH
- chkconfig --add mysqld_multi
Xtrabackup備份與恢復
一、Xtrabackup介紹
1.MySQL冷備、mysqldump、MySQL熱拷貝都無法實現對資料庫進行增量備份。在實際生產環境中增量備份是非常實用的,如果資料大於50G或100G,儲存空間足夠的情況下,可以每天進行完整備份,如果每天產生的資料量較大,需要定製資料備份策略。例如每週實用完整備份,週一到週六實用增量備份。而Percona-Xtrabackup就是為了實現增量備份而出現的一款主流備份工具,xtrabakackup有2個工具,分別是xtrabakup、innobakupe。
2.Percona-xtrabackup是 Percona公司開發的一個用於MySQL資料庫物理熱備的備份工具,支援MySQL、Percona server和MariaDB,開源免費,是目前較為受歡迎的主流備份工具。xtrabackup只能備份innoDB和xtraDB兩種資料引擎的表,而不能備份MyISAM資料表。
二、Xtrabackup優點
- 備份速度快,物理備份可靠
- 備份過程不會打斷正在執行的事務(無需鎖表)
- 能夠基於壓縮等功能節約磁碟空間和流量
- 自動備份校驗
- 還原速度快
- 可以流傳將備份傳輸到另外一臺機器上
- 在不增加伺服器負載的情況備份資料
三、Xtrabackup備份原理
Xtrabackup備份流程圖:
1.innobackupex啟動後,會先fork一個程序,用於啟動xtrabackup,然後等待xtrabackup備份ibd資料檔案;
2.xtrabackup在備份innoDB資料是,有2種執行緒:redo拷貝執行緒和ibd資料拷貝執行緒。xtrabackup程序開始執行後,會啟動一個redo拷貝的執行緒,用於從最新的checkpoint點開始順序拷貝redo.log;再啟動ibd資料拷貝執行緒,進行拷貝ibd資料。這裡是先啟動redo拷貝執行緒的。在此階段,innobackupex進行處於等待狀態(等待檔案被建立)
3.xtrabackup拷貝完成ibd資料檔案後,會通知innobackupex(通過建立檔案),同時xtrabackup進入等待狀態(redo執行緒依舊在拷貝redo.log)
4.innobackupex收到xtrabackup通知後哦,執行FLUSH TABLES WITH READ LOCK(FTWRL),取得一致性位點,然後開始備份非InnoDB檔案(如frm、MYD、MYI、CSV、opt、par等格式的檔案),在拷貝非InnoDB檔案的過程當中,資料庫處於全域性只讀狀態。
5.當innobackup拷貝完所有的非InnoDB檔案後,會通知xtrabackup,通知完成後,進入等待狀態;
6.xtrabackup收到innobackupex備份完成的通知後,會停止redo拷貝執行緒,然後通知innobackupex,redo.log檔案拷貝完成;
7.innobackupex收到redo.log備份完成後,就進行解鎖操作,執行:UNLOCK TABLES;
8.最後innbackupex和xtrabackup程序各自釋放資源,寫備份元資料資訊等,innobackupex等xtrabackup子程序結束後退出。
全量備份
[root@localhost ~]# mkdir backups
[root@localhost ~]# cd backups/
[root@localhost backups]# innobackupex --defaults-file=/etc/my.cnf --user=root --password=zs --host=127.0.0.1 -P3306 /backups/
恢復
[root@localhost ~]# ls /backups/
2021-08-28_18-50-04
[root@localhost ~]# innobackupex --apply-log /backups/2021-08-28_18-50-04
[root@localhost ~]# cd /opt/data/3306
[root@localhost 3306]# ls
auto.cnf ibdata1 performance_schema
ca-key.pem ib_logfile0 private_key.pem
ca.pem ib_logfile1 public_key.pem
client-cert.pem ibtmp1 server-cert.pem
client-key.pem mysql server-key.pem
ib_buffer_pool mysql.pid sys
[root@localhost 3306]# rm -rf *
[root@localhost 3306]# ls
[root@localhost 3306]# innobackupex --defaults-file=/etc/my.cnf --copy-back -uroot -pzs --host=127.0.0.1 /backup/2021-08-28_18-50-04/
常用選項
常用選項:
--host 指定主機
--user 指定使用者名稱
--password 指定密碼
--port 指定埠
--databases 指定資料庫
--incremental 建立增量備份
--incremental-basedir 指定包含完全備份的目錄
--incremental-dir 指定包含增量備份的目錄
--apply-log 對備份進行預處理操作
一般情況下,在備份完成後,資料尚且不能用於恢復操作,因為備份的資料中可能會包含尚未提交的事務或已經提交但尚未同步至資料檔案中的事務。因此,此時資料檔案仍處理不一致狀態。“準備”的主要作用正是通過回滾未提交的事務及同步已經提交的事務至資料檔案也使得資料檔案處於一致性狀態。
--redo-only 不回滾未提交事務
--copy-back 恢復備份目錄