久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

MySQL中Sandbox怎么安裝

134次閱讀
沒有評論

共計 4336 個字符,預計需要花費 11 分鐘才能閱讀完成。

這篇文章主要介紹 MySQL 中 Sandbox 怎么安裝,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

一 sandbox 是什么?
MySQL Sandbox 是一個非常簡單快捷的安裝搭建 MySQL 實例的工具,它可以非常快速地滿足我們對 MySQL 環境各種需求: 單機實例,主從,一主多從等等架構 (區別于自己安裝 MySQL 軟件)。比如 新的數據庫版本發行之后,想要盡快嘗鮮,又不想花太多資源去安裝,就可以使用 sandbox 幫助我們完成創建單個或者主從結構的實例。對于那些不懂 MySQL 安裝的開發, 測試同學而言,可以使用 sandbox 的快速搭建一個符合要求的數據庫。MySQL Sandbox 快速,是以秒來衡量的,誰用誰知道。
二 如何安裝和使用
2.1 安裝 sandbox
本文的案例是基于 Centos 虛擬機測試。 

yum install cpan -y

yum install perl-Test-Simple -y

cpan MySQL::Sandbox

echo export SANDBOX_AS_ROOT=1 /root/.bash_profile source /root/.bash_profile

獲取 Percona server 5.7.17 版本

wget https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.17-11/binary/tarball/Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz

2.2 常用命令
安裝完成之后默認會在 /usr/local/bin/ 目錄下產生 make_開頭的文件。

make_sandbox                 基于二進制壓縮包創建 MySQL 實例

make_sandbox_from_source     基于源碼創建 MySQL 實例,參數是而執行 ./configure make 成功的源碼存放目錄

make_sandbox_from_installed   基于已經安裝好的 mysql 可執行文件目錄安裝 MySQL 實例

make_sandbox_from_url         從網上下載 docker 鏡像進行安裝,具體參考 –help 命令

make_multiple_sandbox         創建多個相同版本的 MySQL 實例

make_multiple_custom_sandbox 創建不同版本的 MySQL 實例

make_replication_sandbox     搭建主從復制結構, 可以是一主一從,也可以是一主多從。

sbtool :                     sandbox 管理工具

要深入了解各個命令的具體用法,請參考源碼目錄下的 README 文檔,然后再自己動手實踐,能理解更深刻,畢竟紙上來得終覺淺,絕知此事要躬行。下面主要通過
make_sandbox 和 make_replication_sandbox 來介紹如何使用。
2.3 使用 sandbox
安裝單個實例

root@rac4:/data/mysql# make_sandbox /data/mysql/Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz

unpacking /data/mysql/Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz

Executing low_level_make_sandbox –basedir=/data/mysql/5.7.17 \

–sandbox_directory=msb_5_7_17 \

–install_version=5.7 \

–sandbox_port=5717 \

–no_ver_after_name \

–my_clause=log-error=msandbox.err

 The MySQL Sandbox, version 3.2.05

 (C) 2006-2016 Giuseppe Maxia

Installing with the following parameters:

upper_directory = /root/sandboxes

sandbox_directory = msb_5_7_17

sandbox_port = 5717

check_port =

no_check_port =

datadir_from = script

install_version = 5.7

basedir = /data/mysql/5.7.17

tmpdir =

my_file =

operating_system_user = root

db_user = msandbox

remote_access = 127.%

bind_address = 127.0.0.1

ro_user = msandbox_ro

rw_user = msandbox_rw

repl_user = rsandbox

db_password = msandbox

repl_password = rsandbox

my_clause = log-error=msandbox.err

…… 省略部分內容

prompt_prefix = mysql

prompt_body = [\h] {\u} (\d)

force =

no_ver_after_name = 1

verbose =

load_grants = 1

no_load_grants =

no_run =

no_show =

keep_uuid =

history_dir =

do you agree? ([Y],n) Y

輸入 Y 然后 sandbox 就會啟動一個實例,需要等待 20s 左右。

# Starting server

. sandbox server started

# Loading grants

Your sandbox server was installed in $HOME/sandboxes/msb_5_7_17

因為本案例采用 root 用戶安裝測試,新生成的數據庫目錄在 /root/sandboxes/msb_5_7_17, 其中的文件如下  

大家可以研究各個可執行文件的具體內容。常用的有 use,stop,start,restart 等等,例如

root@rac4:~/sandboxes/msb_5_7_17# ./use – 登陸數據庫

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 9

Server version: 5.7.17-11 Percona Server (GPL), Release 11, Revision f60191c

Copyright (c) 2009-2016 Percona LLC and/or its affiliates

mysql [localhost] {msandbox} ((none)) show databases;

+——————–+

| Database           |

+——————–+

| information_schema |

| mysql              |

| performance_schema |

| sys              |

| test               |

+——————–+

5 rows in set (0.00 sec)

搭建主從,本例中啟用 gtid 并且設置創建 1 個 slave. 因為上例已經創建了一個 5.7.17 源程序目錄,我們可以基于該目錄創建主從,當然也可以基于源碼的壓縮包。

root@rac4:/data/mysql# make_replication_sandbox –gtid –how_many_slaves=1  5.7.17

installing and starting master

installing slave 1

starting slave 1

.. sandbox server started

initializing slave 1

replication directory installed in $HOME/sandboxes/rsandbox_5_7_17

根據結果提示 sandbox 創建的主從在目錄 $HOME/sandboxes/rsandbox_5_7_17,進入該目錄查看有如下文件  

其中 master 和 node1 分別是主庫和備庫的數據庫目錄,m 和 n1 都是登陸主庫的命令,s1 和 n2 都是登陸 slave 的命令,其他的可以從文件名知道具體用途。這里介紹兩個命令 test_replication 和 check_slaves 兩個命令功能類似,都是檢查 slave 的狀態信息。check_slaves 會把主庫相關信息輸出。

root@rac4:~/sandboxes/rsandbox_5_7_17# sh test_replication   檢查主備關系

# Master log: mysql-bin.000001 – Position: 10732 – Rows: 20

# Testing slave #1

ok – Slave #1 acknowledged reception of transactions from master

ok – Slave #1 IO thread is running

ok – Slave #1 SQL thread is running

ok – Table t1 found on slave #1

ok – Table t1 has 20 rows on #1

# TESTS : 5

# FAILED: 0 (0.0%)

# PASSED: 5 (100.0%)

# exit code: 0

root@rac4:~/sandboxes/rsandbox_5_7_17# ./check_slaves  #

master

port: 20192

 File: mysql-bin.000001

 Position: 10732

Executed_Gtid_Set: 00020192-1111-1111-1111-111111111111:1-40

slave # 1

port: 20193

 Master_Log_File: mysql-bin.000001

 Read_Master_Log_Pos: 10732

 Slave_IO_Running: Yes

 Slave_SQL_Running: Yes

 Exec_Master_Log_Pos: 10732

 Retrieved_Gtid_Set: 00020192-1111-1111-1111-111111111111:1-40

 Executed_Gtid_Set: 00020192-1111-1111-1111-111111111111:1-40

以上是“MySQL 中 Sandbox 怎么安裝”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注丸趣 TV 行業資訊頻道!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-27發表,共計4336字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 托克托县| 吴川市| 太原市| 新闻| 丹凤县| 北辰区| 北安市| 临汾市| 山东省| 双辽市| 深水埗区| 巴彦县| 临夏市| 高要市| 梨树县| 大余县| 屏东县| 赣州市| 仲巴县| 温州市| 重庆市| 清水河县| 蓬溪县| 天津市| 南昌县| 清镇市| 玉田县| 福泉市| 罗城| 涞水县| 宜川县| 阿瓦提县| 牡丹江市| 旌德县| 东台市| 武强县| 华亭县| 松潘县| 莱阳市| 北京市| 台山市|