mysql-sandbox 安裝配置筆記

來源:互聯網
上載者:User

標籤:mysql-sandbox 安裝配置筆記

sandbox的安裝可以使用github的方式,也可以使用cpan安裝。

推薦使用cpan這種一鍵安裝的。


# 安裝mysqlsanbox

yum install cpan perl-YAML perl-Test-Simple -y
cpan MySQL::Sandbox
echo ‘export SANDBOX_AS_ROOT=1‘ >> /root/.bashrc 
source /root/.bashrc


將準備好的幾個常用mysql通用二進位包放到/opt/目錄下。如下:

[[email protected] /opt ]# ll
total 1035444
-rw-r--r-- 1 root root 640650826 2017-07-27 20:53 mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
-rw-r--r-- 1 root root 419634124 2017-07-27 20:53 mariadb-10.3.0-linux-x86_64.tar.gz


建立一個10.3.0版本的mariadb執行個體

make_sandbox mariadb-10.3.0-linux-x86_64.tar.gz

過程如下:unpacking /opt/mariadb-10.3.0-linux-x86_64.tar.gz

Executing low_level_make_sandbox --basedir=/opt/10.3.0 \

--sandbox_directory=msb_10_3_0 \

--install_version=10.3 \

--sandbox_port=10300 \

--no_ver_after_name \

--my_clause=log-error=msandbox.err

    The MySQL Sandbox,  version 3.2.13

    (C) 2006-2017 Giuseppe Maxia

Installing with the following parameters:

upper_directory                = /root/sandboxes

sandbox_directory              = msb_10_3_0

sandbox_port                   = 10300

check_port                     = 

no_check_port                  = 

datadir_from                   = script

install_version                = 10.3

basedir                        = /opt/10.3.0

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

init_options                   = 

init_my_cnf                    = 

init_use_cnf                   = 

master                         = 

slaveof                        = 

high_performance               = 

gtid                           = 

pre_start_exec                 = 

pre_grants_exec                = 

post_grants_exec               = 

pre_grants_sql                 = 

post_grants_sql                = 

pre_grants_file                = 

post_grants_file               = 

load_plugin                    = 

plugin_mysqlx                  = 

mysqlx_port                    = 

expose_dd_tables               = 

custom_mysqld                  = 

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

# Starting server

.. sandbox server started

# Loading grants

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

然後,輸入Y表示同意上面的配置參數。

稍等20s後,就會自動在/root/sandboxes目錄下產生一個類似msb_10_3_0的目錄


預設是監聽在127.0.0.1的地址的。如果我們要改成監聽在外部地址的話,

cd /root/sandboxes/msb_10_3_0 (這個目錄下有很多指令碼,可以自己看下裡面內容就知道如何用了)

vim /root/sandboxes/msb_10_3_0/my.sandbox.cnf 注釋掉listen那行代碼,

然後執行./restart 即可。


./use 即可登入mysql

./mycli 就可以用mycli來登入(CentOS6需要自己編譯安裝python27才能正常使用mycli)



建立一套GTID複製的5.7.19主從執行個體

cd /opt/       ### 需要先切換到mysql源碼包那個路徑下才行make_replication_sandbox --gtid --how_many_slaves=1  5.7.19   建立一套GTID複製的5.7.19主從執行個體



稍等20s,即可啟動1套主從mysql5.7.19的環境。

ss -lntp|grep mysql 即可驗證。


如何使用上面建立的GTID主從機器:

cd /root/sandboxescd rsandbox_5_7_19[[email protected] /root/sandboxes/rsandbox_5_7_19 ]# ./test_replication    檢查主從複製狀態

# Master log: mysql-bin.000001 - Position: 11309 - 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



這個目錄下,m和n1都是串連主庫的串連指令碼。 s1和n2都是串連從庫的指令碼。




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

如果需要一次性建立好幾個相同的執行個體且不需要有複製關係,可以使用下面的命令

cd /opt/ make_multiple_sandbox --how_many_nodes=3 mariadb-10.3.0-linux-x86_64.tar.gz    # 預設一次性建立3個執行個體



#####還有些常用的命令,都是些簡單的shell指令碼,開啟看下就知道啥意思了。就不解釋了。






本文出自 “一隻菜雞的筆記” 部落格,請務必保留此出處http://lee90.blog.51cto.com/10414478/1951579

mysql-sandbox 安裝配置筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.