Submarine needs to use the database to store information about the organization
, user
, projects
, tasks
, metastore
and configuration
of the system information, So consider using mysql to store this data.
- MySQL will be included in the
mini-submarine
docker image to allow users to quickly experience thesubmarine workbench
. - In a production environment, the
submarine workbench
can be connected to the official mysql database.
Must:
- MySQL
- MyBatis
By using the official docker image of submarine database, only one docker command is required to run submarine database
docker run -it -p 3306:3306 -d --name submarine-database -e MYSQL_ROOT_PASSWORD=password apache/submarine:database-0.4.0
It will create users and tables that submarine requires
sudo ./init-database
If you need to store Chinese character data in mysql, you need to execute the following command to modify the mysql character set.
-
Set database character set
bash > mysql -uroot -ppassword mysql>SHOW VARIABLES LIKE 'character_set_%'; // View database character set mysql>SHOW VARIABLES LIKE 'collation_%'; SET NAMES 'utf8';
-
Configuration
mysqld.cnf
# install vim apt-get update apt-get install vim vi /etc/mysql/mysql.conf.d/mysqld.cnf [mysqld] character_set_server = utf8 [mysql] default-character-set = utf8 [mysql.server] default-character-set = utf8 [mysqld_safe] default-character-set = utf8 [client] default-character-set = utf8
Copy the files, submarine.sql, submarine-data.sql and metastore.sql to the mysql docker.
docker cp ${SUBMARINE_HOME}/docs/database/submarine.sql ${DOCKER_ID}:/
docker cp ${SUBMARINE_HOME}/docs/database/submarine-data.sql ${DOCKER_ID}:/
docker cp ${SUBMARINE_HOME}/docs/database/metastore.sql ${DOCKER_ID}:/
Development database for development environment.
# in mysql container
bash > mysql -uroot -ppassword
mysql> CREATE USER IF NOT EXISTS 'submarine'@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'submarine'@'%';
mysql> CREATE DATABASE IF NOT EXISTS submarine CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> use submarine;
mysql> source /submarine.sql;
mysql> source /submarine-data.sql;
mysql> CREATE USER IF NOT EXISTS 'metastore'@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'metastore'@'%';
mysql> CREATE DATABASE IF NOT EXISTS metastore CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> use metastore;
mysql> source /metastore.sql;
mysql> quit
NOTE: submarine development database name is
submarine
and user name issubmarine
, password ispassword
, metastore development database name ismetastore
and user name ismetastore
, password ispassword
, This is the default value in the system'ssubmarine-site.xml
configuration file and is not recommended for modification.
Test database for program unit testing and Travis test environment.
# in mysql container
bash > mysql -uroot -ppassword
mysql> CREATE USER IF NOT EXISTS 'submarine_test'@'%' IDENTIFIED BY 'password_test';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'submarine_test'@'%';
mysql> CREATE DATABASE IF NOT EXISTS `submarine_test` CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> use `submarine_test`;
mysql> source /submarine.sql;
mysql> CREATE USER IF NOT EXISTS 'metastore_test'@'%' IDENTIFIED BY 'password_test';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'metastore_test'@'%';
mysql> CREATE DATABASE IF NOT EXISTS `metastore_test` CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> use `metastore_test`;
mysql> source /metastore.sql;
mysql> quit
NOTE: submarine test database name is
submarine_test
and user name issubmarine_test
, password ispassword_test
, metastore test database name ismetastore_test
and user name ismetastore_test
, password ispassword_test
, Cannot be configured, values that cannot be modified.
mysqldump -uroot -ppassword --databases submarine > submarine.sql;
mysqldump -umetastore -ppassword metastore > metastore.sql;
-
In the submarine's Travis, the
test database
,database name
,username
andpassword
will be automatically created based on the contents of this document.Therefore, do not modify the database's
database name
,username
andpassword
configuration to avoid introducing some problems. -
In the mysql database in Travis, the
submarine.sql
are executed to create the submarine database table structure and test data. -
The submarine database test case written in the
workbench-server
module will also be unit tested in the mysql database in travis.