Skip to content

Commit ceae951

Browse files
committed
New translations advanced_deployment.md (Chinese Simplified)
1 parent e88d231 commit ceae951

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
id: version-0.6.0-advanced_deployment
3+
title: Private Deploy
4+
original_id: advanced_deployment
5+
---
6+
7+
## Deploy with CovenantSQL Docker
8+
9+
### Install Docker
10+
11+
You need to install docker and docker-compose on your machine to deploy CovenantSQL.
12+
13+
Docker:https://docs.docker.com/install/
14+
15+
Docker-Compose:https://docs.docker.com/compose/install/
16+
17+
### Download project
18+
19+
```bash
20+
git clone https://github.com/CovenantSQL/CovenantSQL
21+
cd CovenantSQL
22+
```
23+
24+
For all subsequent commands, the working directory is by default in the cloned CovenantSQL root directory, which can be saved as an environment variable:
25+
26+
```bash
27+
export COVENANTSQL_ROOT=$PWD
28+
```
29+
30+
### Start Docker container
31+
32+
There are now two ways to start the CovenantSQL container:
33+
34+
1. Use a public image on Docker Hub
35+
2. Build a CovenantSQL Docker image
36+
37+
> We recommend that regular users test CovenantSQL in the first way, and the second is only used to experience the latest development features.
38+
39+
#### 1. Use a public image on Docker Hub
40+
41+
Then start directly:
42+
43+
```bash
44+
make start
45+
```
46+
47+
#### 2. Build a CovenantSQL Docker image
48+
49+
Run CovenantSQL locally by executing the following command
50+
51+
```bash
52+
make docker # compile a new image from source files
53+
make start
54+
```
55+
56+
### Check running status
57+
58+
Check the container status:
59+
60+
```bash
61+
docker-compose ps
62+
```
63+
64+
Confirm that all components are in the `Up` state
65+
66+
Name Command State Ports
67+
------------------------------------------------------------------------------------------------------
68+
covenantsql_bp_0 "./docker-entry.sh" Up 0.0.0.0:11099->4661/tcp
69+
covenantsql_bp_1 "./docker-entry.sh" Up 0.0.0.0:11100->4661/tcp
70+
covenantsql_bp_2 "./docker-entry.sh" Up 0.0.0.0:11101->4661/tcp
71+
covenantsql_miner_0 "./docker-entry.sh" Up 0.0.0.0:11102->4661/tcp
72+
covenantsql_miner_1 "./docker-entry.sh" Up 0.0.0.0:11103->4661/tcp
73+
covenantsql_miner_2 "./docker-entry.sh" Up 0.0.0.0:11104->4661/tcp
74+
covenantsql_adapter "./docker-entry.sh" Up 0.0.0.0:11105->4661/tcp
75+
covenantsql_mysql_adapter "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11107->4664/tcp
76+
covenantsql_observer "./docker-entry.sh" Up 4661/tcp, 0.0.0.0:11108->80/tcp
77+
covenantsql_fn_0 "./docker-entry.sh -…" Up 4661/tcp, 0.0.0.0:11110->8546/tcp
78+
79+
80+
## Operate CovenantSQL
81+
82+
### Create a database
83+
84+
Create a DB instance by using the `cql` command and using the `create` parameter to provide the required number of database nodes.
85+
86+
e.g.: creating a single-node database instance
87+
88+
```bash
89+
docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 1
90+
```
91+
92+
> Modify the value of the `create` parameter to create an instance running on multiple nodes
93+
> e.g.: create an instance of two nodes
94+
95+
```bash
96+
docker exec -it covenantsql_adapter /app/cql create -config /app/config.yaml -db-node 2
97+
```
98+
99+
The command will return the connection string of the created database instance
100+
101+
covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4
102+
103+
104+
### Accessing the database
105+
106+
Use the `cql` command and use the `dsn` parameter to provide a connection string for the database instance access:
107+
108+
```bash
109+
docker exec -it covenantsql_adapter /app/cql console -config /app/config.yaml covenantsql://0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4
110+
```
111+
112+
After that, it will get the following output, and enter the `cql` interactive command line mode
113+
114+
```
115+
116+
Connected with driver covenantsql (develop) Type "help" for help.
117+
118+
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=>
119+
120+
<br />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.
121+
122+
```sql
123+
CREATE TABLE test (test TEXT);
124+
SHOW TABLES;
125+
INSERT INTO test VALUES("happy");
126+
SELECT * FROM test;
127+
128+
129+
After that, it will get the following output:
130+
131+
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> CREATE TABLE test (test TEXT);
132+
CREATE TABLE
133+
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SHOW TABLES;
134+
name
135+
------
136+
test
137+
(1 row)
138+
139+
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> INSERT INTO test VALUES("happy");
140+
INSERT
141+
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=> SELECT * FROM test;
142+
test
143+
-------
144+
happy
145+
(1 row)
146+
147+
co:0a255f136520a2bc6a29055a619ec4f72c2c80fa600daf73b1caa375946ea0e4=>
148+
149+
150+
Use the `Ctrl + D` shortcut or type `\q` to exit the `cql` interactive command line
151+
152+
### SQLChain Observer
153+
154+
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.
155+
156+
(For details on rights management, please refer to [Database Permission Managemen](cql.md#数据库权限管理))
157+
158+
#### Use SQLChain Observer in your browser
159+
160+
We provide a SQLChain Observer at port `127.0.0.1:11108` to see the SQL statement on the chain.

0 commit comments

Comments
 (0)