Blog > How to implement rapid deployment of SequoiaDB cluster with Docker

How to implement rapid deployment of SequoiaDB cluster with Docker

 2019-03-15  SequoiaDB,Docker
How to implement rapid deployment of SequoiaDB cluster with Docker

Container technology, represented by Docker and Rocket, is becoming more and more popular. It changes the way companies and users create, publish, and use distributed applications, and it will bring its value to the cloud computing industry in the next five years. The reasons for its attractiveness are as follows:

1)Resource Independence and Isolation

Resource isolation is the most basic requirement of cloud computing platforms. Docker limits the hardware resources and software running environment through the Linux namespace, cgroup, and is isolated from other applications on the host machine, so it does not affect each other.

Different applications and service are “ship” and “unship” with the unit of container. Thousands of “containers” are arranged on the “container” ship. Different companies, different types of “goods” (programs, components, operating environments, dependencies required to run applications) remain independent.

2) Environmental Consistency

The development engineer builds a docker image after finishing the application development. Based on this image, the container is packaged with various “parts of goods” (programs, components, operating environment, dependencies required to run the application). No matter where the container is: development environment, test environment or production environment, you can ensure that the number of “goods” in the container is exactly the same, the software package will not be missing in the test environment, and the environmental variables will not be forgotten in the production environment. The development and production environment will not cause the application to run abnormally due to the dependency of installing different versions. This consistency is benefited by the fact that the “build docker image” is already sealed into the “container” when delivery, and each link is transporting this complete “container” that does not need to be split and merged.

3) Lightweight

Compared to traditional virtualization technology (VM), the performance loss of using docker on cpu, memory, disk IO, network IO has the same level or even better performance. The rapid creation, start-up, and destruction of containers have received a lot of praise.

4)Build Once, Run Everywhere

This feature has attracted many people. When the “goods” (application) is exchanged between “cars”, “trains”, “ships” (private clouds, public clouds, etc.), it only need to migrate the “docker container” which conform to the standard specifications and handling mode, which has reduced the time-consuming and labor-intensive manual “loading and unloading” (online and off-line applications), resulting in huge time labor cost savings. This feature makes it possible for only a few operators in the future to operate the container clusters for ultra-large-scale loading online applications, just as a few machine operators in the 1960s can unload a 10,000-class container ship in a few hours.

Container technology nowadays is also widely used in the database field. Its “Build Once, Run Everywhere” feature greatly reduces the time spent on installing the configuration database environment. Because even for DBAs who have been working with databases for many years, installing the configuration database environment is still a seemingly simple but often a complex work. Of course, other advantages of container technology are also well used in the application of databases.

As an excellent domestic distributed NewSQL database, SequoiaDB has been recognized by more and more users. This article takes Docker as an example, focusing on how to quickly build a SequoiaDB image with Dockerfile, and how to use the container to quickly build and start the SequoiaDB cluster to application system.

Build SequoiaDB image

How to install docker and configure repositories is not the focus of this article. There are many related technical articles on the Internet. It should be pointed out that this article uses Aliyun Repository, because the speed of uploading images to Docker official repository is unflattering. How to register and use the Aliyun Repository can refer to the article (

STEP 1: Create Dockerfile using following simple statements:

# --------------------------
# This is the Dockerfile for Sequoiadb 2.8.4
# ----------------------------------
# (1)
# (2)
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
#      $ sudo docker build -t sequoiadb:2.8.4 .
# Pull base image
   FROM ubuntu
# Environment variables required for this build
# Copy binaries
# Install SDB software binaries

The content of the script are as follows:

$INSTALL_DIR/$INSTALL_BIN_FILE --mode unattended
echo 'service sdbcm start' >> /root/.bashrc

It should to be noted that this example uses SequoiaDB Enterprise Edition 2.8.4. You can also download the community version from the official website of SequoiaDB (select tar package, download and extract), and replace the media name in this example.

SequoiaDB website download address:

STEP 2: Create an image

The root user executes:

docker build -t sequoiadb:2.8.4 .

If you are a normal user, use sudo:

sudo docker build -t sequoiadb:2.8.4 .

STEP3: Login to Aliyun Repository

docker login --username=xxx
Where xxx is the account you registered with Alibaba Cloud.

STEP4: View local SequoiaDB image id

docker images

STEP5: Mark local image and put it into Aliyun Repository

docker tag 04dc528f2a6f
04dc528f2a6f is the author’s local sequoiadb image id, is the Aliyun Repository address, 508mars is the author’s name in Aliyun, SequoiaDB is the image name, and latest is the tag.

STEP6:Submit Sequoiadb image to image library

docker push

Start SequoiaDB cluster with container

Docker’s network defaults to bridge mode, and containers in bridge mode have the following characteristics:

1) Containers in the same host can ping each other

2) Containers in different hosts can not ping each other

However, the SequoiaDB cluster requires interoperability between all nodes, so if the container with SequoiaDB is running on different hosts, the default network mode of docker is obviously inappropriate. There are many ways to solve the connectivity problem between different host containers. This article only introduces the weave virtual network solution, because weave also provides a DNS server function. When deploying SequoiaDB clusters with containers using this function, it is no longer necessary to modify /etc/hosts inside each container, which greatly simplifies the steps of automated deployment.

STEP1: Install the weave network

curl -s -L -o /usr/local/bin/weave
chmod a+x /usr/local/bin/weave

It needs to install on all hosts, the author uses three virtual machines as hosts: sdb1, sdb2 and sdb3.

STEP2: Start the weave network

weave launch

The weave image will be downloaded the first time it is started.

STEP3: Download the SequoiaDB image from Aliyun Repository

docker pull

STEP4: Create a docker mounted volume on all hosts

cd /home/sdbadmin
mkdir -p data/disk1 data/disk2 data/disk3
mkdir -p conf/local
chmod -R 777 data
chmod -R 777 conf

The location of the mounted volume can be customized, but in general, it needs to create two types of mounted volumes, one for storing aggregate data, such as data/disk1, data/disk2, data/disk3, and so on. The other is used to store node configuration information, such as conf/local in this example. Thus, even if the container is deleted by mistake, you can still start a new container to play the role of the container that was accidentally deleted.

STEP5: Start the container


weave stop
weave launch
eval $(weave env)
docker run -dit --name sdbserver1 -p 11810:11810 -v /home/sdbadmin/data:/data -v /home/sdbadmin/conf/local:/opt/sequoiadb/conf/local


weave stop
weave launch
eval $(weave env)
docker run -dit --name sdbserver2 -p 11810:11810 -v /home/sdbadmin/data:/data -v /home/sdbadmin/conf/local:/opt/sequoiadb/conf/local


weave stop
weave launch
eval $(weave env)
docker run -dit --name sdbserver3 -p 11810:11810 -v /home/sdbadmin/data:/data -v /home/sdbadmin/conf/local:/opt/sequoiadb/conf/local is the IP address of sdb1 and 11810 is the externally exposed cluster access port. The volume on the host that stores the node configuration information must be hung in the /opt/sequoiadb/conf/local directory of the container. The volume that holds the table data can be mounted to the user-defined directory. However, once the cluster is created, it cannot be changed. The machine name must be specified when starting the container, because after the cluster is built, the machine name will be saved in the system table of SequoiaDB. If the machine name of the node is inconsistent with the system table, it will not be added to the cluster. In the scenario of using weave, it is recommended to use the--name option. Do not use--hostname to set the machine name. The latter will prevent weave from adding the machine name to the DNS server. Weave will automatically set the machine name according to the value of --name, and add the weave.local domain name after the machine name. Also, it will add it to the DNS server.

STEP6: Copy the script that created the SequoiaDB cluster to the container

docker cp create_cluster.js sdbserver1:/data

The content of create_cluster.js is as follows:

var array_hosts = ["sdbserver1.weave.local", "sdbserver2.weave.local", "sdbserver3.weave.local"];
var array_dbroot = ["/data/disk1/sequoiadb/database","/data/disk2/sequoiadb/database","/data/disk3/sequoiadb/database"];
var port_sdbcm = "11790";
var port_temp_coord = "18888";
var cataloggroup = {gname:"SYSCatalogGroup", gport:"11820", ghosts:["sdbserver1.weave.local", "sdbserver2.weave.local", "sdbserver3.weave.local"]};
var array_coordgroups = [
        {gname:"SYSCoord", gport:"11810", ghosts:["sdbserver1.weave.local", "sdbserver2.weave.local", "sdbserver3.weave.local"]}
var array_datagroups = [
        {gname:"dg1", gport:"11830", ghosts:["sdbserver1.weave.local", "sdbserver2.weave.local", "sdbserver3.weave.local"], goptions:{transactionon:true}}
       ,{gname:"dg2", gport:"11840", ghosts:["sdbserver1.weave.local", "sdbserver2.weave.local", "sdbserver3.weave.local"], goptions:{transactionon:true}}
       ,{gname:"dg3", gport:"11850", ghosts:["sdbserver1.weave.local", "sdbserver2.weave.local", "sdbserver3.weave.local"], goptions:{transactionon:true}}
var array_domains = [
        {dname:"allgroups", dgroups:["dg1", "dg2", "dg3"], doptions:{AutoSplit:true}}
var oma = new Oma(array_coordgroups[0].ghosts[0], port_sdbcm);
oma.createCoord(port_temp_coord, array_dbroot[0]+"/coord/"+port_temp_coord);
println("创建编目节点组:"+cataloggroup.ghosts[0]+"   "+cataloggroup.gport+"    "+array_dbroot[0]+"/cata/"+cataloggroup.gport);
var db = new Sdb(array_coordgroups[0].ghosts[0], port_temp_coord);
db.createCataRG(cataloggroup.ghosts[0], cataloggroup.gport, array_dbroot[0]+"/cata/"+cataloggroup.gport);
var cataRG = db.getRG("SYSCatalogGroup");
for (var i in cataloggroup.ghosts) {
        if (i==0) {continue;}
    println("创建编目节点: "+cataloggroup.ghosts[i]+"  "+cataloggroup.gport+"    "+array_dbroot[0]+"/cata/"+cataloggroup.gport);
        var catanode = cataRG.createNode(cataloggroup.ghosts[i], cataloggroup.gport, array_dbroot[0]+"/cata/"+cataloggroup.gport);
var db = new Sdb(array_coordgroups[0].ghosts[0], port_temp_coord);
var coordRG = db.createCoordRG();
for (var i in array_coordgroups) {
        for (var j in array_coordgroups[i].ghosts) {
                println("创建协调节点组:"+array_coordgroups[i].ghosts[j]+"    "+array_coordgroups[i].gport+"    "+array_dbroot[0]+"/coord/"+array_coordgroups[i].gport);
                coordRG.createNode(array_coordgroups[i].ghosts[j], array_coordgroups[i].gport, array_dbroot[0]+"/coord/"+array_coordgroups[i].gport);
var oma = new Oma(array_coordgroups[0].ghosts[0], port_sdbcm);
var db = new Sdb(array_coordgroups[0].ghosts[0], array_coordgroups[0].gport);
var k=0;
for (var i in array_datagroups) {
        var dataRG = db.createRG(array_datagroups[i].gname);
        for (var j in array_datagroups[i].ghosts) {
                println("创建数据节点:"+array_datagroups[i].gname+"    "+array_datagroups[i].ghosts[j]+"   "+array_datagroups[i].gport+"    "+array_dbroot[k]+"/data/"+array_datagroups[i].gport+"    "+array_datagroups[i].goptions)
                dataRG.createNode(array_datagroups[i].ghosts[j], array_datagroups[i].gport, array_dbroot[k]+"/data/"+array_datagroups[i].gport, array_datagroups[i].goptions);
var db = new Sdb(array_coordgroups[0].ghosts[0], array_coordgroups[0].gport);
for (var i in array_domains) {
        println("创建域:"+array_domains[i].dname+"   "+array_domains[i].dgroups+"    "+array_domains[i].doptions)
        db.createDomain(array_domains[i].dname, array_domains[i].dgroups, array_domains[i].doptions );

STEP7: Create a SequoiaDB cluster

docker exec sdbserver1 su - sdbadmin -c "sdb -f /data/create_cluster.js

Now, SequoiaDB cluster is created and started, and the cluster will start automatically when you start the container.


SequoiaDB uses container technology to achieve rapid cluster deployment, which greatly simplifies the installation and deployment of beginners. Later, the author will also do some optimization on SequoiaDB image production, because the image currently made is a bit large. The main reason is that using the ADD or COPY command to copy the CD-ROM toward the Docker container will generate a new image1, although the finally generated image2 has been deleted CD-ROM, it is above image1, and the size of image2 still contains the CD-ROM. Thus, it is best to use ADD command to copy tar package(ADD automatically decompress ) or use a method as follows:

RUN mkdir -p /usr/src/things \
&& curl -SL \
| tar -xJC /usr/src/things \
&& make -C /usr/src/things all
Ready to get started with SequoiaDB?