Created
June 4, 2019 11:40
-
-
Save negasus/c066a74de4495cf404b41865b81c9d0c to your computer and use it in GitHub Desktop.
Tarantool Vshard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------- | |
s_1.lua | |
------------------- | |
require('strict').on() | |
vshard = require('vshard') | |
local storage_uuid = 'b271d109-7f1f-4db5-9f0f-625abf9050ca' | |
local cfg = { | |
listen = '127.0.0.1:13301', | |
log_level = 5, | |
bucket_count = 30000, | |
work_dir = '/Users/negasus/Code/adscompass/tarantool-sessions', | |
wal_dir = 'debug/storage_1', | |
memtx_dir = 'debug/storage_1', | |
vinyl_dir = 'debug/storage_1', | |
} | |
function reload_vshard() | |
cfg.sharding = require('debug.vshard') | |
vshard.storage.cfg(cfg, storage_uuid) | |
end | |
reload_vshard() | |
box.once("create_user", function() | |
box.schema.user.create('user', { password = 'secret', if_not_exists = true }) | |
box.schema.user.grant('user', 'read,write,execute', 'universe') | |
end) | |
------------------- | |
s_2.lua такой же, только изменен storage_uuid на '7e5aaeba-14e3-4964-b9a8-0530df88cfed' и в cfg указан listen = '127.0.0.1:13302' и другие пути для хранения данных | |
------------------- | |
------------------- | |
r.lua | |
------------------- | |
require('strict').on() | |
local cfg = { | |
listen = '127.0.0.1:3300', | |
log_level = 5, | |
work_dir = '/Users/negasus/Code/adscompass/tarantool-sessions', | |
bucket_count = 30000, | |
wal_dir = 'debug/router', | |
memtx_dir = 'debug/router', | |
vinyl_dir = 'debug/router', | |
} | |
vshard = require('vshard') | |
function reload_vshard() | |
cfg.sharding = require('debug.vshard') | |
vshard.router.cfg(cfg) | |
end | |
reload_vshard() | |
box.once('create_user', function() | |
box.schema.user.create('user', { password = 'secret' }) | |
box.schema.user.grant('user', 'read,write,execute', 'universe') | |
end) | |
box.once('bootstrap', function() | |
vshard.router.bootstrap() | |
end) | |
------------------- | |
vshard.lua | |
------------------- | |
return { | |
['45dee63e-b017-4cc0-a8a1-1cb1d491f5ab'] = { | |
replicas = { | |
['b271d109-7f1f-4db5-9f0f-625abf9050ca'] = { | |
uri = 'user:secret@127.0.0.1:13301', | |
name = 'storage_1', | |
master = true, | |
}, | |
}, | |
}, | |
--['2c90d1c2-3d3c-47b8-bfa4-d7bf20ff0b17'] = { | |
-- replicas = { | |
-- ['7e5aaeba-14e3-4964-b9a8-0530df88cfed'] = { | |
-- uri = 'user:secret@127.0.0.1:13302', | |
-- name = 'storage_2', | |
-- master = true, | |
-- }, | |
-- }, | |
--}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment