Best Steps To Add Slave Server in Virtualizor – OrcaCore
This article will guide you through the process of adding a Slave Server in Virtualizor, enabling you to manage it centrally from a master server. The master server gains complete control over the slave, allowing you to add media, create and manage VPS instances, and handle other administrative tasks. We aim to provide a clear and concise walkthrough for integrating a slave server into your Virtualizor setup. Let’s explore the best steps to add slave server in Virtualizor.
The following steps will detail how to add a slave server in Virtualizor panel. Because the master server manages everything on the slave server, performing the post-installation requirements directly on the slave is unnecessary. All tasks can be handled from the master interface. Access the master server by entering its IP address followed by port 4085 (e.g., ServerIP:4085) in your browser and logging in with your administrative credentials. Once logged in, follow the steps outlined below.
Step 1 – Add Server Group / Region to Virtualizor
In Virtualizor, servers are organized into groups. Before adding a slave server, you must first create a group to assign it to. Navigate to the "Servers >> Add Server Group / Region" menu.
<figure><img decoding="async" width="1024" height="576" src="https://bluehoster.info/wp-content/uploads/2023/08/1-9-1024x576.webp" alt="Add Server Group / Region - orcacore.com" srcset="https://bluehoster.info/wp-content/uploads/2023/08/1-9-1024x576.webp 1024w, https://bluehoster.info/wp-content/uploads/2023/08/1-9-300x169.webp 300w, https://bluehoster.info/wp-content/uploads/2023/08/1-9-768x432.webp 768w, https://bluehoster.info/wp-content/uploads/2023/08/1-9-1536x864.webp 1536w, https://bluehoster.info/wp-content/uploads/2023/08/1-9-150x84.webp 150w, https://bluehoster.info/wp-content/uploads/2023/08/1-9-696x392.webp 696w, https://bluehoster.info/wp-content/uploads/2023/08/1-9-1068x601.webp 1068w, https://bluehoster.info/wp-content/uploads/2023/08/1-9.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px"><figcaption>Add Slave Server in Virtualizor</figcaption></figure>
As shown in the image, assign a descriptive name to the "Server Group Name" field based on your organizational structure. You can also define a "Reseller Region Name" to be displayed to your reseller users.
Next, provide a detailed description of the group in the "Server Group Description" box.
When creating a new VPS, you need to specify which server within this group should host the VPS.
The "Server Selection" setting allows you to define a priority, ensuring that new VPS instances are created according to your chosen criteria.
If you want to install a new VPS on all servers within this group, effectively creating a cluster, enable the "High Availability" option.
Finally, click on "Add Server Group" to save the created group. You can view all your groups and regions by navigating to the "Servers >> Server Group / Regions" menu.
Step 2 – How to Get Slave Server API
This step explains how to obtain the API information from the slave server. This information is essential for establishing a connection between the slave and master servers. Access the slave server by entering its IP address followed by port 4085 (e.g., ServerIP:4085) in your browser and logging in with your credentials.
On the slave server, go to "Configuration >> Server Info" to access the required information.
<figure><img decoding="async" width="1024" height="576" src="https://bluehoster.info/wp-content/uploads/2023/08/2-3-1024x576.webp" alt="Server info - orcacore.com" srcset="https://bluehoster.info/wp-content/uploads/2023/08/2-3-1024x576.webp 1024w, https://bluehoster.info/wp-content/uploads/2023/08/2-3-300x169.webp 300w, https://bluehoster.info/wp-content/uploads/2023/08/2-3-768x432.webp 768w, https://bluehoster.info/wp-content/uploads/2023/08/2-3-1536x864.webp 1536w, https://bluehoster.info/wp-content/uploads/2023/08/2-3-150x84.webp 150w, https://bluehoster.info/wp-content/uploads/2023/08/2-3-696x392.webp 696w, https://bluehoster.info/wp-content/uploads/2023/08/2-3-1068x601.webp 1068w, https://bluehoster.info/wp-content/uploads/2023/08/2-3.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px"><figcaption>Add Slave Server in Virtualizor</figcaption></figure>
Copy the key (API Password) and save it securely. You will need it in the next step to connect the slave server to the master server.
Step 3 – How to add a server to Master Server
With all the necessary information gathered, you can now add the slave server to the master server. On the master server, navigate to "Servers >> Add server". Fill in the required information.
<figure><img decoding="async" width="1024" height="576" src="https://bluehoster.info/wp-content/uploads/2023/08/3-1-1024x576.webp" alt="Add server - orcacore.com" srcset="https://bluehoster.info/wp-content/uploads/2023/08/3-1-1024x576.webp 1024w, https://bluehoster.info/wp-content/uploads/2023/08/3-1-300x169.webp 300w, https://bluehoster.info/wp-content/uploads/2023/08/3-1-768x432.webp 768w, https://bluehoster.info/wp-content/uploads/2023/08/3-1-1536x864.webp 1536w, https://bluehoster.info/wp-content/uploads/2023/08/3-1-150x84.webp 150w, https://bluehoster.info/wp-content/uploads/2023/08/3-1-696x392.webp 696w, https://bluehoster.info/wp-content/uploads/2023/08/3-1-1068x601.webp 1068w, https://bluehoster.info/wp-content/uploads/2023/08/3-1.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px"><figcaption>Add Slave Server in Virtualizor</figcaption></figure>
Enter the "Server Name" as you wish it to be identified. Then, enter the slave server’s "IP Address". In the "Server API Password" field, paste the API password you copied in the previous step. If you want to define an "Internal IP", you can enter it in the corresponding field.
Check the "Lock Server" checkbox if you want to prevent new VPS instances from being installed on the slave server. This is useful if the server is undergoing maintenance or is not yet ready for production.
Finally, select the appropriate "Server Group" from the drop-down list (the group you defined in Step 1).
Click on "Add Server" to add the new slave server to Virtualizor. You can view all your servers by navigating to the "Servers >> List Server" menu. Adding slave server in Virtualizor is now complete.
Conclusion
In this tutorial, we covered how to create a server group and region, retrieve slave server information, and add a slave server to the master server. If you have any questions about this process, feel free to ask. These are the best steps to add slave server in Virtualizor.
Alternative Solutions for Managing Slave Servers
While using the Virtualizor panel’s built-in functionality as described above is a straightforward approach, alternative methods exist for managing slave servers, offering different levels of automation and control. Here are two different ways:
1. Using the Virtualizor API Directly
Instead of relying solely on the web interface, you can interact with the Virtualizor API directly using scripting languages like Python or PHP. This allows for automated server provisioning, management, and monitoring.
Explanation:
The Virtualizor API provides a programmatic interface to manage servers, VPS instances, and other resources. By using API calls, you can automate tasks such as adding new slave servers, monitoring their status, and deploying VPS instances. This approach is beneficial for large-scale deployments or when integrating Virtualizor with other management systems.
Code Example (Python):
import requests
def add_slave_server(master_ip, master_api_key, server_name, server_ip, server_api_password, server_group):
url = f"http://{master_ip}:4085/index.php?act=server&ser_act=add"
params = {
"apikey": master_api_key,
"name": server_name,
"ip": server_ip,
"pass": server_api_password,
"groupid": server_group,
"output": "json"
}
try:
response = requests.post(url, data=params)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
data = response.json()
if data["done"] == 1:
print(f"Slave server '{server_name}' added successfully.")
else:
print(f"Error adding slave server: {data['error']}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
# Example Usage: Replace with your actual values
master_ip = "YOUR_MASTER_IP"
master_api_key = "YOUR_MASTER_API_KEY"
server_name = "slave-server-01"
server_ip = "SLAVE_SERVER_IP"
server_api_password = "SLAVE_SERVER_API_PASSWORD"
server_group = "1" # Replace with the actual group ID
add_slave_server(master_ip, master_api_key, server_name, server_ip, server_api_password, server_group)
Important Considerations:
- Security: Securely store and manage API keys. Avoid hardcoding them directly into scripts.
- Error Handling: Implement robust error handling to gracefully manage API failures.
- Rate Limiting: Be aware of any API rate limits and implement appropriate delays or retry mechanisms.
2. Using Configuration Management Tools (Ansible, Puppet, Chef)
Tools like Ansible, Puppet, or Chef can automate the configuration of both the master and slave servers, including the Virtualizor installation and the process of adding slave servers to the master.
Explanation:
Configuration management tools allow you to define the desired state of your servers and automatically enforce that state. You can use these tools to install Virtualizor, configure networking, and manage user accounts. Furthermore, you can automate the process of retrieving the slave server API key and adding the slave server to the master, eliminating manual steps.
Example (Ansible):
This example assumes that Virtualizor is already installed on both master and slave.
---
- hosts: master_server
tasks:
- name: Get slave server API key
command: ssh root@{{ slave_server_ip }} "/usr/bin/vzlicutil getapikey" # Replace /usr/bin/vzlicutil with correct path if needed
register: slave_api_key
delegate_to: localhost
- name: Add slave server to master
uri:
url: "http://{{ master_ip }}:4085/index.php?act=server&ser_act=add"
method: POST
body:
apikey: "{{ master_api_key }}"
name: "{{ slave_server_name }}"
ip: "{{ slave_server_ip }}"
pass: "{{ slave_api_key.stdout }}"
groupid: "{{ server_group_id }}"
output: "json"
body_format: form
return_content: yes
register: add_server_result
- debug:
var: add_server_result.content
Important Considerations:
- Idempotency: Ensure that your configuration management scripts are idempotent, meaning they can be run multiple times without causing unintended changes.
- Version Control: Store your configuration management scripts in a version control system like Git to track changes and facilitate collaboration.
- Testing: Thoroughly test your configuration management scripts before deploying them to production environments.
By leveraging these alternative methods, you can gain greater flexibility and control over your Virtualizor infrastructure, automating tasks and reducing manual intervention. Choose the solution that best aligns with your technical expertise and specific requirements. The article has covered the best steps to add slave server in Virtualizor and alternative solutions.