本文整理汇总了Python中lib.tarantool_server.TarantoolServer.rpl_master方法的典型用法代码示例。如果您正苦于以下问题:Python TarantoolServer.rpl_master方法的具体用法?Python TarantoolServer.rpl_master怎么用?Python TarantoolServer.rpl_master使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.tarantool_server.TarantoolServer
的用法示例。
在下文中一共展示了TarantoolServer.rpl_master方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import rpl_master [as 别名]
import os
from glob import iglob as glob
from lib.tarantool_server import TarantoolServer
# master server
master = server
master_id = master.get_param('server')['id']
master.admin("box.schema.user.grant('guest', 'replication')")
replica = TarantoolServer(server.ini)
replica.script = 'replication/replica.lua'
replica.vardir = server.vardir #os.path.join(server.vardir, 'replica')
replica.rpl_master = master
replica.deploy()
replica.wait_lsn(master_id, master.get_lsn(master_id))
replica_id = replica.get_param('server')['id']
replica.admin('box.info.server.id')
replica.admin('box.info.server.ro')
replica.admin('box.info.server.lsn')
replica.stop()
print '-------------------------------------------------------------'
print 'replica is read-only until receive self server_id in _cluster'
print '-------------------------------------------------------------'
# Remove xlog retrived by SUBSCRIBE
filename = str(0).zfill(20) + ".xlog"
wal = os.path.join(os.path.join(replica.vardir, replica.name), filename)
os.remove(wal)
示例2: range
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import rpl_master [as 别名]
master.admin("box.schema.user.grant('guest', 'replication')")
master.admin("box.schema.user.grant('guest', 'execute', 'universe')")
print '----------------------------------------------------------------------'
print 'Bootstrap replicas'
print '----------------------------------------------------------------------'
# Start replicas
master.id = master.get_param('server')['id']
master_lsn = master.get_lsn(master.id)
cluster = [ master ]
for i in range(REPLICA_N - 1):
server = TarantoolServer(server.ini)
server.script = 'replication/replica.lua'
server.vardir = os.path.join(server.vardir, 'replica', str(master.id + i))
server.rpl_master = master
server.deploy()
# Wait replica to fully bootstrap.
# Otherwise can get ACCESS_DENIED error.
server.wait_lsn(master.id, master_lsn)
cluster.append(server)
# Make a list of servers
sources = []
for server in cluster:
sources.append(yaml.load(server.admin('box.cfg.listen', silent = True))[0])
server.id = server.get_param('server')['id']
print 'done'
print '----------------------------------------------------------------------'
示例3: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import rpl_master [as 别名]
server.script = script
server.deploy()
print '-------------------------------------------------------------'
print 'Start a new replica and check box.info on the start'
print '-------------------------------------------------------------'
# master server
master = server
master_id = master.get_param('server')['id']
master.admin("box.schema.user.grant('guest', 'replication')")
replica = TarantoolServer(server.ini)
replica.script = 'replication/replica.lua'
replica.vardir = server.vardir
replica.rpl_master = master
replica.deploy()
replica.wait_lsn(master_id, master.get_lsn(master_id))
replica_id = replica.get_param('server')['id']
replica_uuid = replica.get_param('server')['uuid']
sys.stdout.push_filter(replica_uuid, '<replica uuid>')
replica.admin('box.info.server.id == %d' % replica_id)
replica.admin('not box.info.server.ro')
replica.admin('box.info.server.lsn == 0')
replica.admin('box.info.vclock[%d] == 0' % replica_id)
print '-------------------------------------------------------------'
print 'Modify data to change LSN and check box.info'
print '-------------------------------------------------------------'
replica.admin('box.space._schema:insert{"test", 48}')
示例4: insert_tuples
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import rpl_master [as 别名]
insert_tuples(master, id, id + ID_STEP)
# select from replica
replica.wait_lsn(master_id, master.get_lsn(master_id))
select_tuples(replica, id, id + ID_STEP)
id += ID_STEP
# insert to master
insert_tuples(master, id, id + ID_STEP)
# select from replica
replica.wait_lsn(master_id, master.get_lsn(master_id))
select_tuples(replica, id, id + ID_STEP)
id += ID_STEP
print "swap servers"
# reconfigure replica to master
replica.rpl_master = None
print("switch replica to master")
replica.admin("box.cfg{replication_source=''}")
# reconfigure master to replica
master.rpl_master = replica
print("switch master to replica")
master.admin("box.cfg{replication_source='%s'}" % replica.uri, silent=True)
# insert to replica
insert_tuples(replica, id, id + ID_STEP)
# select from master
master.wait_lsn(replica_id, replica.get_lsn(replica_id))
select_tuples(master, id, id + ID_STEP)
id += ID_STEP
# insert to replica