在 AEM 6 中配置节点存储与数据存储 configuring-node-stores-and-data-stores-in-aem

简介 introduction

在Adobe Experience Manager (AEM)中,二进制数据可以独立于内容节点进行存储。 二进制数据存储在数据存储中,而内容节点存储在节点存储中。

数据存储和节点存储都可以使用OSGi配置进行配置。 每个OSGi配置都使用永久性标识符(PID)引用。

配置步骤 configuration-steps

要配置节点存储和数据存储,请执行以下步骤:

  1. 将AEM快速入门JAR文件复制到其安装目录。

  2. 在安装目录中创建文件夹crx-quickstart/install

  3. 首先,通过创建一个配置文件来配置节点存储,该配置文件具有您要在crx-quickstart/install目录中使用的节点存储选项的名称。

    例如,Document节点存储(AEM的MongoMK实现的基础)使用文件org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.config

  4. 编辑文件,并设置配置选项。

  5. 创建配置文件,该文件应具有您要使用的数据存储的PID。 编辑文件以设置配置选项。

    note note
    NOTE
    有关配置选项,请参阅节点存储配置数据存储配置
  6. 启动AEM。

节点存储配置 node-store-configurations

CAUTION
较新版本的Oak为OSGi配置文件采用新的命名方案和格式。 新的命名方案要求配置文件名为​**.config**,而新格式要求键入值。 有关详细信息,请参阅Apache Sling配置模型和Apache SlingStart — 默认配置格式
如果您从旧版Oak升级,请确保首先备份crx-quickstart/install文件夹。 升级后,将文件夹的内容还原到已升级的安装,并将配置文件的扩展名从​**.cfg**​修改为​**.config**。

区段节点存储 segment-node-store

区段节点存储是Adobe在AEM6中实施TarMK的基础。 它使用org.apache.jackrabbit.oak.segment.SegmentNodeStoreService PID进行配置。

CAUTION
区段节点存储的PID已从AEM 6的org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService in previous versions更改为AEM 6.3中的org.apache.jackrabbit.oak.segment.SegmentNodeStoreService。 确保进行必要的配置调整以反映此更改。

您可以配置以下选项:

  • repository.home:存储存储库相关数据的存储库主目录的路径。 默认情况下,区段文件存储在crx-quickstart/segmentstore目录下。

  • tarmk.size:区段的最大大小(以MB为单位)。 默认最大为256MB。

  • customBlobStore:布尔值,指示使用了自定义数据存储。 AEM 6.3及更高版本的默认值为true。 在AEM 6.3之前,默认为false。

以下是示例org.apache.jackrabbit.oak.segment.SegmentNodeStoreService.config文件:

#Path to repo
repository.home="crx-quickstart/repository"

#Max segment size
tarmk.size=I"256"

#Custom data store
customBlobStore=B"true"

文档节点存储 document-node-store

文档节点存储是AEM实施MongoMK的基础。 它使用org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService* *PID。 可以使用以下配置选项:

  • mongouri:连接到Mongo数据库所需的MongoURI。 默认值为mongodb://localhost:27017

  • db: Mongo数据库的名称。 默认数据库名称为​Oak . However, new AEM 6 installations use **aem-author**

  • cache:缓存大小(MB)。 它分布在DocumentNodeStore中使用的各种缓存中。 默认值为256

  • changesSize: Mongo中用于缓存差异输出的上限集合的大小(以MB为单位)。 默认值为256

  • customBlobStore:布尔值,指示使用了自定义数据存储。 默认为 false

以下是示例org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.config文件:

#Mongo server details
mongouri="mongodb://localhost:27017"

#Name of Mongo database to use
db="aem-author"

#Store binaries in custom BlobStore
customBlobStore=B"false"

数据存储配置 data-store-configurations

在处理大量二进制文件时,建议使用外部数据存储而不是默认节点存储,以最大限度地提高性能。

例如,如果您的项目需要许多媒体资产,将它们存储在File或S3 Data Store下时,访问它们的速度会比直接存储在MongoDB中更快。

文件数据存储提供了比MongoDB更好的性能,而且对于大量资产,Mongo备份和恢复操作速度也会比较慢。

有关不同数据存储和配置的详细信息如下所述。

NOTE
要启用自定义数据存储,您必须确保在相应的节点存储配置文件(区段节点存储文档节点存储)中将customBlobStore设置为true

文件数据存储 file-data-store

这是Jackrabbit 2中存在的FileDataStore的实现。 它提供了一种将二进制数据作为普通文件存储在文件系统中的方法。 它使用org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore PID。

可以使用以下配置选项:

  • repository.home: Path to repository home under which various repository related data is stored. By default, binary files would be stored under crx-quickstart/repository/datastore directory

  • path: Path to the directory under which the files would be stored. If specified then it takes precedence over repository.home value

  • minRecordLength: The minimum size in bytes of a file stored in the data store. Binary content less than this value would be inlined.

NOTE
When using a NAS to store shared file data stores, make sure you use only high performing devices to avoid performance issues.

Amazon S3 Data Store amazon-s-data-store

AEM can be configured to store data in Amazon's Simple Storage Service (S3). 它使用org.apache.jackrabbit.oak.plugins.blob.datastore.S3DataStore.config PID进行配置。

NOTE
AEM 6.5 supports storing data in Amazon's S3, however support is not extended to storing data in other platforms, whose vendors may have their own implementations of Amazon's S3 APIs.

To enable the S3 data store functionality, a feature pack containing the S3 Datastore Connector must be downloaded and installed. Go to the Adobe Repository and download the latest version from the 1.10.x versions of the feature pack (for example, com.adobe.granite.oak.s3connector-1.10.0.zip). Also, you must download and install the latest AEM service pack as listed on the AEM 6.5 Release Notes page.

NOTE
When using AEM with TarMK, binaries will be stored by default in the FileDataStore. To use TarMK with the S3 Datastore, you must start AEM using the crx3tar-nofds runmode, for example:
java -jar <aem-jar-file>.jar -r crx3tar-nofds

Once downloaded, you can install and configure the S3 Connector as follows:

  1. Extract the contents of the feature pack zip file to a temporary folder.

  2. Go to the temporary folder and navigate to the following location:

    code language-xml
    jcr_root/libs/system/install
    

    Copy all the contents from the above location to <aem-install>/crx-quickstart/install.

  3. If AEM is already configured to work with the Tar or MongoDB storage, remove any existing configuration files from the <aem-install>/crx-quickstart/install folder before proceeding. The files that must be removed are:

    • For MongoMK: org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.config
    • For TarMK: org.apache.jackrabbit.oak.segment.SegmentNodeStoreService.config
  4. Return to the temporary location where the feature pack has been extracted, and copy the contents of the following folder:

    • jcr_root/libs/system/config

    • <aem-install>/crx-quickstart/install

    Make sure you only copy the configuration files needed by your current configuration. For both a dedicated data store and a shared data store setup copy the org.apache.jackrabbit.oak.plugins.blob.datastore.S3DataStore.config file.

    note note
    NOTE
    在群集设置中,对群集的所有节点逐个执行上述步骤。 此外,请确保对所有节点使用相同的S3设置。
  5. 编辑文件并添加安装程序所需的配置选项。

  6. 启动AEM。

升级到1.10.x S3连接器的新版本 upgrading-to-a-new-version-of-the-s-connector

要升级到新版本的1.10.x S3连接器(例如,从1.10.0升级到1.10.4),请执行以下步骤:

  1. 停止 AEM 实例。

  2. 导航到AEM安装文件夹中的<aem-install>/crx-quickstart/install/15,并备份其内容。

  3. 备份后,通过删除<aem-install>/crx-quickstart/install/15文件夹中的所有jar文件来删除S3 Connector的旧版本及其依赖项,例如:

    • oak-blob-cloud-1.6.1.jar
    • aws-java-sdk-osgi-1.10.76.jar
    note note
    NOTE
    上述文件名仅用于说明目的。
  4. Adobe存储库下载1.10.x功能包的最新版本。

  5. 将内容解压缩到单独的文件夹,然后导航到jcr_root/libs/system/install/15

  6. 将jar文件复制到AEM安装文件夹中的​<aem-install>/crx-quickstart/install/15。

  7. 启动AEM并检查连接器功能。

您可以使用配置文件以及下面详述的选项。

S3连接器配置文件选项 s3-connector-configuration-file-options

NOTE
S3连接器同时支持IAM用户身份验证和IAM角色身份验证。 要使用IAM角色身份验证,请忽略配置文件中的accessKeysecretKey值。 然后,S3连接器将默认使用分配给实例的IAM角色
描述
默认
必需
访问密钥
有权访问存储桶的IAM用户的访问密钥ID。
是,当不使用IAM角色时。
密钥
有权访问存储桶的IAM用户的访问密钥。
是,当不使用IAM角色时。
缓存大小
本地缓存的大小(以字节为单位)。
64GB
不会。
connectionTimeout
设置初始建立连接时超时前等待的时间(以毫秒为单位)。
10000
不会。
maxCachedBinarySize
大小小于或等于此值(以字节为单位)的二进制文件存储在内存缓存中。
17408 (17 KB)
不会。
maxConnections
设置允许的最大打开HTTP连接数。
50
不会。
maxErrorRetry
设置失败(可重试)请求的最大重试次数。
3
不会。
minRecordLength
应存储在数据存储中的对象的最小大小(以字节为单位)。
16384
不会。
路径
AEM数据存储的本地路径。
crx-quickstart/repository/datastore
不会。
proxyHost
设置客户端通过连接的可选代理主机。
不会。
代理端口
设置客户端通过连接的可选代理端口。
不会。
s3Bucket
S3存储桶的名称。
s3EndPoint
S3 REST API端点。
不会。
s3Region
存储桶所在的区域。 有关更多详细信息,请参阅此页面
正在运行AWS实例的区域。
不会。
sockettimeout
设置在连接超时并关闭之前,通过已建立的打开的连接传输数据等待的时间(以毫秒为单位)。
50000
不会。
stagingPurgeInterval
从临时缓存中清除已完成上载的时间间隔(以秒为单位)。
300
不会。
stagingRetryInterval
重试失败的上传的时间间隔(以秒为单位)。
600
不会。
stagingSplitPercentage
用于暂存异步上载的cacheSize的百分比。
10
不会。
uploadThreads
用于异步上传的上传线程数。
10
不会。
writeThreads
通过S3传输管理器写入时使用的并发线程数。
10
不会。

数据存储缓存 data-store-caching

NOTE
S3DataStoreCachingFileDataStoreAzureDataStore的DataStore实现支持本地文件系统缓存。 当DataStore位于NFS (网络文件系统)上时,CachingFileDataStore实现非常有用。

从旧版缓存实施(Oak 1.6以前的版本)升级时,本地文件系统缓存目录的结构存在差异。 在旧的缓存结构中,下载的文件和上传的文件都直接放在缓存路径下。 新结构将下载和上传分开,并将其存储在缓存路径下名为uploaddownload的两个目录中。 升级过程应是无缝的,应安排任何挂起的上传进行上传,并且在初始化时将之前下载到缓存中的任何文件放入缓存中。

您还可以使用oak-run的datastorecacheupgrade命令脱机升级缓存。 有关如何执行命令的详细信息,请查看oak-run模块的readme

缓存具有大小限制,可以使用cacheSize参数进行配置。

下载 downloads

在从DataStore访问请求文件/blob之前,将检查本地缓存以查找其记录。 在将文件添加到缓存时,如果缓存超出配置的限制(请参阅cacheSize参数),则将收回某些文件以回收空间。

异步上传 async-upload

缓存支持将数据异步上传到DataStore。 文件将存放在本地、缓存(在文件系统上)中,并且异步作业将开始上载文件。 异步上传的数量受临时缓存大小的限制。 临时缓存的大小通过使用stagingSplitPercentage参数来配置。 此参数定义用于临时缓存的缓存大小百分比。 此外,可用于下载的缓存的百分比计算为​(100 - stagingSplitPercentage) *cacheSize

异步上传是多线程的,线程数是使用uploadThreads参数配置的。

上传完成后,文件将移至主下载缓存。 当暂存缓存大小超过其限制时,文件将同步上传到DataStore,直到上一次异步上传完成并且暂存缓存中再次有可用空间为止。 通过周期性作业(其间隔由stagingPurgeInterval参数配置),将上载的文件从临时区域删除。

失败的上传(例如,由于网络中断)将被置于重试队列中,并定期重试。 使用stagingRetryInterval parameter配置重试间隔。

使用Amazon S3配置无二进制复制 configuring-binaryless-replication-with-amazon-s

要使用S3配置无二进制复制,需要执行以下步骤:

  1. 安装创作实例和发布实例,并确保它们已正确启动。

  2. 通过打开​ https://localhost:4502/etc/replication/agents.author/publish.html ​的页面,转到复制代理设置。

  3. 按​ 设置 ​部分中的​ 编辑 ​按钮。

  4. 将​ 序列化 ​类型选项更改为​无二进制文件

  5. 在传输URI中添加参数“ binaryless= true”。 进行更改后,URI应当类似于以下内容:

    https://localhost:4503/bin/receive?sling:authRequestLogin=1&binaryless=true

  6. 重新启动所有创作和发布实例,以使更改生效。

使用S3和MongoDB创建群集 creating-a-cluster-using-s-and-mongodb

  1. 使用以下命令解压缩CQ快速启动:

    java -jar cq-quickstart.jar -unpack

  2. 解压缩AEM后,在安装目录​crx-quickstart/install​中创建文件夹。

  3. crx-quickstart文件夹中创建这两个文件:

    • org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.config

    • org.apache.jackrabbit.oak.plugins.blob.datastore.S3DataStore.config

    创建文件后,根据需要添加配置选项。

  4. 按照上面的说明,安装S3数据存储所需的两个捆绑包。

  5. 确保已安装MongoDB并且mongod的实例正在运行。

  6. 使用以下命令启动AEM:

    java -Xmx1024m -jar cq-quickstart.jar -r crx3,crx3mongo

  7. 对第二个AEM实例重复步骤1至4。

  8. 启动第二个AEM实例。

配置共享数据存储 configuring-a-shared-data-store

  1. 首先,在共享数据存储所需的每个实例上创建数据存储配置文件:

    • 如果您使用的是FileDataStore,请创建一个名为org.apache.jackrabbit.oak.plugins.blob.datastore.FileDataStore.config的文件并将其放在<aem-install>/crx-quickstart/install文件夹中。

    • 如果使用S3作为数据存储,则在<aem-install>/crx-quickstart/install文件夹中创建名为rg.apache.jackrabbit.oak.plugins.blob.datastore.S3DataStore.config的文件,如上所述。

  2. 修改每个实例上的数据存储配置文件,使其指向相同的数据存储。 有关详细信息,请参阅数据存储配置

  3. 如果实例是从现有服务器克隆的,则必须在存储库脱机时使用最新的oak-run工具删除新实例的clusterId。 必须运行的命令是:

    code language-xml
    java -jar oak-run.jar resetclusterid < repository path | Mongo URI >
    
    note note
    NOTE
    如果配置了区段节点存储,则必须指定存储库路径。 默认情况下,路径为<aem-install-folder>/crx-quickstart/repository/segmentstore.如果配置了文档节点存储,则可以使用Mongo连接字符串URI
    note note
    NOTE
    可以从以下位置下载Oak-run工具:
    https://mvnrepository.com/artifact/org.apache.jackrabbit/oak-run/
    根据您在安装AEM时使用的Oak版本,必须使用该工具的不同版本。 Check the version requirements list below before using the tool:
    code language-none
    * For Oak versions **1.2.x** use the Oak-run **1.2.12 or newer**
    * For Oak versions **newer than the above**, use the version of Oak-run that matches the Oak core of your AEM installation.
    
  4. Lastly, validate the configuration. To validate, look for a unique file added to the data store by each repository that is sharing it. The format of the files is repository-[UUID], where the UUID is a unique identifier of each individual repository.

    Therefore, a proper configuration should have as many unique files as there are repositories sharing the data store.

    The files are stored differently, depending on the data store:

    • For the FileDataStore the files are created under the root path of the data store folder.
    • For the S3DataStore the files are created in the configured S3 bucket under the META folder.

Azure 数据存储 azure-data-store

AEM can be configured to store data in Microsoft®'s Azure storage service. 它使用org.apache.jackrabbit.oak.plugins.blob.datastore.AzureDataStore.config PID进行配置。

To enable the Azure data store functionality, a feature pack containing the Azure Connector must be downloaded and installed. Go to the Adobe Repository and download the latest version from the 1.6.x versions of the feature pack (for example, com.adobe.granite.oak.azureblobconnector-1.6.3.zip).

NOTE
When using AEM with TarMK, binaries are stored by default in the FileDataStore. To use TarMK with the Azure DataStore, you must start AEM using the crx3tar-nofds runmode, for example:
java -jar <aem-jar-file>.jar -r crx3tar-nofds

Once downloaded, you can install and configure the Azure connector as follows:

  1. Extract the contents of the feature pack zip file to a temporary folder.

  2. Go to the temporary folder and copy the contents of jcr_root/libs/system/install to the <aem-install>crx-quickstart/install folder.

  3. If AEM is already configured to work with the Tar or MongoDB storage, remove any existing configuration files from the /crx-quickstart/install folder before proceeding. The files that must be removed are:

    ForMongoMK:

    org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService.config

    For TarMK:

    org.apache.jackrabbit.oak.segment.SegmentNodeStoreService.config

  4. Return to the temporary location where the feature pack has been extracted and copy the contents of jcr_root/libs/system/config to the <aem-install>/crx-quickstart/install folder.

  5. Edit the configuration file and add the configuration options required by your setup.

  6. 启动AEM。

配置文件具有以下选项:

  • azureSas=":在连接器的1.6.3版本中,添加了Azure共享访问签名(SAS)支持。 如果配置文件中同时存在SAS和存储凭据,则SAS具有优先级。 有关SAS的详细信息,请参阅官方文档。 确保“=”字符像“=”一样转义。

  • azureBlobEndpoint="": Azure Blob端点。 例如,https://<storage-account>.blob.core.windows.net。

  • accessKey="":存储帐户名称。 有关® Azure身份验证凭据的更多详细信息,请参阅官方文档

  • secretKey="":存储访问密钥。 确保“=”字符像“=”一样转义。

  • container="": ® Azure Blob存储容器名称。 容器是一组Blob。 有关其他详细信息,请阅读官方文档

  • maxConnections=":每个操作的并发请求数。 默认值为 1。

  • maxErrorRetry="":每个请求的重试次数。 默认值为 3。

  • socketTimeout="":用于请求的超时间隔(以毫秒为单位)。 默认值为5分钟。

除了上述设置之外,还可以配置以下设置:

  • path:数据存储的路径。 默认值为<aem-install>/repository/datastore.
  • RecordLength:应存储在数据存储中的对象的最小大小。 默认值为16 KB。
  • maxCachedBinarySize:大小小于或等于此大小的二进制文件存储在内存缓存中。 大小以字节为单位。 默认值为17408 (17 KB)。
  • cacheSize:高速缓存的大小。 该值以字节为单位指定。 默认值为64 GB。
  • 密钥:仅在为共享数据存储设置使用无二进制复制时使用。
  • stagingSplitPercentage:配置为用于暂存异步上载的缓存大小的百分比。 默认值为 10。
  • uploadThreads:用于异步上传的上传线程数。 默认值为 10。
  • stagingPurgeInterval:从暂存缓存中清除已完成上载的时间间隔(以秒为单位)。 默认值为300秒(5分钟)。
  • stagingRetryInterval:失败上载的重试间隔(以秒为单位)。 默认值为600秒(10分钟)。
NOTE
所有设置都应置于引号之间,例如:
accessKey="ASDASDERFAERAER"
secretKey="28932hfjlkwdo8fufsdfas\=\="

数据存储垃圾收集 data-store-garbage-collection

数据存储垃圾收集过程用于删除数据存储中的任何未使用文件,从而在该过程中释放宝贵的磁盘空间。

您可以通过以下方式运行数据存储垃圾收集:

  1. 转到​ https://<serveraddress:port/system/console/jmx ​处的JMX控制台

  2. 正在搜索​RepositoryManagement。 找到存储库管理器MBean后,单击它可显示可用选项。

  3. 滚动到页面末尾,然后单击​ startDataStoreGC(boolean markOnly) ​链接。

  4. 在以下对话框中,输入markOnly参数的false,然后单击​调用

    chlimage_1-9

    note note
    NOTE
    markOnly参数表示垃圾回收的扫描阶段是否运行。

共享数据存储的数据存储垃圾收集 data-store-garbage-collection-for-a-shared-data-store

NOTE
在群集或共享数据存储中执行垃圾收集时,设置(使用Mongo或Segment Tar)日志可能会显示有关无法删除某些blob ID的警告。 其他没有相关ID删除信息的群集或共享节点再次错误地引用了之前垃圾收藏集中删除的Blob ID。 因此,执行垃圾收集时,它会尝试删除在上次运行中已删除的ID时记录警告。 此行为不会影响性能或功能。
NOTE
如果您使用共享数据存储设置并且数据存储垃圾收集被禁用,则运行Lucene二进制清理任务可能会突然增加使用的磁盘空间。 考虑通过执行以下操作在所有创作实例和发布实例上禁用BlobTracker:
  1. 停止AEM实例。
  2. crx-quickstart/install/org.apache.jackrabbit.oak.segment.SegmentNodeStoreService.config文件中添加blobTrackSnapshotIntervalInSecs=L"0"参数。 此参数需要Oak 1.12.0、1.10.2或更高版本。
  3. 重新启动AEM实例。

使用较新版本的AEM,数据存储垃圾收集还可以在多个存储库共享的数据存储上运行。 要在共享数据存储上运行数据存储垃圾收集,请执行以下步骤:

  1. 确保在共享数据存储的所有存储库实例上禁用为数据存储垃圾收集配置的任何维护任务。

  2. 对共享数据存储的​ 所有 ​存储库实例分别运行二进制垃圾回收中提到的步骤。 但是,请确保在单击“调用”按钮之前为markOnly参数输入true

    chlimage_1-10

  3. 在所有实例上完成上述过程后,从​ 任意 ​个实例中再次运行数据存储垃圾收集:

    1. 转到JMX控制台,然后选择Repository Manager Mbean。
    2. 单击​ Click startDataStoreGC(boolean markOnly) ​链接。
    3. 在下面的对话框中,再次输入markOnly参数的false

    使用之前使用的标记阶段整理找到的所有文件,并从数据存储中删除未使用的其余文件。

recommendation-more-help
19ffd973-7af2-44d0-84b5-d547b0dffee2