Summary: Instances with persistent memory (e.g., RE7p, R7p, re6P) provide large CPU memory ratios, and Redis applications running on these instances can significantly reduce the cost of single GiB memory. This article describes how to quickly deploy Redis applications on some operating systems.
Instances with persistent memory (e.g., RE7p, R7p, re6P) provide large CPU memory ratios, and Redis applications running on these instances can significantly reduce the cost of single GiB memory. This article describes how to quickly deploy Redis applications on some operating systems.
I. Background information
The steps described in this article for rapid deployment of Redis applications apply to specific instance specifications and mirroring versions, with the following requirements:
-
Example specifications:
-
Re7p: ecs.re7p. Large, ecs.re7p. Xlarge, ecs.re7p.2xlarge, ecs.re7p.16large, ecs.re7p.32xlarge
-
R7p: ecs.r7p.large, ecs.r7p.xlarge, ecs.r7p.2xlarge, ecs.r7p.16large, ecs.r7p.32xlarge
-
Re6p: ecs.re6p-redis.large, ecs.re6p-redis.xlarge, ecs.re6p-redis.2xlarge, ecs.re6p-redis.4xlarge, ecs.re6p-redis.13xlarge
Note If you want to use ECs.re6p-redis.4xlarge, you can click the link to submit the work order for relevant help.
-
Mirror:
-
Alibaba Cloud Linux 2
-
CentOS 7.6 and later
-
Ubuntu 18.10 and later
-
SUSE Linux 12 SP4 or later
Deploy Redis application in Alibaba Cloud Linux 2
Alibaba Cloud Linux 2 has been specially tuned for Redis applications, which improves the overall performance of Redis applications by more than 20% compared with the community edition operating system.
Alibaba Cloud Linux 2 has the yum sources of Redis 6.0.5 and Redis 3.2.12 built in. You can deploy Redis 6.0.5 and Redis 3.2.12 by executing the yum install command. You can also manually deploy other Redis applications. For details, see Deploying Redis Applications on CentOS and Deploying Redis Applications on Ubuntu.
Perform the following steps to configure related resources:
- Example specification: ecs.re6p-redis.2xlarge
- Alibaba Cloud Linux 2.1903 LTS 64-bit
- Purchase persistent memory instances. For details, see Using the Wizard to Create An Instance. Note the following configuration:
- Example: Click the memory type classification under x86 computing architecture and select the instance specification named ECs.re6p-Redis.2xlarge.
- Image: Select Alibaba Cloud Linux 2.1903 LTS 64-bit.
- Login instance. For details, see Connection Mode Overview.
- Deploy Redis 6.0.5 or Redis 3.2.12 as required.
-
Deploying Redis 6.0.5:
Yum install -y alinux-release-experimentals && yum install -y redis-6.0.5
-
Deploying Redis 3.2.12:
Yum install -y alinux-release-experimentals && yum install -y redis-3.2.12
- Start the Redis application (configure the normal and persistent memory capacity used by default). The following is an example command:
-
The recommended ratio of common memory to persistent memory is 1:4.
export MEMKIND_DAX_KMEM_NODES=1 &&
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 -
You can also customize the ratio of common memory to persistent memory to reserve some common memory for running other applications. For example, set the ratio to 1:16 and allocate 34 GiB memory (common memory 2 GiB and persistent memory 32 GiB).
export MEMKIND_DAX_KMEM_NODES=1 &&
redis-server /etc/redis.conf –port 8369 –memory-alloc-policy ratio –dram-pmem-ratio 1 16 –maxmemory 34G
Deploy Redis in CentOS
Perform the following steps to configure related resources and software:
- Example specification: ecs.re6p-redis.2xlarge
- Mirroring: CentOS 7.6
- Redis: Redis 4.0.14
- Memkind: memkind 1.10.1 – rc2
This step involves downloading resources from GitHub (github.com/)…
- Purchase persistent memory instances. For details, see Using the Wizard to Create An Instance. Note the following configuration:
- Example: Click the memory type classification under x86 computing architecture and select the instance specification named ECs.re6p-Redis.2xlarge.
- Mirroring: Select CentOS 7.6 64-bit.
-
Login instance. For details, see Connection Mode Overview.
-
Prepare the compilation environment.
export MEMKIND_DAX_KMEM_NODES=1 &&
yum -y install numactl-devel.x86_64 &&
yum -y groupinstall ‘Development Tools’ -
Prepare the Redis 4.0.14 source code.
Wget github.com/redis-io/re… && wget github.com/redis/redis… -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 is used to enable persistent memory. Different Redis versions use different patches. For more information, see Downloading persistent Memory Enabled Patch.
-
Prepare memkind source code. Memkind is a memory management tool for allocating and managing persistent memory.
-
Download memkind source code.
Wget github.com/memkind/mem… &&mv memkind-1.10.1-rc2/*./deps/memkind
-
** Optional: ** Adjust the makefile.
instructions
You can run LDD –version to view the gliBC version. If the version of GliBC is 2.17 or higher, you can skip the following operations and start compiling Redis.
CD./deps/memkind && wget github.com/memKeyDB/me… && git apply –ignore-whitespace 0001-use-secure_getenv-when-possible. patch && CD /root/redis-4.0.14
-
Note If the patch download fails, you do not need to include CD./deps/memkind && \ when running the command again.
-
Compile and install Redis.
make clean &&
make distclean &&
make MALLOC=memkind -j 4 &&
make install -
Start the Redis application (configure the normal and persistent memory capacity used by default). The following is an example command:
-
The recommended ratio of common memory to persistent memory is 1:4.
Redis-server /root/redis-4.0.14/redis.conf –port 8369 –memory-alloc-policy ratio — DRAM -pmem-ratio 14 –hashtable-on-dram yes –daemonize yes –logfile/TMP /redis_8369.log –protected-mode no –bind 0.0.0.0
-
You can also customize the ratio of common memory to persistent memory to reserve some common memory for running other applications. For example, set the ratio to 1:16 and allocate 34 GiB memory (common memory 2 GiB and persistent memory 32 GiB).
Redis-server /root/redis-4.0.14/redis.conf –port 8369 –memory-alloc-policy ratio — DRAM -pmem-ratio 1 16 –maxmemory 34G
Deploy the Redis application in Ubuntu
Perform the following steps to configure related resources and software:
- Example specification: ecs.re6p-redis.2xlarge
- Image: Ubuntu 20.04
- Redis: Redis 6.2.5
- Memkind: memkind 1.10.1 – rc2
This step involves downloading resources from GitHub (github.com/)…
- Purchase persistent memory instances. For details, see Using the Wizard to Create An Instance. Note the following configuration:
- Example: Click the memory type classification under x86 computing architecture and select the instance specification named ECs.re6p-Redis.2xlarge.
- Image: Select Ubuntu 20.04 64-bit.
-
Login instance. For details, see Connection Mode Overview.
-
Prepare the compilation environment.
export MEMKIND_DAX_KMEM_NODES=1 &&
apt update &&
apt -y install git &&
apt install -y libnuma-dev &&
apt install -y numactl -
Prepare the Redis 6.2.5 source code.
Wget download. Redis. IO/releases/re… && wget github.com/redis/redis… -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 is used to enable persistent memory. Different Redis versions use different patches. For more information, see Downloading persistent Memory Enabled Patch.
-
Prepare memkind source code. Memkind is a memory management tool for allocating and managing persistent memory.
-
Download memkind source code.
Wget github.com/memkind/mem… &&mv memkind-1.10.1-rc2/*./deps/memkind/
-
Adjust the makefile.
You can run LDD –version to view the gliBC version. If the version of GliBC is 2.17 or higher, you can skip the following operations and start compiling Redis.
CD./deps/memkind && wget –no-check-certificate github.com/memKeyDB/me… && git apply –ignore-whitespace 0001-use-secure_getenv-when-possible. patch && CD /root/redis-6.2.5
-
Note If the patch download fails, you do not need to include CD./deps/memkind && \ when running the command again.
-
Compile and install Redis.
make clean &&
make distclean &&
make MALLOC=memkind -j 4 &&
make install -
Start the Redis application (configure the normal and persistent memory capacity used by default). The following is an example command:
-
The recommended ratio of common memory to persistent memory is 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
-
You can also customize the ratio of common memory to persistent memory to reserve some common memory for running other applications. For example, set the ratio to 1:16 and allocate 34 GiB memory (common memory 2 GiB and persistent memory 32 GiB).
Redis-server /root/redis-6.2.5/redis.conf –port 8369 –memory-alloc-policy ratio — DRAM -pmem-ratio 1 16 — maxMemory 34G
5. Download the patch that enables persistent memory
Replace the download address and version number in the file name in the example command. For example, to download the patch for Redis 6.2.5, run the following command:
Wget https://github.com/redis/redis/compare/6.2.5... Tieredmemdb: 6.2.5 - devel. Diff - O redis_6. 2.5 _diff_tieredmemdb. PatchCopy the code
The download addresses of supported patches are as follows:
-
Redis 6.0
-
Github.com/redis/redis…
-
Github.com/redis/redis…
-
Github.com/redis/redis…
-
Github.com/redis/redis…
-
Redis 5.0
-
Github.com/redis/redis…
-
Github.com/redis/redis…
-
Github.com/redis/redis…
-
Redis 4.0
-
Github.com/redis/redis…
-
Github.com/redis/redis…
-
Github.com/redis/redis…
-
Github.com/redis/redis…
-
Redis 3.0
-
Github.com/redis/redis…
The original link
This article is the original content of Aliyun and shall not be reproduced without permission.