Skip to content

Periodically check Vultr servers and auto repair by snapshot binding with Aliyun domain

Notifications You must be signed in to change notification settings

Fantastic8/Vultr-Aliyun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vultr-Aliyun

Vultr-Aliyun is a command-line tool which helps to automatically redeploy blocked server and synchronize with Aliyun domain and Vultr snapshot.

Also see 中文文档

Quick Start

To run Vultr-Aliyun tool:

python3 vultr.py

And you can see a list of all your records and main menu.

Main Menu

Then select 13 to start monitoring.

Monitoring

It's better if you run this tool as a background process, so that monitoring process will continue when you log out from SSH, and you can achieve that by using screen.

Prerequisites

Requirements

Installation

Install Mysql

Install tcping

Install python3:

sudo apt-get install python3

Install pymysql

sudo apt-get install python3-pip
pip3 install PyMySQL

Install Aliyun SDK:

sudo pip3 install aliyun-python-sdk-core-v3

Download Vultr-Aliyun using git clone:

git clone https://github.com/Fantastic8/Vultr-Aliyun.git

Configuration

Set up Mysql:

  1. Create a mysql user
  2. Create a database for Vultr-Aliyun

Set up vultr.py:

cd Vultr-Aliyun
vi vultr.py

Modify the following:

MYSQL_USER = 'Your mysql user name'
MYSQL_PASSWD = 'Your mysql user password'
MYSQL_DB = 'Your mysql database name'
VULTR_KEY = 'Vultr api key'
ALI_ACCESS_KEY_ID = 'Aliyun access key id'
ALI_ACCESS_KEY_SECRET = 'Aliyun access key secret'
client = AcsClient(ALI_ACCESS_KEY_ID, ALI_ACCESS_KEY_SECRET, 'cn-hangzhou')
DOMAIN_NAME = 'Aliyun domain name'
logf_name = 'vultr.log' # vultr log file name

# interval better be greater than 5 minutes
CHECK_INTERVAL_MAX = 10 # maximum check interval (minutes)
CHECK_INTERVAL_MIN = 4  # minimum check interval (minutes)
check_int = CHECK_INTERVAL_MAX
CHECK_PORT = '1010' # slave's port which master will use tcping to check, make sure this port is open on slave server!
RANDOM_REGION = True # True: randomly select new region from REGION_LIST when detected a blocked server; False: keep the same region as the old server
REGION_LIST = ['Atlanta', 'Dallas', 'Chicago', 'Los Angeles', 'Silicon Valley', 'Seattle', 'Miami'] # regions that can be randomly selected for new server

After that, you can run vultr.py:

python3 vultr.py

Why you need a Vultr Snapshot

When you deploy a server on vultr, there is a chance that this IP will be blocked in the future. So after configuration of your server and keeping all services running, you can create a snapshot of server so that it will automatically resume to the point where you create a snapshot at when this server has been blocked.

Structure

Structure

Usage

See usage for more details.

Warning

  • All vultr servers that not exist in chain record will be deleted !!!!!! Please add all your vultr servers into chain record.
  • Please prepare your vultr servers, snapshots and Aliyun domain records first, then add chain record in Vultr-Aliyun.
  • Please delete related chain record before you delete server instance or snapshot or domain record.
  • Please check vultr.log if anything goes wrong.
  • Usually need to wait until second checking interval to repair chain completely, because server needs time to reboot.

Author

About

Periodically check Vultr servers and auto repair by snapshot binding with Aliyun domain

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published