Private Deploy
Deploy with CovenantSQL Docker
Install Docker
You need to install docker and docker-compose on your machine to deploy CovenantSQL.
Docker:https://docs.docker.com/install/
Docker-Compose:https://docs.docker.com/compose/install/
Download project
git clone https://github.com/CovenantSQL/CovenantSQL
cd CovenantSQL
For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable:
export COVENANTSQL_ROOT=$PWD
Start Docker container
There are now two ways to start the CovenantSQL container:
- Use a public image on Docker Hub
- Build a CovenantSQL Docker image
We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features.
1. Use a public image on Docker Hub
Then start directly:
make start
2. Build a CovenantSQL Docker image
Run CovenantSQL locally by executing the following command
make docker # compile a new image from source files
make start
Check running status
Check the container status:
docker-compose ps
Confirm that all components are in the Up
state
Name Command State Ports
------------------------------------------------------------------------------------------------------
covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp
covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp
covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp
covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp
covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp
covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp
covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp
covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp
covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp
covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp
Operate CovenantSQL
Create a database
Create a DB instance by using the cql
command and using the create
parameter to provide the required number of database nodes.
e.g.: creating a single-node database instance
cql create -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml -db-node 1
Modify the value of the
create
parameter to create an instance running on multiple nodes
e.g.: create an instance of two nodes
cql create -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml -db-node 2
The command will return the connection string of the created database instance
covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4
Accessing the database
Use the cql
command and use the dsn
parameter to provide a connection string for the database instance access:
cql console -config ${COVENANTSQL_ROOT}/test/service/node_c/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4
After that, it will get the following output, and enter the cql
interactive command line mode
Connected with driver covenantsql (develop)
Type "help" for help.
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=>
The cql
interactive command line mode is similar to the mysql
command. For example, create a table named test, view the tables in the database, insert records, and query results etc.
CREATE TABLE test (test TEXT);
SHOW TABLES;
INSERT INTO test VALUES("happy");
SELECT * FROM test;
After that, it will get the following output:
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT);
CREATE TABLE
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES;
name
------
test
(1 row)
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy");
INSERT
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test;
test
-------
happy
(1 row)
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=>
Use the Ctrl + D
shortcut or type \q
to exit the cql
interactive command line
SQLChain Observer
The Observer role in the image uses the same private.key as in the mysql-adapter image, so the new account authorization and transfer process can be eliminated.
(For details on rights management, please refer to Database Permission Managemen)
Use SQLChain Observer in your browser
We provide a SQLChain Observer at port 127.0.0.1:11108
to see the SQL statement on the chain.