how to replace a mirror node in Manticore Search without restarting the service?
No way atm. We have in plans to simplify this.
The docs for now is Manticore Search Manual: Creating a cluster > Setting up replication > Managing replication nodes
So, if I have a distributed table and I’ve configured agent mirrors like this: agent=node1|node2:9312:shard1
and node2 goes down, I need to replace it with another node, I would need to modify the configuration and then restart the service.
thx.
Oh, you mean not a replication node by “mirror node”, but just a remote agent. Then here’s what you can do:
RT mode:
Let’s assume we have a distributed table like this one:
➜ ~ mysql -P9306 -h0 -v -e "drop table if exists t; create table t; drop table if exists dist; create table dist type='distributed' agent='127.0.0.1:9312:t|127.0.0.1:9312:t'; desc dist;"
--------------
drop table if exists t
--------------
--------------
create table t
--------------
--------------
drop table if exists dist
--------------
--------------
create table dist type='distributed' agent='127.0.0.1:9312:t|127.0.0.1:9312:t'
--------------
--------------
desc dist
--------------
+------------------+-------------------+
| Agent | Type |
+------------------+-------------------+
| 127.0.0.1:9312:t | remote_1_mirror_1 |
| 127.0.0.1:9312:t | remote_1_mirror_2 |
+------------------+-------------------+
To update it, we need to remove it and create a new one:
➜ ~ time mysql -P9306 -h0 -v -e "drop table dist; create table dist type='distributed' agent='127.0.0.1:9312:t'; desc dist;"
--------------
drop table dist
--------------
--------------
create table dist type='distributed' agent='127.0.0.1:9312:t'
--------------
--------------
desc dist
--------------
+------------------+----------+
| Agent | Type |
+------------------+----------+
| 127.0.0.1:9312:t | remote_1 |
+------------------+----------+
mysql -P9306 -h0 -v -e 0.01s user 0.01s system 39% cpu 0.033 total
You will experience a short downtime: about 30ms in my case.
Plain mode
Let’s assume we have this config:
➜ ~ cat min_dist.conf
searchd {
listen = 9316
listen = 9315:mysql41
log = searchd.log
pid_file = searchd.pid
binlog_path =
}
source src {
type = csvpipe
csvpipe_command = echo "1,abc"
csvpipe_field = f
}
index idx {
type = plain
source = src
path = idx
}
index dist {
type = distributed
agent = 127.0.0.1:9312:t|127.0.0.1:9312:t
}
2 agents in the dist table:
➜ ~ mysql -P9315 -h0 -e "desc dist"
+------------------+-------------------+
| Agent | Type |
+------------------+-------------------+
| 127.0.0.1:9312:t | remote_1_mirror_1 |
| 127.0.0.1:9312:t | remote_1_mirror_2 |
+------------------+-------------------+
To update the distributed table let’s change the config like this:
- agent = 127.0.0.1:9312:t|127.0.0.1:9312:t
+ agent = 127.0.0.1:9312:t
and run RELOAD TABLES
:
➜ ~ mysql -P9315 -h0 -e "reload tables"
➜ ~ mysql -P9315 -h0 -e "desc dist"
+------------------+----------+
| Agent | Type |
+------------------+----------+
| 127.0.0.1:9312:t | remote_1 |
+------------------+----------+
As we can see, now there’s only one node left.