CBoard开源数据可视化工具
文章目录
- CBoard开源数据可视化工具
-
- 介绍
- 资源列表
- 基础环境
- 一、安装JDK
- 二、安装Maven
- 三、安装Tomcat8
- 四、安装MySQL5版本
- 五、安装PhantomJS
- 六、git下载源码包
- 七、修改Maven配置文件
- 八、设置平台默认语言
- [九、删除SQL server驱动](#九、删除SQL server驱动)
- 十、初始化元数据
- 十一、打包源代码
- 十二、MySQL授权
- 十三、访问
- 十四、解决登录进入Error报错
介绍
- 什么是CBoard?CBoard是一个开源的数据可视化工具,皆在简化数据分析过程并提供美观、交互性强的仪表盘。该项目由张洋开发,并在GitCode上分享,让更多的开发者和数据分析师能够轻松地创建、分享和协作他们的数据故事。
资源列表
操作系统 | 配置 | 主机名 | IP | 所需软件 |
---|---|---|---|---|
CentOS 7.9 | 8C4G | cboard | 192.168.93.101 | apache-maven-3.9.0-bin.tar.gz apache-tomcat-8.5.78.tar.gz jdk-8u162-linux-x64.tar.gz mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz phantomjs-2.1.1-linux-x86_64.tar.bz2 |
win 11 | 略 | 略 | 略 | Edge浏览器 |
基础环境
- 关闭防火墙
shell
systemctl stop firewalld
systemctl disable firewalld
- 关闭内核安全机制
shell
setenforce 0
sed -i "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
- 修改主机名
shell
hostnamectl set-hostname cboard
一、安装JDK
shell
# 卸载原有的JDK环境
[root@cboard ~]# yum -y remove java*
# 安装新的JDK环境
[root@cboard ~]# tar -zxvf jdk-8u162-linux-x64.tar.gz
[root@cboard ~]# mv jdk1.8.0_162 /usr/local/java
[root@cboard ~]# vim /etc/profile
export JAVA_HOME=/usr/local/java/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[root@cboard ~]# source /etc/profile
[root@cboard ~]# java -version # 查看版本
java version "1.8.0_162"
二、安装Maven
- 作用:用于项目管理和构建的开源工具
2.1、安装Maven
shell
[root@cboard ~]# tar -zxvf apache-maven-3.9.0-bin.tar.gz
[root@cboard ~]# mv apache-maven-3.9.0 /usr/local/maven
[root@cboard ~]# vim /etc/profile
MAVEN_HOME=/usr/local/maven
PATH=$PATH:$MAVEN_HOME/bin
[root@cboard ~]# mvn -version # 查看Maven版本
Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
2.2、配置Maven
- 默认使用的是国外的仓库,改为阿里云
- 默认大概是在153行左右,把注释去掉,更改为下面的内容
shell
[root@cboard ~]# vim /usr/local/maven/conf/settings.xml
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
三、安装Tomcat8
shell
[root@cboard ~]# tar -zxvf apache-tomcat-8.5.78.tar.gz
[root@cboard ~]# mv apache-tomcat-8.5.78 /usr/local/tomcat8
四、安装MySQL5版本
4.1、安装相关依赖
- 卸载CentOS 7系统自带的数据库
shell
[root@cboard ~]# yum -y remove mariadb*
- 安装一些基础工具(minni系统)
shell
[root@cboard ~]# yum -y install vim wget net-tools lrzsz
- 安装MySQL依赖软件包
shell
[root@cboard ~]# yum -y install libaio gcc gcc-c++
- 创建运行MySQL程序的用户
shell
[root@cboard ~]# useradd -M -s /sbin/nologin mysql
4.2、二进制安装
shell
[root@cboard ~]# tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@cboard ~]# mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql
[root@cboard ~]# mkdir /usr/local/mysql/data
[root@cboard ~]# chown -R mysql:mysql /usr/local/mysql/data/
[root@cboard ~]# cd /usr/local/mysql/bin/
# 执行下面命令配置和初始化数据库,回显的最后12字母就是临时root密码,要牢记,等下会用到
[root@cboard bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
######## 部分内容省略
2024-05-01T02:37:58.642067Z 1 [Note] A temporary password is generated for root@localhost: gCqlrw1yOH=a
######## 部分内容省略
4.3、设定配置文件
- 二进制安装的MySQL配置文件跟源码编译安装的配置文件类似。
shell
[root@cboard ~]# vim /etc/my.cnf
[client]
socket=/usr/local/mysql/data/mysql.sock
[mysqld]
socket=/usr/local/mysql/data/mysql.sock
# 绑定监听地址0.0.0.0
bind-address = 0.0.0.0
# 禁止域名解析,减少mysql对外部连接客户端DNS解析的时间
skip-name-resolve
# 设置端口为3306
port=3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=2048
# 服务端使用的字符集默认为utf8
character-set-server=utf8
# 创建新表时将使用默认存储引擎
default-storage-engine=INNODB
# sql语句不区分大小写
lower_case_table_names=1
# 设置一次消息传输的最大值
max_allowed_packet=16M
- 将MySQL的可执行文件写入环境变量中
shell
[root@cboard ~]# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@cboard ~]# . /etc/profile
4.4、配置systemcatl方式启动
shell
[root@cboard ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@cboard ~]# chmod +x /etc/rc.d/init.d/mysqld
[root@cboard ~]# vim /lib/systemd/system/mysqld.service
[Unit]
Description=mysqld
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.d/init.d/mysqld start
ExecReload=/etc/rc.d/init.d/mysqld restart
ExecStop=/etc/rc.d/init.d/mysqld stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@cboard ~]# systemctl daemon-reload
[root@cboard ~]# systemctl start mysqld
[root@cboard ~]# systemctl enable mysqld
4.5、访问MySQL数据库
- 使用临时密码登录数据库,修改root密码
shell
[root@cboard ~]# mysql -u root -p
Enter password: # 输入临时密码
mysql> set password=password('wzh.2005');
五、安装PhantomJS
- 如果想要看板导出和邮件功能,需要安装
shell
# 安装软件依赖
[root@cboard ~]# yum install -y gcc gcc-c++ make git openssl-devel freetype-devel fontconfig-devel
[root@cboard ~]# yum install -y bitmap-fonts bitmap-fonts-cjk
[root@cboard ~]# yum -y install bzip2
[root@cboard ~]# tar xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
[root@cboard ~]# mv phantomjs-2.1.1-linux-x86_64 /usr/local/
[root@cboard ~]# ln -sf /usr/local/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/
六、git下载源码包
- 安装git工具
shell
[root@cboard ~]# yum -y install git*
- 克隆源码包
shell
[root@cboard ~]# git clone https://github.com/yzhang921/CBoard.git
# 拷贝之后root目录下就会有一个CBoard的目录
[root@cboard ~]# ls CBoard/
changelog imgs LICENSE.txt README.md sql
Dockerfile lib pom.xml Readme_zh.md src
[root@cboard ~]# cd CBoard/
# 使用的版本是0.4
[root@cboard CBoard]# git checkout branch-0.4
分支 branch-0.4 设置为跟踪来自 origin 的远程分支 branch-0.4。
切换到一个新分支 'branch-0.4'
七、修改Maven配置文件
shell
[root@cboard ~]# vim CBoard/src/main/resources/config.properties
validationQuery=SELECT 1
jdbc_url=jdbc:mysql://192.168.93.101:3306/cboard # 修改,下面会导入元数据文件cboard数据库
jdbc_username=root # MySQL用户
jdbc_password=wzh.2005 # MySQl用户密码
dataprovider.resultLimit=3000000 # 修改
admin_user_id=1
phantomjs_path=/usr/local/phantomjs-2.1.1-linux-x86_64/bin/phantomjs # 修改为phantomjs的绝对安装路径即可
八、设置平台默认语言
shell
[root@cboard ~]# vim CBoard/src/main/webapp/org/cboard/Settings.js
var settings = {
preferredLanguage: "cn" // en/cn: 可选值en/cn
};
九、删除SQL server驱动
- 由于源代码以来中默认包含了SQL Server的JDBC驱动,但是该驱动在共有Maven仓库不存在。这个实验的使用不设计SQL Server数据库,所以把CMoard目录下的pom.xml中的下面依赖删除
shell
[root@cboard ~]# vim CBoard/pom.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
十、初始化元数据
- 安装unzip,解压sql脚本
shell
[root@cboard ~]# yum -y install unzip.x86_64
[root@cboard ~]# unzip foodmart.zip
- 导入数据
sql
[root@cboard ~]# mysql -u root -pwzh.2005
mysql> create database cboard;
mysql> use cboard
mysql> source /root/CBoard/sql/mysql/mysql.sql
mysql> source /root/foodmart.sql
mysql> source /root/cboard_demo.sql
# 查询数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cboard |
| cboard_demo2 |
| foodmart2 |
| mysql |
| performance_schema |
| sys |
+--------------------+
7 rows in set (0.00 sec)
十一、打包源代码
- 进入源码包执行打包命令
shell
[root@cboard ~]# cd CBoard/
[root@cboard CBoard]# mvn install:install-file -Dfile=lib/sqljdbc4-4.0.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar
[root@cboard CBoard]# mvn clean package
- 打包完成之后,CMoard目录下会多出一个target目录,这个目录下面有我们需要的cboard.war文件,拷贝文件到tomcat目录下的webaaps目录下,然后开启服务,tomcat会自动解析cboard.war文件,然后生成一个cboard目录
shell
[root@cboard CBoard]# cp -p target/cboard.war /usr/local/tomcat8/webapps/
[root@cboard CBoard]# /usr/local/tomcat8/bin/startup.sh
十二、MySQL授权
- 分别对cboard、cboard_demo2、foodmart2三个数据库进行授权
shell
[root@cboard ~]# mysql -u root -pwzh.2005
mysql> GRANT ALL PRIVILEGES ON cboard.* TO 'root'@'%' IDENTIFIED BY 'wzh.2005' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON foodmart2.* TO 'root'@'%' IDENTIFIED BY 'wzh.2005' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON cboard_demo.* TO 'root'@'%' IDENTIFIED BY 'wzh.2005' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
十三、访问
-
默认用户:admin 默认密码:root123
十四、解决登录进入Error报错
- 删除掉cboard,用最笨重的方法,一个一个的SQL指令执行,
sql
mysql> CREATE DATABASE cboard CHARACTER SET utf8;
mysql> USE cboard;
mysql> CREATE TABLE dashboard_board (
-> board_id bigint(20) NOT NULL AUTO_INCREMENT,
-> user_id varchar(50) NOT NULL,
-> category_id bigint(20) DEFAULT NULL,
-> board_name varchar(100) NOT NULL,
-> layout_json text,
-> PRIMARY KEY (board_id)
-> );
mysql> CREATE TABLE dashboard_category (
-> category_id bigint(20) NOT NULL AUTO_INCREMENT,
-> category_name varchar(100) NOT NULL,
-> user_id varchar(100) NOT NULL,
-> PRIMARY KEY (category_id)
-> );
mysql> CREATE TABLE dashboard_datasource (
-> datasource_id bigint(20) NOT NULL AUTO_INCREMENT,
-> user_id varchar(50) NOT NULL,
-> source_name varchar(100) NOT NULL,
-> source_type varchar(100) NOT NULL,
-> config text,
-> PRIMARY KEY (datasource_id)
-> );
mysql> CREATE TABLE dashboard_widget (
-> widget_id bigint(20) NOT NULL AUTO_INCREMENT,
-> user_id varchar(100) NOT NULL,
-> category_name varchar(100) DEFAULT NULL,
-> widget_name varchar(100) DEFAULT NULL,
-> data_json text,
-> PRIMARY KEY (widget_id)
-> );
mysql> CREATE TABLE dashboard_dataset (
-> dataset_id bigint(20) NOT NULL AUTO_INCREMENT,
-> user_id varchar(100) NOT NULL,
-> category_name varchar(100) DEFAULT NULL,
-> dataset_name varchar(100) DEFAULT NULL,
-> data_json text,
-> PRIMARY KEY (dataset_id)
-> );
mysql> CREATE TABLE dashboard_user (
-> user_id varchar(50) NOT NULL,
-> login_name varchar(100) DEFAULT NULL,
-> user_name varchar(100) DEFAULT NULL,
-> user_password varchar(100) DEFAULT NULL,
-> user_status varchar(100) DEFAULT NULL,
-> PRIMARY KEY (user_id)
-> );
mysql> INSERT INTO dashboard_user (user_id,login_name,user_name,user_password)
-> VALUES('1', 'admin', 'Administrator', 'ff9830c42660c1dd1942844f8069b74a');
mysql> CREATE TABLE dashboard_user_role (
-> user_role_id bigint(20) NOT NULL AUTO_INCREMENT,
-> user_id varchar(100) DEFAULT NULL,
-> role_id varchar(100) DEFAULT NULL,
-> PRIMARY KEY (user_role_id)
-> );
mysql> CREATE TABLE dashboard_role (
-> role_id varchar(100) NOT NULL,
-> role_name varchar(100) DEFAULT NULL,
-> user_id varchar(50) DEFAULT NULL,
-> PRIMARY KEY (role_id)
-> );
mysql> CREATE TABLE dashboard_role_res (
-> role_res_id bigint(20) NOT NULL AUTO_INCREMENT,
-> role_id varchar(100) DEFAULT NULL,
-> res_type varchar(100) DEFAULT NULL,
-> res_id bigint(20) DEFAULT NULL,
-> permission varchar(20) DEFAULT NULL,
-> PRIMARY KEY (role_res_id)
-> );
mysql> CREATE TABLE dashboard_job (
-> job_id bigint(20) NOT NULL AUTO_INCREMENT,
-> job_name varchar(200) DEFAULT NULL,
-> cron_exp varchar(200) DEFAULT NULL,
-> start_date timestamp NULL DEFAULT NULL,
-> end_date timestamp NULL DEFAULT NULL,
-> job_type varchar(200) DEFAULT NULL,
-> job_config text,
-> user_id varchar(100) DEFAULT NULL,
-> last_exec_time timestamp NULL DEFAULT NULL,
-> job_status bigint(20),
-> exec_log text,
-> PRIMARY KEY (job_id)
-> );
mysql> CREATE TABLE dashboard_board_param (
-> board_param_id bigint(20) NOT NULL AUTO_INCREMENT,
-> user_id varchar(50) NOT NULL,
-> board_id bigint(20) NOT NULL,
-> config text,
-> PRIMARY KEY (board_param_id)
-> );
mysql> ALTER TABLE dashboard_dataset ADD create_time TIMESTAMP DEFAULT now();
mysql> ALTER TABLE dashboard_dataset ADD update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
mysql> UPDATE dashboard_dataset SET update_time = create_time;
mysql> CREATE TRIGGER insert_dataset_update_time_trigger
-> BEFORE INSERT ON dashboard_dataset FOR EACH ROW SET new.update_time = now();
mysql> CREATE TRIGGER update_dataset_update_time_trigger
-> BEFORE UPDATE ON dashboard_dataset FOR EACH ROW SET new.update_time = now();
mysql> ALTER TABLE dashboard_datasource ADD create_time TIMESTAMP DEFAULT now();
mysql> ALTER TABLE dashboard_datasource ADD update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
mysql> UPDATE dashboard_datasource SET update_time = create_time;
mysql> CREATE TRIGGER insert_datasource_update_time_trigger
-> BEFORE INSERT ON dashboard_datasource FOR EACH ROW SET new.update_time = now();
mysql> CREATE TRIGGER update_datasource_update_time_trigger
-> BEFORE UPDATE ON dashboard_datasource FOR EACH ROW SET new.update_time = now();
mysql> ALTER TABLE dashboard_widget ADD create_time TIMESTAMP DEFAULT now();
mysql> ALTER TABLE dashboard_widget ADD update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
mysql> UPDATE dashboard_widget SET update_time = create_time;
mysql> CREATE TRIGGER insert_widget_update_time_trigger
-> BEFORE INSERT ON dashboard_widget FOR EACH ROW SET new.update_time = now();
mysql> CREATE TRIGGER update_widget_update_time_trigger
-> BEFORE UPDATE ON dashboard_widget FOR EACH ROW SET new.update_time = now();
mysql> ALTER TABLE dashboard_board ADD create_time TIMESTAMP DEFAULT now();
mysql> ALTER TABLE dashboard_board ADD update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
mysql> UPDATE dashboard_board SET update_time = create_time;
mysql> CREATE TRIGGER insert_board_update_time_trigger
-> BEFORE INSERT ON dashboard_board FOR EACH ROW SET new.update_time = now();
mysql> CREATE TRIGGER update_board_update_time_trigger
-> BEFORE UPDATE ON dashboard_board FOR EACH ROW SET new.update_time = now();