NICE re/streamer pro

Guides

Master and slaves: installation and setup

How to spread viewers across several servers. The main server (master) keeps the database and decides where each client goes. The extra servers (slaves) deliver the channels in its place.

How it works

  1. The client connects to the master as before. Playlist addresses do not change.
  2. The master picks a server and redirects the client there. Playlists (Xtream, M3U, Stalker, NICE, TVIP) already contain the chosen slave's address.
  3. The slave checks the subscriber against its own copy of the data and starts the stream. Movies and series (VOD) are played from the master.
  4. Every 15 seconds the slave asks the master for changes and downloads only what changed, channel logos included. With a key it also reports its load.

A slave runs the same program as the master. The only difference is one setting: Configuration → Balancer.

Before you start

1Make the server a master

On the main server open Configuration → tab BALANCER.

Configuration → BALANCER on the master: type Master, key, Generate, Save
  1. Balancer type → Master.
  2. Balancer key – the shared secret between the master and its slaves. Everything between them, subscriber passwords included, is encrypted and signed with it.
  3. Generate creates a random key. You can also type your own: 16–128 characters, letters, digits, - and _. Copy the key – every slave needs it.
  4. Save.
It also works without a key, but unprotected.

The old protocol is then used: its cipher is the same for every installation and a slave is recognised only by its IP. Load reports and the common connection limit do not work either. We recommend always setting a key.

2Add the slave on the master

On the master: Channels → Balancers. Fill in the new server in the Add row.

The add-balancer form: Id, name, address, countries, panel language, stream workers, source read
  1. Id – the slave's number. A free one is suggested. Remember it – the same number is entered on the slave.
  2. Name – e.g. DE-1. Subscribers are assigned to the slave by this name.
  3. IP address or host name – the address for clients: 203.0.113.21 or de1.example.com. Viewers are redirected there and it goes into the playlists.
  4. Countries and networks – whom the slave serves: country codes (DE,AT), subnets (10.20.0.0/16) or single IPs, separated by commas. Leave empty if the slave is only for manually assigned subscribers.
  5. Panel language on the slave – English or Bulgarian.
  6. Stream workers – auto (recommended) or a fixed number. See “Slave settings from the master” below.
  7. Source read, ms – 20 by default.
  8. Add balancer.
Tip

If you install over SSH (option A in the next step) you can skip this row – the installation adds the slave itself.

3Install and set up the slave

Option A – over SSH from the masterFastest. The master installs the panel on the new server and configures it.
Option B – by handWhen the master has no root SSH access or the panel is already installed there.

Option A – SSH installation

On the master: Channels → Balancers → SSH installation (top right).

The SSH installation dialog with IP, port, password, name, countries, panel language, stream workers and source read
  1. IP address of the new server.
  2. SSH port (usually 22). The user is root.
  3. Password for root. It is used only for this installation.
  4. Name of the slave, e.g. DE-1.
  5. Countries and networks – as in step 2.
  6. Panel language on the slave.
  7. Stream workers – leave auto: the master reads the number of CPU cores of the new server during the installation.
  8. Source read, ms – 20.
  9. Start install. Progress appears in the black box.

The master installs the panel, makes it a slave pointing to itself, writes its Id and the key, turns on Admin login from master, and adds it to the list. You log in to the slave's panel with the same admin user and password as on the master (after the first sync, up to 60 s after it starts). After a few minutes the slave shows as online – see step 4.

Option B – by hand

1. Install the panel on the new server as usual (as root):

curl -s https://nice-panel.com/install3.sh | bash -s 5.5

2. Log in to the slave's panel → Configuration → BALANCER:

Configuration → BALANCER on the slave: type, master, Id, key, network speed, admin login
  1. Balancer type → Slave.
  2. Master – the master's address with its panel port: IP:4300.
  3. Balancer Id – the same as in the master's list (step 2). With a key the master recognises the slave by it, whatever its IP (dynamic IP, NAT, different outgoing address).
  4. Balancer key – the same key as on the master.
  5. Network speed (Mbps) – 0 = read from the network card. Enter a value (1000, 10000) on virtual servers or when the port/plan is slower than the card.
  6. Admin login from master – No: the slave keeps its own admin user and password. Yes: it takes them from the master.

3. Save. The slave downloads everything from the master: channels, users, EPG, VOD, settings and logos. If the master uses other ports, the slave takes them and restarts itself.

4. If you have not done it yet, add the slave to the master's list (step 2).

Slave settings from the master

The Configuration page on a slave is limited – most settings come from the master. Three settings belong to each slave and are set on the master, in its row in Balancers (Add, Edit ✎ or SSH installation):

SettingWhat it does
Panel languagethe language of the slave's panel. Applied at once, without a restart
Stream workersprocesses that send the live streams to the viewers, on several CPU cores. Auto by the slave's cores: up to 4 cores → 2, up to 8 → 4, more than 8 → 8 (more than 8 does not help). Or a fixed number (off, 1–16)
Source read, mshow often the slave reads the channel sources. 20 by default; 0 = off. Applied at once
When the slave restarts

The number of stream workers takes effect after a restart, so the slave restarts itself – only when the value really changes. Its viewers are disconnected for a few seconds. With the SSH installation the right number is written during the installation, so there is no restart. A slave installed by hand gets it on its first contact with the master – one restart.

4Check the status

On the master: Channels → Balancers. Each slave's status refreshes every 5 seconds.

The balancer list: three slaves online, protected, with clients, CPU, RAM, network and load
Three slaves online, protected, with their clients and metrics. BG-1 has a 1 Gbps card and is the busiest, so new viewers from Germany go to DE-2.
ShownMeaning
● online / offlinewhether the slave has polled the master in the last 150 s. The number turns green or red
protected / unprotectedwith a key / old protocol without a key
from <IP>the slave connects from an IP other than its address (NAT, host name) – for information
N clientshow many viewers the slave serves
EN / BGthe panel language set for the slave
CPU · RAM · MbpsCPU use (cores), memory and network (traffic / card speed)
workers N (auto) · read N msthe slave's actual stream workers and source read. An orange → N means a new value is waiting for the slave's restart
load %the busiest of the three resources. The slave is chosen by it; above 90% it is highlighted
syncwhen the slave last confirmed the data
changes waiting (N)how many kinds of data it has not downloaded yet. Normal for a short time after a change or a restart

Each panel also shows its role under the logo, on every page – so you always know which panel you are in:

The panel header on the master: MASTER in red under the logo
MASTER – red
The panel header on a slave: SLAVE (201) in orange under the logo, the server tag in orange
SLAVE (Id) – orange, with the slave's Id from the master's list; the server tag is orange too

5Which viewer goes where

For every new connection the master checks the rules in order and stops at the first one that gives a live slave:

RuleHow to set it
1. ManualUsers → the subscriber's Balancer field (or in bulk for the selected ones). Always wins while that slave is live
2. Subnetthe viewer's IP is in a subnet or IP listed in a balancer's “countries” field
3. Countrythe viewer's GeoIP country is in the “countries” field
4. Masternothing matched or those slaves are down: the viewer stays on the master

Several slaves for one location

If one country or network has several live slaves, the new viewer goes to the least loaded one. This is not round robin: load is the highest of CPU, memory and network, so a server with a faster card or more cores takes proportionally more viewers. On a tie (within 5 points) the subscriber decides, so one subscriber keeps landing on the same server.

A slave goes down

A slave that has not polled for over 150 s is skipped. The redirect is temporary (302), so the viewer's next connection goes through the master again and lands on a live server. If the master is unreachable when a slave starts, the slave starts with the last data it received.

Connection limit

With a key the subscriber's limit is shared across all servers: 2 allowed connections means 2 in total, not 2 per server.

If something does not work

Messages are in the panel log and start with [BAL].

Message / symptomWhat to do
old protocol – set the same bal_key therethe master has a key, the slave does not. Enter the key on the slave
bal_key mismatchthe keys differ or the clocks are more than 10 minutes apart
unknown slave … set the same Idthe slave's Id is missing or not in the master's list
IP not allowedwithout a key the slave must connect from the IP of its address. With a key, fill in the slave's Id
master … – no syncthe slave cannot reach the master: network, firewall, port 4300
“offline” on the masterthe slave is stopped or cannot reach the master. Its viewers go to the other servers
“speed unknown”the virtual card does not report a speed. Set Network speed on the slave
Switching a running installation to a key
  • update the master and all slaves;
  • set the key (and Id) on the slaves;
  • set it on the master last.

Until the keys match, the slaves keep working with the last data they received.