Create Stream Manager 2.0 Instance
The Stream Manager 2.0 instance is the cornerstone of Red5 Pro’s architecture, providing a comprehensive solution for managing, orchestrating, and scaling your streaming infrastructure.
Stream Manager 2.0 instance consists of multiple Docker containers (microservices) and runs using Docker Compose.
Create Stream Manager 2.0 Instance
- Navigate to the EC2 Dashboard
- From the left-hand navigation, under INSTANCES, click on Instances, then Launch Instance
- Specify name to the instance. Eg:
red5pro-stream-manager-instance
. - Choose an Amazon Machine Image (AMI) – Select the
Ubuntu Server 22.04 LTS
. - Choose an Instance Type – Recommended minimum
c5.2xlarge
for price and performance. - Configure Key Pair – Select the existing key pair created in the previous step.
- Configure Instance Details – Network Settings: choose the VPC created for autoscaling in that region. Ensure that
Auto-assign Public IP
is set to Enable, accept all other defaults. - Click on Next: Add storage – Increase from the default 8G to 16G or more.
- Configure Security Group – Select an existing node security group. Eg:
red5pro-autoscaling-sm-sg
- Click Launch Instance
Create new DNS record for Stream Manager 2.0 Instance
The default configuration requires creating a DNS record and using an SSL certificate on the Stream Manager 2.0 to allow clients to publish and subscribe to WebRTC streams using a browser.
- Find the public IP address of your Stream Manager 2.0 instance.
- Create an A record in your DNS provider to point the DNS name to the public IP address.
red5pro-sm2.example.com - 1.2.3.4
If you choose not to install a domain name and SSL certificate, you will not be able to publish WebRTC streams. However, you will still be able to publish RTMP and RTSP streams and subscribe to WebRTC, RTMP, and RTSP streams. In this case, you will need to use the docker-compose.yml file that does not include SSL certificate configuration. Example: autoscaling-without-ssl
Install Stream Manager 2.0 Instance
-
Connect to your instance over ssh as ubuntu user. Example:
ssh -i ssh_private_key.pem ubuntu@1.2.3.4
-
Install
docker
withdocker-compose-plugin
, follow the public documentation. -
Create folder for Stream Manager 2.0 files.
sudo mkdir /usr/local/stream-manager
- Pull Stream Manager 2.0 docker-compose examples from our public repository red5pro-stream-manager-2-examples.
git clone https://github.com/red5pro/red5pro-stream-manager-2-examples.git
- Choose one deployment type from examples. Example with SSL ceritificate:
autoscaling-with-ssl
- Copy files from folder
autoscaling-with-ssl
to the folder/usr/local/stream-manager
sudo cp -r ./red5pro-stream-manager-2-examples/autoscaling-with-ssl/. /usr/local/stream-manager/
- Go to the Stream Manager folder
cd /usr/local/stream-manager/
- Create folder for SSL certificate
sudo mkdir /usr/local/stream-manager/letsencrypt
- Rename docker compose variables file
sudo mv /usr/local/stream-manager/.example.env /usr/local/stream-manager/.env
- Set main Stream Manager 2.0 variables in the file
/usr/local/stream-manager/.env
R5AS_AUTH_SECRET=<SECRET_KEY>
R5AS_AUTH_USER=<USER_NAME>
R5AS_AUTH_PASS=<PASSWORD>
R5AS_CLOUD_PLATFORM_TYPE=<PLATFORM_TYPE>
KAFKA_HOST=<PRIVATE_IP>
TRAEFIK_HOST=<DNS_NAME>
TRAEFIK_SSL_EMAIL=<EMAIL>
R5P_LICENSE_KEY=<LICENSE_KEY>
R5AS_AUTH_SECRET
– Authentication secret used to create and authenticate JWTs. Example:12345abcd
R5AS_AUTH_USER
– Authentication user name used to get JWT token. Example:admin
R5AS_AUTH_PASS
– Authentication user password used to get JWT token. Example:password
R5AS_CLOUD_PLATFORM_TYPE
– Cloud platform type (OCI,AWS,LINODE). Example:AWS
KAFKA_HOST
– Kafka server IP address. In this deployment Kafka server on the Stream Manager 2.0 instance so you will need to set Private IP address of this instance. Example:10.0.0.10
TRAEFIK_HOST
– Stream Manager 2.0 domain name: This should be the same domain name you used to create the DNS record. Example:red5pro-sm2.example.com
TRAEFIK_SSL_EMAIL
– The email address that will be used for the SSL certificate.R5P_LICENSE_KEY
– Red5 Pro license key which will be using on the Red5 Pro nodes. It should be active Red5 Pro license key, Startup Pro level or higher.
- Set AWS Cloud specific variables in the
/usr/local/stream-manager/docker-compose.yml
file.TF_VAR_aws_access_key: YOUR_AWS_ACCESS_KEY TF_VAR_aws_secret_key: YOUR_AWS_SECRET_KEY TF_VAR_aws_ssh_key_pair: AWS_SSH_KEY_NAME TF_VAR_enable_root_volume_block_encryption: true
You should have these variables from the previous steps.
TF_VAR_aws_access_key
– AWS access key to authenticate with AWS account. Follow the docs to createTF_VAR_aws_secret_key
– AWS secret key to authenticate with AWS account. Follow the docs to createTF_VAR_aws_ssh_key_pair
– SSH key name. It will be using for SSH connect to Red5 Pro nodes. Follow the docs to create SSH key pair in AWS.TF_VAR_enable_root_volume_block_encryption
– Enable or disable root block volume encryption for node instance. Defaults to true.
Example as-terraform
service configuration for AWS
as-terraform:
deploy:
replicas: 1
image: red5pro/as-terraform:latest
depends_on:
kafka0:
condition: service_healthy
environment:
R5AS_AUTOSCALE_PARTITIONS: 2
R5AS_REPLICATION_FACTOR: 1
R5AS_BOOTSTRAP_SERVERS: kafka0:29092
R5AS_SECURITY_PROTOCOL_CONFIG: ""
R5AS_SSL_KEYSTORE_TYPE_CONFIG: ""
R5AS_SSL_TRUSTSTORE_TYPE_CONFIG: ""
R5AS_SSL_CA_CERTIFICATE: ""
R5AS_SASL_USERNAME: ""
R5AS_SASL_PASSWORD: ""
R5AS_SASL_ENABLED_MECHANISMS: ""
R5AS_COMMAND_INACTIVITY_GAP_MS: 10000
TF_VAR_aws_access_key: aabbccdd11223344...
TF_VAR_aws_secret_key: aabbccdd11223344...
TF_VAR_aws_ssh_key_pair: red5pro-ssh-key
TF_VAR_enable_root_volume_block_encryption: true
TF_VAR_r5p_license_key: ${R5P_LICENSE_KEY:?R5P_LICENSE_KEY is not set}
- Start/Stop Stream Manager 2.0 – docker compose
sudo docker compose up -d
– Start the Docker Compose services defined in the docker-compose.yml file in detached mode.sudo docker compose up
– Start the Docker Compose services defined in the docker-compose.yml file.sudo docker compose logs -f
– Follow the logs of all running services in real-time.sudo docker compose down
– Stop and remove all the services defined in thedocker-compose.yml
file.
To run Docker Compose commands, you should be in the directory containing the docker-compose.yml file. In this case, it is the /usr/local/stream-manager directory.
- Create service to allow for ease of startup/shutdown of Stream Manager 2.0, in addition to automatically starting the service on server reboot, you will want to add a systemd unit file for Stream Manager 2.0.
- Create a service file:
sudo nano /lib/systemd/system/sm.service
- Add the following content to the service file:
[Unit]
Description=Stream Manager 2.0
Requires=docker.service
After=docker.service
StartLimitIntervalSec=60
[Service]
WorkingDirectory=/usr/local/stream-manager
ExecStart=/usr/bin/docker compose up
ExecStop=/usr/bin/docker compose down
TimeoutStartSec=0
Restart=on-failure
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
- Start the service:
sudo systemctl start sm.service
- Stop the service:
sudo systemctl stop sm.service
- Restart the service:
sudo systemctl restart sm.service
- Enable the service to start on boot:
sudo systemctl enable sm.service
- Check the status of the service:
sudo systemctl status sm.service
- Verify Stream Manager 2.0
To verify that the Stream Manager 2.0 is running correctly, open your web browser and navigate to the following URL: https://<STREAM_MANAGER_DOMAIN_NAME>
. If you are using the Stream Manager 2.0 without an SSL certificate and domain name, use http://<STREAM_MANAGER_IP_ADDRESS>
instead.
You should see the Stream Manager 2.0 interface if everything is set up correctly.