如何进行网站宣传推广,万网,深圳设计装修公司哪家好,温州市城乡建设信息港简介#xff1a;配备持久内存的实例#xff08;例如re7p、r7p、re6p#xff09;提供了超大CPU内存配比#xff0c;Redis应用运行在这类实例上可以大幅度降低单GiB内存的成本。本文以部分操作系统为例#xff0c;介绍如何在这类实例上快速部署Redis应用。
配备持久内存的实…简介配备持久内存的实例例如re7p、r7p、re6p提供了超大CPU内存配比Redis应用运行在这类实例上可以大幅度降低单GiB内存的成本。本文以部分操作系统为例介绍如何在这类实例上快速部署Redis应用。
配备持久内存的实例例如re7p、r7p、re6p提供了超大CPU内存配比Redis应用运行在这类实例上可以大幅度降低单GiB内存的成本。本文以部分操作系统为例介绍如何在这类实例上快速部署Redis应用。
一、背景信息
本文中快速部署Redis应用的步骤适用于特定的实例规格和镜像版本要求如下
实例规格
re7pecs.re7p.large、ecs.re7p.xlarge、ecs.re7p.2xlarge、ecs.re7p.16large、ecs.re7p.32xlarger7pecs.r7p.large、ecs.r7p.xlarge、ecs.r7p.2xlarge、ecs.r7p.16large、ecs.r7p.32xlargere6pecs.re6p-redis.large、ecs.re6p-redis.xlarge、ecs.re6p-redis.2xlarge、ecs.re6p-redis.4xlarge、ecs.re6p-redis.13xlarge说明 如需使用ecs.re6p-redis.4xlarge可以点击链接提交工单获得相关帮助。
镜像
Alibaba Cloud Linux 2CentOS 7.6及更高版本Ubuntu 18.10及更高版本SUSE Linux 12 SP4及更高版本
二、在Alibaba Cloud Linux 2中部署Redis应用
Alibaba Cloud Linux 2针对Redis应用进行了专项调优相比社区版操作系统Redis应用整体性能提升20%以上。
Alibaba Cloud Linux 2内置Redis 6.0.5和Redis 3.2.12的yum源执行yum install命令即可部署Redis 6.0.5和Redis 3.2.12。您也可以手动部署其他版本的Redis应用具体操作请参见在CentOS中部署Redis应用和在Ubuntu中部署Redis应用。
本步骤中相关资源的配置如下
实例规格ecs.re6p-redis.2xlarge镜像Alibaba Cloud Linux 2.1903 LTS 64位
购买持久内存实例。具体操作请参见使用向导创建实例。请注意以下配置
实例单击x86计算架构下的内存型分类并选中名称为ecs.re6p-redis.2xlarge的实例规格。镜像选择Alibaba Cloud Linux 2.1903 LTS 64位。
登录实例。具体操作请参见连接方式概述。根据需要部署Redis 6.0.5或Redis 3.2.12。
部署Redis 6.0.5
yum install -y alinux-release-experimentals \
yum install -y redis-6.0.5
部署Redis 3.2.12
yum install -y alinux-release-experimentals \
yum install -y redis-3.2.12
启动Redis应用配置默认使用的普通内存和持久内存容量。示例命令如下
普通内存与持久内存的推荐配比为1:4。
export MEMKIND_DAX_KMEM_NODES1 \
redis-server /etc/redis.conf --port 8369 --memory-alloc-policy ratio --dram-pmem-ratio 1 4 --hashtable-on-dram yes --daemonize yes --logfile /tmp/redis_8369.log --protected-mode no --bind 0.0.0.0
您也可以自定义普通内存与持久内存的配比保留部分普通内存以运行其他应用例如配比为1:16、分配内存34 GiB其中普通内存2 GiB、持久内存32 GiB。
export MEMKIND_DAX_KMEM_NODES1 \
redis-server /etc/redis.conf --port 8369 --memory-alloc-policy ratio --dram-pmem-ratio 1 16 --maxmemory 34G三、在CentOS中部署Redis应用
本步骤中相关资源和软件的配置如下
实例规格ecs.re6p-redis.2xlarge镜像CentOS 7.6RedisRedis 4.0.14memkindmemkind 1.10.1-rc2
说明 本步骤中涉及从GitHubhttps://github.com/相关地址下载资源时请确保下载成功后再进行后续操作。如果下载失败请重复执行相关命令直至下载成功。
购买持久内存实例。具体操作请参见使用向导创建实例。请注意以下配置
实例单击x86计算架构下的内存型分类并选中名称为ecs.re6p-redis.2xlarge的实例规格。镜像选择CentOS 7.6 64位。
登录实例。具体操作请参见连接方式概述。准备编译环境。
export MEMKIND_DAX_KMEM_NODES1 \
yum -y install numactl-devel.x86_64 \
yum -y groupinstall Development Tools
准备Redis 4.0.14源码。
wget https://github.com/redis-io/redis/archive/4.0.14.tar.gz \
wget https://github.com/redis/redis/compare/4.0.14...tieredmemdb:4.0.14-devel.diff -O redis_4.0.14_diff_tieredmemdb.patch \
tar xzvf 4.0.14.tar.gz \
cd redis-4.0.14 \
git apply --ignore-whitespace ../redis_4.0.14_diff_tieredmemdb.patch
说明 patch用于使能持久内存不同Redis版本使用的patch不同。更多信息请参见下载使能持久内存的patch。准备memkind源码。memkind是内存管理工具用于分配管理持久内存。
下载memkind源码。
wget https://github.com/memkind/memkind/archive/v1.10.1-rc2.tar.gz \
tar xzvf v1.10.1-rc2.tar.gz \
mv memkind-1.10.1-rc2/* ./deps/memkind
可选调整makefile。说明 您可以先运行ldd --version查看glibc版本。如果glibc版本等于或高于2.17可以跳过以下操作直接开始编译Redis。
cd ./deps/memkind \
wget https://github.com/memKeyDB/memKeyDB/wiki/files/0001-Use-secure_getenv-when-possible.patch \
git apply --ignore-whitespace 0001-Use-secure_getenv-when-possible.patch \
cd /root/redis-4.0.14
说明 如果patch下载失败再执行命令时无需包括cd ./deps/memkind \。
编译安装Redis。
make clean \
make distclean \
make MALLOCmemkind -j 4 \
make install
启动Redis应用配置默认使用的普通内存和持久内存容量。示例命令如下
普通内存与持久内存的推荐配比为1:4。
redis-server /root/redis-4.0.14/redis.conf --port 8369 --memory-alloc-policy ratio --dram-pmem-ratio 1 4 --hashtable-on-dram yes --daemonize yes --logfile /tmp/redis_8369.log --protected-mode no --bind 0.0.0.0
您也可以自定义普通内存与持久内存的配比保留部分普通内存以运行其他应用例如配比为1:16、分配内存34 GiB其中普通内存2 GiB、持久内存32 GiB。
redis-server /root/redis-4.0.14/redis.conf --port 8369 --memory-alloc-policy ratio --dram-pmem-ratio 1 16 --maxmemory 34G四、在Ubuntu中部署Redis应用
本步骤中相关资源和软件的配置如下
实例规格ecs.re6p-redis.2xlarge镜像Ubuntu 20.04RedisRedis 6.2.5memkindmemkind 1.10.1-rc2
说明 本步骤中涉及从GitHubhttps://github.com/相关地址下载资源时请确保下载成功后再进行后续操作。如果下载失败请重复执行相关命令直至下载成功。
购买持久内存实例。具体操作请参见使用向导创建实例。请注意以下配置
实例单击x86计算架构下的内存型分类并选中名称为ecs.re6p-redis.2xlarge的实例规格。镜像选择Ubuntu 20.04 64位。
登录实例。具体操作请参见连接方式概述。准备编译环境。
export MEMKIND_DAX_KMEM_NODES1 \
apt update \
apt -y install git \
apt install -y libnuma-dev \
apt install -y numactl
准备Redis 6.2.5源码。
wget https://download.redis.io/releases/redis-6.2.5.tar.gz \
wget https://github.com/redis/redis/compare/6.2.5...tieredmemdb:6.2.5-devel.diff -O redis_6.2.5_diff_tieredmemdb.patch \
tar xzf redis-6.2.5.tar.gz \
cd redis-6.2.5 \
git apply --ignore-whitespace ../redis_6.2.5_diff_tieredmemdb.patch
说明 patch用于使能持久内存不同Redis版本使用的patch不同。更多信息请参见下载使能持久内存的patch。准备memkind源码。memkind是内存管理工具用于分配管理持久内存。
下载memkind源码。
wget https://github.com/memkind/memkind/archive/v1.10.1-rc2.tar.gz \
tar xzvf v1.10.1-rc2.tar.gz \
mv memkind-1.10.1-rc2/* ./deps/memkind/
调整makefile。说明 您可以先运行ldd --version查看glibc版本。如果glibc版本等于或高于2.17可以跳过以下操作直接开始编译Redis。
cd ./deps/memkind \
wget --no-check-certificate https://github.com/memKeyDB/memKeyDB/wiki/files/0001-Use-secure_getenv-when-possible.patch \
git apply --ignore-whitespace 0001-Use-secure_getenv-when-possible.patch \
cd /root/redis-6.2.5
说明 如果patch下载失败再执行命令时无需包括cd ./deps/memkind \。
编译安装Redis。
make clean \
make distclean \
make MALLOCmemkind -j 4 \
make install
启动Redis应用配置默认使用的普通内存和持久内存容量。示例命令如下
普通内存与持久内存的推荐配比为1:4。
redis-server /root/redis-6.2.5/redis.conf --port 8369 --memory-alloc-policy ratio --dram-pmem-ratio 1 4 --hashtable-on-dram yes --daemonize yes --logfile /tmp/redis_8369.log --protected-mode no --bind 0.0.0.0
您也可以自定义普通内存与持久内存的配比保留部分普通内存以运行其他应用例如配比为1:16、分配内存34 GiB其中普通内存2 GiB、持久内存32 GiB。
redis-server /root/redis-6.2.5/redis.conf --port 8369 --memory-alloc-policy ratio --dram-pmem-ratio 1 16 --maxmemory 34G五、下载使能持久内存的patch
替换示例命令中的下载地址以及文件名中对应的版本号即可例如下载Redis 6.2.5适用的patch的命令如下
wget https://github.com/redis/redis/compare/6.2.5...tieredmemdb:6.2.5-devel.diff -O redis_6.2.5_diff_tieredmemdb.patch
目前支持的patch的下载地址如下所示
Redis 6.0
https://github.com/redis/redis/compare/6.0.9...tieredmemdb:6.0.9-devel.diffhttps://github.com/redis/redis/compare/6.0.5...tieredmemdb:6.0.5-devel.diffhttps://github.com/redis/redis/compare/6.0.3...tieredmemdb:6.0.3-devel.diffhttps://github.com/redis/redis/compare/6.0.0...tieredmemdb:6.0.0-devel.diff
Redis 5.0
https://github.com/redis/redis/compare/5.0.9...tieredmemdb:5.0.9-devel.diffhttps://github.com/redis/redis/compare/5.0.2...tieredmemdb:5.0.2-devel.diffhttps://github.com/redis/redis/compare/5.0.0...tieredmemdb:5.0.0-devel.diff
Redis 4.0
https://github.com/redis/redis/compare/4.0.14...tieredmemdb:4.0.14-devel.diffhttps://github.com/redis/redis/compare/4.0.9...tieredmemdb:4.0.9-devel.diffhttps://github.com/redis/redis/compare/4.0.2...tieredmemdb:4.0.2-devel.diffhttps://github.com/redis/redis/compare/4.0.0...tieredmemdb:4.0.0-devel.diff
Redis 3.0
https://github.com/redis/redis/compare/3.2.12...tieredmemdb:3.2.diff
原文链接
本文为阿里云原创内容未经允许不得转载。