Compare commits

..

No commits in common. "4aa272fc97508c630f778c746c6ce258d771528c" and "194e27045721dc91604e1fb029b1257da84ac4ee" have entirely different histories.

4 changed files with 2572 additions and 153 deletions

File diff suppressed because it is too large Load Diff

135
README.md
View File

@ -1,122 +1,37 @@
# 分布式数据管理 # distributeddatamgr_datamgr_service
分布式数据管理基于分布式软总线,实现了应用程序数据和用户数据的分布式管理。用户数据不再与单一物理设备绑定,业务逻辑与数据存储分离,应用跨设备运行时数据无缝衔接。 #### 介绍
Distributed Data Service (DDS) provides the capability to store data in the databases of different devices. DDS isolates data based on a triplet of the account, app, and database. DDS synchronizes data between trusted devices to provide users with consistent data access experience on different devices.
分布式数据管理由上游 `OpenHarmony 3.2 Release` 版本移植而来,目前包含四个组件: #### 软件架构
软件架构说明
| 组件 | 对应openEuler软件包 | 功能介绍 |
| --- | --- | --- |
| 分布式数据服务Distributed Data Service | distributeddatamgr_datamgr_service | 提供不同设备间数据库数据分布式的能力 |
| 键值对数据库KV store | distributeddatamgr_kv_store | 为设备应用提供键值对数据管理能力 |
| 关系型数据库Relational store | distributeddatamgr_relational_store | 基于关系模型来管理数据的数据库 |
| 分布式数据对象部件Data object | distributeddatamgr_data_object | 具备多设备数据同步的面向对象的内存数据管理框架 |
更多分布式数据管理介绍,可参考[上游 OpenHarmony 文档 “数据管理” 相关章节](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/database/data-mgmt-overview.md/)。
## 安装
分布式数据管理相关组件目前在 openEuler-22.03-LTS-SP2 update 版本 和openEuler-22.03-LTS-SP3 版本发布,两个版本下的安装略有不同。
### openEuler-22.03-LTS-SP2 版本
分布式数据管理首次发布于 openEuler-22.03-LTS-SP2 update版本如果是使用 openEuler-22.03-LTS-SP2 版本,需要配置 update 版本的 repo步骤如下
1. 在 `/etc/yum.repos.d` 目录下新增 update repo 配置文件 sp2_update.repo其内容填写如下
```config
[sp2_update]
name=sp2_update
baseurl=https://repo.openeuler.org/openEuler-22.03-LTS-SP2/EPOL/update/main/$basearch/
enabled=1
```
1. 更新 repo 源。(需要保证当前网络可以访问 https://repo.openeuler.org
```shell
dnf makecache
```
1. 下载安装分布式管理的四个软件包及其依赖软件包
```shell
dnf install distributeddatamgr_kv_store distributeddatamgr_relational_store distributeddatamgr_datamgr_service distributeddatamgr_data_object
```
1. 如果是 openEuler-22.03-LTS-SP2 版本,需要配置 SA 服务拉起需要的 profile 文件,可以从 [](https://gitee.com/heppen/distributed-files-for-test/tree/master/profile) 下载。
```shell
mkdir -p /system/profile
wget https://gitee.com/heppen/distributed-files-for-test/raw/master/profile/device_manager.xml -P /system/profile/
wget https://gitee.com/heppen/distributed-files-for-test/raw/master/profile/distributeddata.xml -P /system/profile/
wget https://gitee.com/heppen/distributed-files-for-test/raw/master/profile/distributedfiledaemon.xml -P /system/profile/
wget https://gitee.com/heppen/distributed-files-for-test/raw/master/profile/huks_service.xml -P /system/profile/
wget https://gitee.com/heppen/distributed-files-for-test/raw/master/profile/softbus_server.xml -P /system/profile/
```
1. 下载 [服务启停脚本](https://gitee.com/heppen/distributed-data-files/blob/master/scripts/)
```shell
wget https://gitee.com/heppen/distributed-data-files/raw/master/scripts/start_services.sh -P /system/bin/
wget https://gitee.com/heppen/distributed-data-files/raw/master/scripts/stop_services.sh -P /system/bin/
chmod +x /system/bin/*.sh
```
### openEuler-22.03-LTS-SP3 版本
分布式数据管理在 openEuler-22.03-LTS-SP3 版本已经默认集成,直接安装即可:
```shell
dnf install distributeddatamgr_kv_store distributeddatamgr_relational_store distributeddatamgr_datamgr_service distributeddatamgr_data_object
```
## 启动服务
1. 分布式数据服务可以通过 start_services.sh 脚本来启动
```shell
/system/bin/start_services.sh datamgr
```
1. 可以通过 ps 命令查看分布式数据管理服务是否拉起
```shell
ps -ef | grep distributeddata
```
## 使用分布式数据功能
1. 新建demo运行需要的/data目录。因为OpenHarmony下app运行有指定的目录需要在openEuler下先新增
```shell
mkdir -p /data/app/el0/0/database/com.example.distributed.rdb/rdb
mkdir -p /data/app/el1/0/database/distributeddata/kvdb
mkdir -p /data/service/el1/public/database/distributeddata/meta
mkdir -p /data/service/el1/public/database/distributeddata/kvdb
mkdir -p /data/service/el1/public/database/distributeddata/meta/backup
```
1. 编写三个数据库kv_store/data_object/relational_store的客户端程序使用分布式数据功能。
客户端程序编写可参考[仓库](https://gitee.com/heppen/distributed-data-files)每个数据库的 demo 源代码demo 在这个仓库每个数据库同名目录下的 demo目录下`kv_store/demo`,可使用对应目录下的 build.sh 脚本进行编译。
**注意demo 指定的数据 db 路径等,请最好保持和所给示例 demo 的路径一致,否则可能会存在路径不存在或者权限不足问题。**
1. 暂停分布式管理服务 datamgr_service #### 安装教程
```shell
./stop_services.sh all # 停止所有服务
./stop_services.sh datamgr # 停止datamgr一个服务
```
## 常见问题 1. xxxx
2. xxxx
3. xxxx
* 启动各个服务日志一直在报错 `Binder Driver died` #### 使用说明
原因:说明系统未开启 binder可以查看 `/dev/binder` 文件是否存在,如果不存在则说明未开启 binder。 1. xxxx
2. xxxx
3. xxxx
解决方法启动binder功能参考[communication_ipc仓库说明](https://gitee.com/src-openeuler/communication_ipc/blob/46d83ed1462e521ce356aec48ef980dbf84cff80/README.md)开启binder功能。 #### 参与贡献
* `softbus_server` 服务未成功起来,报错 `GetNetworkIfIp ifName:eth0 fail` 1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
原因:使用命令 `ip a` 查看当前系统的网卡名称,查看是否有 `eth0` 有线网卡名。 因为 `softbus_server` 是通过 `eth0` 这个有线网卡名来获取 ip 等信息,如果没有 `eth0` 网卡则无法启动 `softbus_server`
解决方法一:修改网卡名称为 `eth0` #### 特技
解决方法二:修改 `softbus_server` 源码,将依赖的有线网卡名称改成当前系统的网卡名。 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
## 参考 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
1. [分布式文件系统概述](https://docs.openeuler.org/zh/docs/22.03_LTS_SP2/docs/Distributed/%E5%88%86%E5%B8%83%E5%BC%8F%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84.html) 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -1,33 +1,24 @@
%define debug_package %{nil} %define debug_package %{nil}
%global oh_version OpenHarmony-v3.2-Release %global oh_version OpenHarmony-v3.2-Release
%global distributeddata_dir %{_builddir}/foundation/distributeddatamgr/ %global datamgr_service_dir %{_builddir}/foundation/distributeddatamgr/
%global build_opt /opt/distributed-middleware-build %global build_opt /opt/distributed-middleware-build
Name: distributeddatamgr_datamgr_service Name: distributeddatamgr_datamgr_service
Version: 1.0.0 Version: 1.0.0
Release: 3 Release: 2
Summary: Distributed data manager that provides the capability to store data in the databases of different devices Summary: Distributed data manager that provides the capability to store data in the databases of different devices
License: Apache-2.0 License: Apache-2.0
Url: https://gitee.com/openharmony/distributeddatamgr_datamgr_service Url: https://gitee.com/openharmony/distributeddatamgr_datamgr_service
Source1: https://gitee.com/openharmony/distributeddatamgr_datamgr_service/repository/archive/%{oh_version}.tar.gz#/distributeddatamgr_datamgr_service-%{oh_version}.tar.gz Source0: https://gitee.com/openharmony/distributeddatamgr_datamgr_service/repository/archive/OpenHarmony-v3.2-Release.tar.gz#/distributeddatamgr_datamgr_service-OpenHarmony-v3.2-Release.tar.gz
Patch1: 0001-remove-useless-dependency.patch Patch0: 0001-remove-useless-dependency.patch
Patch2: 0002-establish-kvstore-dependence-on-boundscheck.patch Patch1: 0002-add-huks-component.patch
Patch2: 0003-establish-kvstore-dependence-on-boundscheck.patch
BuildRequires: libboundscheck, zlib, zlib-devel, jsoncpp, jsoncpp-devel, compat-openssl11-devel BuildRequires: libatomic libicu-devel libxml2-devel openssl-devel
BuildRequires: distributed-build, distributed-beget, hilog, commonlibrary_c_utils BuildRequires: distributed-build distributed-build_lite hilog distributed-utils
BuildRequires: communication_ipc, communication_dsoftbus BuildRequires: distributeddatamgr_relational_store distributeddatamgr_kv_store
BuildRequires: systemabilitymgr_safwk, systemabilitymgr_samgr
BuildRequires: security_dataclassification, security_device_auth, security_huks
BuildRequires: distributedhardware_device_manager
BuildRequires: distributeddatamgr_kv_store, distributeddatamgr_relational_store
Requires: libboundscheck, zlib, zlib-devel, jsoncpp, jsoncpp-devel, compat-openssl11-devel Requires: hilog distributed-utils distributeddatamgr_kv_store distributeddatamgr_relational_store
Requires: distributed-beget, hilog, commonlibrary_c_utils
Requires: communication_ipc, communication_dsoftbus
Requires: systemabilitymgr_safwk, systemabilitymgr_samgr
Requires: security_dataclassification, security_device_auth, security_huks
Requires: distributedhardware_device_manager
Requires: distributeddatamgr_kv_store, distributeddatamgr_relational_store
%description %description
Distributed Data Service (DDS) provides the ability to distribute database data between different devices. Distributed Data Service (DDS) provides the ability to distribute database data between different devices.
@ -37,29 +28,30 @@ providing users with a consistent data access experience on various terminal dev
%prep %prep
rm -rf %{_builddir}/* rm -rf %{_builddir}/*
cp -rf %{build_opt} %{_builddir}/build
cd %{_builddir}
cp -rp %{build_opt} %{_builddir}/build
[ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh [ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh
[ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn [ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn
[ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py [ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py
cp -rf %{_builddir}/build/openeuler/vendor %{_builddir}/ mv build/openeuler/vendor %{_builddir}/
cp -rf %{_builddir}/build/openeuler/compiler_gn/* %{_builddir}
%setup -q -D -T -a 1 -c -n %{distributeddata_dir} %setup -q -T -a 0 -c -n %{datamgr_service_dir}
if [ -d "%{distributeddata_dir}/datamgr_service" ]; then mv %{datamgr_service_dir}%{name}-%{oh_version} %{datamgr_service_dir}datamgr_service
rm -rf %{distributeddata_dir}/datamgr_service cp -rf %{_builddir}/build/openeuler/compiler_gn/* %{_builddir}/
fi %patch0 -p1 -d %{datamgr_service_dir}datamgr_service
mv %{distributeddata_dir}/%{name}-%{oh_version} %{distributeddata_dir}/datamgr_service %patch1 -p1 -d %{_builddir}/base/security
%patch2 -p1 -d %{datamgr_service_dir}datamgr_service
%patch -P1 -p1 -d %{distributeddata_dir}/datamgr_service
%patch -P2 -p1 -d %{distributeddata_dir}/datamgr_service
%build %build
cd %{_builddir}
rm -rf %{_builddir}/out
%ifarch x86_64 %ifarch x86_64
%{_builddir}/build.sh --product-name openeuler --target-cpu x86_64 ./build.sh --product-name openeuler --target-cpu x86_64
%endif %endif
%ifarch aarch64 %ifarch aarch64
%{_builddir}/build.sh --product-name openeuler --target-cpu arm64 ./build.sh --product-name openeuler --target-cpu arm64
%endif %endif
%install %install
@ -70,27 +62,22 @@ install -d -m 0755 %{buildroot}/system/lib64
install -d -m 0755 %{buildroot}/system/etc/distributeddata/conf install -d -m 0755 %{buildroot}/system/etc/distributeddata/conf
%ifarch aarch64 %ifarch aarch64
%define lib_out_path out/openeuler/linux_clang_arm64/distributeddatamgr/datamgr_service module_out_path="out/openeuler/linux_clang_arm64/distributeddatamgr/datamgr_service"
%endif %endif
%ifarch x86_64 %ifarch x86_64
%define lib_out_path out/openeuler/linux_clang_x86_64/distributeddatamgr/datamgr_service module_out_path="out/openeuler/linux_clang_x86_64/distributeddatamgr/datamgr_service"
%endif %endif
install -m 0755 %{_builddir}/%{lib_out_path}/*.so %{buildroot}%{_libdir} install -m 0755 %{_builddir}/${module_out_path}/*.so %{buildroot}%{_libdir}
install -m 0755 %{_builddir}/%{lib_out_path}/*.so %{buildroot}/system/lib64 install -m 0755 %{_builddir}/${module_out_path}/*.so %{buildroot}/system/lib64
install -m 0755 %{_builddir}/out/openeuler/packages/phone/system/profile/distributeddata.xml %{buildroot}/system/profile
%define config_path out/openeuler/packages/phone/system install -m 0755 %{_builddir}/out/openeuler/packages/phone/system/etc/distributeddata/conf/* %{buildroot}/system/etc/distributeddata/conf/
install -m 0755 %{_builddir}/%{config_path}/profile/distributeddata.xml %{buildroot}/system/profile
install -m 0755 %{_builddir}/%{config_path}/etc/distributeddata/conf/* %{buildroot}/system/etc/distributeddata/conf/
%files %files
%{_libdir}/*.so %{_libdir}/*.so
/system/* /system/*
%changelog %changelog
* Tue Nov 21 2023 Peng He <hepeng68@huawei.com> - 1.0.0-3
- Update build requires and requires.
* Thu Aug 03 2023 Peng He <hepeng68@huawei.com> - 1.0.0-2 * Thu Aug 03 2023 Peng He <hepeng68@huawei.com> - 1.0.0-2
- Add requires and rectify the contents of the RPM package. - Add requires and rectify the contents of the RPM package.