User Guide Distributed Cache Service - Date 2020-07-17
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Distributed Cache Service User Guide Contents Contents 1 Introduction.............................................................................................................................. 1 1.1 DCS............................................................................................................................................................................................... 1 1.2 Application Scenarios............................................................................................................................................................. 2 1.3 Advantages................................................................................................................................................................................ 3 1.4 Redis Command Compatibility........................................................................................................................................... 3 1.5 DCS Instance Specifications...............................................................................................................................................10 1.6 Accessing DCS........................................................................................................................................................................ 11 1.6.1 How to Access DCS........................................................................................................................................................... 11 1.6.2 Related Services................................................................................................................................................................. 12 1.6.3 User Permissions................................................................................................................................................................ 12 2 Getting Started...................................................................................................................... 14 2.1 Setting Up Environments................................................................................................................................................... 14 2.2 Creating a DCS Instance..................................................................................................................................................... 15 2.3 Accessing a DCS Redis Instance....................................................................................................................................... 18 2.4 Viewing Details of a DCS Instance..................................................................................................................................20 3 Operation Guide.................................................................................................................... 23 3.1 Configuring Redis-Specific Parameters..........................................................................................................................23 3.2 Starting DCS Instances........................................................................................................................................................ 30 3.3 Restarting DCS Instances................................................................................................................................................... 30 3.4 Deleting DCS Instances....................................................................................................................................................... 31 3.5 Modifying DCS Instance Specifications......................................................................................................................... 32 3.6 Changing Instance Passwords.......................................................................................................................................... 34 3.7 Modifying an Instance's Maintenance Time Window.............................................................................................. 35 3.8 Modifying an Instance's Security Group....................................................................................................................... 36 3.9 Backing Up and Restoring DCS Instances.................................................................................................................... 36 3.9.1 Overview............................................................................................................................................................................... 36 3.9.2 Configuring a Backup Policy.......................................................................................................................................... 38 3.9.3 Manually Backing Up a DCS Instance........................................................................................................................ 40 3.9.4 Restoring a DCS Instance................................................................................................................................................40 3.10 Managing Background Tasks..........................................................................................................................................41 4 Monitoring.............................................................................................................................. 43 4.1 DCS Metrics............................................................................................................................................................................. 43 2020-07-17 ii
Distributed Cache Service User Guide Contents 4.2 Viewing DCS Metrics............................................................................................................................................................51 4.3 Setting Alarm Rules for Critical Metrics........................................................................................................................ 51 5 FAQs..........................................................................................................................................54 5.1 Does DCS Support Common Redis Clients Such as Jedis?...................................................................................... 54 5.2 Should I Install Redis If I Already Have a DCS Instance?........................................................................................ 54 5.3 Do I Need to Enter a Password When Accessing a DCS Instance? Where Can I Obtain the Password? ............................................................................................................................................................................................................ 54 5.4 Does Standby Cache Node Remain Synchronized with Master Cache Node?................................................ 54 5.5 Does DCS Support Data Persistence?............................................................................................................................ 55 5.6 Can DCS Be Accessed over Public Networks?............................................................................................................. 55 5.7 Can I Modify Configuration Parameters of DCS Instances?...................................................................................55 5.8 Can I Recover Data from Deleted DCS Instances?.................................................................................................... 55 5.9 What Is the Default Data Eviction Policy?................................................................................................................... 55 5.10 What Should I Do If the Connection Between My Redis Client and the DCS Instance Times Out?..... 56 5.11 Why Is Available Memory of Unused DCS Instances Less Than Total Memory? Why Is Memory Usage of Unused DCS Instances Greater Than Zero?................................................................................................................... 56 5.12 Does DCS Support Data Read/Write in Multiple Databases?............................................................................. 57 5.13 Why Can't I Back Up or Scale Up My DCS Instances?........................................................................................... 57 5.14 Do DCS Instances in Cluster Mode Support Native Redis Clusters?................................................................. 57 5.15 Why Do My DCS Instances Sometimes Become Unavailable While They Are in Running State?......... 57 5.16 Why Is the Used Instance Memory Displayed on Cloud Eye Console Slightly Higher than the Instance Available Memory?...................................................................................................................................................................... 58 5.17 How to Select and Configure a Security Group?..................................................................................................... 58 5.18 Do DCS Instances Support Cross-VPC Access?......................................................................................................... 59 A Glossary................................................................................................................................... 60 B Change History...................................................................................................................... 61 2020-07-17 iii
Distributed Cache Service User Guide 1 Introduction 1 Introduction 1.1 DCS Distributed Cache Service (DCS) is an online, distributed, in-memory cache service compatible with Redis. It is reliable, scalable, usable out of the box, and easy to manage, meeting your requirements for high read/write performance and fast data access. Clients can access DCS instances only when they are installed on Elastic Cloud Servers (ECSs) and belong to the same virtual private cloud (VPC) as the DCS instances. Figure 1-1 Accessing DCS instances NOTE Like clients, DCS instances are also run on ECSs. A client must belong to the same VPC and subnet as the DCS instance it is attempting to access. 2020-07-17 1
Distributed Cache Service User Guide 1 Introduction DCS Redis DCS uses Redis 3.0, a storage system that supports multiple types of data structures, including key-value pairs. It can be used in scenarios such as caching, event pub/sub, and high-speed queuing. Redis is networked and written in ANSI C. It supports direct read/write of strings, hashes, lists, queues, and sets. Redis works with in-memory datasets and provides persistence. For more information about Redis, visit https://redis.io/. There are three deployment modes for DCS Redis instances: ● Single-node Each DCS instance runs on only one cache node. Such DCS instances are mainly used for temporary data storage but are not suitable for high- reliability service scenarios. Single-node DCS instances support intensive concurrent read/write operations, but do not implement data persistence. Data will be deleted after single-node DCS instances are restarted. ● Master/Standby DCS instances run in master/standby mode, providing higher availability than single-node DCS instances: – Each DCS instance runs on two cache nodes (one master and one standby), and supports data persistence. – The standby node is invisible to the client and does not provide data read/write services. It is kept synchronized with the master node through data synchronization. – The standby node takes over automatically if the master node fails. ● Proxy Cluster DCS instances run in Proxy Cluster mode, providing higher instance specifications and performance than master/standby DCS instances: – Each DCS instance has at least three master nodes. Compared with master/standby DCS instances, DCS instances in Proxy Cluster mode support higher instance specifications and concurrency. – Each master node has a redundant node. If a master node is faulty, the redundant node becomes the master node and provides data read/write services for users. – Each redundant node is invisible to Redis clients, and it is kept synchronized with its master node through data synchronization. 1.2 Application Scenarios For e-commerce, video sharing, gaming, and other data-intensive applications, it is essential to retrieve data fast. The primary purpose of DCS is to provide fast yet inexpensive data retrieval. With DCS, you can retrieve data from in-memory data stores instead of relying entirely on slower disk-based databases. DCS instances are also fully managed. You no longer need to perform management tasks such as hardware provisioning, software patching, monitoring, or failure recovery. Consider using DCS when you need to cache the following types of data: 2020-07-17 2
Distributed Cache Service User Guide 1 Introduction ● Web pages Caching the content of web pages improves page load times. The cached content can include static data such as Hypertext Markup Language (HTML) pages, Cascading Style Sheets (CSS), and images. ● Status DCS provides quick and simple queries of session status and application- scaling status, enabling easy sharing of status information. ● Application objects DCS serves as a level-2 cache at the service layer and provides data storage and access for external entities. Storing frequently requested data in DCS instances can off load databases and reduce access latency. ● Events DCS provides continuous event querying, allowing streams of events to be processed as they occur. 1.3 Advantages The advantages of DCS include: ● Usability off the shelf You can create DCS instances with just a few clicks on the DCS console or by calling application programming interfaces (APIs). DCS responds to instance creation commands without requiring you to deal with complex underlying software and hardware. ● Customizable specifications DCS instance specifications range from 2 GB to 512 GB, increasing the flexibility of DCS. ● Reliability Data persistence, support for master/standby and Proxy Cluster modes, and automatic failover between cache nodes ensure data reliability and service availability. ● Ease of maintenance You can create, restart, and delete DCS instances with just a few clicks on the DCS console. DCS continuously monitors and maintains DCS instances so that you can focus on application development. Service monitoring metrics include keys, the number of client connections, and processed commands. System monitoring metrics include memory, CPU, and network usage. 1.4 Redis Command Compatibility This section describes DCS's compatibility with Redis commands, including supported commands, disabled commands, unsupported scripts and commands of later Redis versions, and restrictions on command usage. For more information about the command syntax, visit the Redis official website. DCS for Redis instances support most Redis commands. Any client compatible with the Redis protocol can access DCS. 2020-07-17 3
Distributed Cache Service User Guide 1 Introduction ● For security purposes, some Redis commands are disabled in DCS. For details, see Commands Disabled by DCS for Redis 3.0. ● Some Redis commands have usage restrictions, which are described in Other Command Usage Restrictions. ● Some Redis commands are supported by Proxy Cluster DCS instances for multi-key operations in the same slot. For details, see Table 1-4. Commands Supported by DCS for Redis 3.0 The following lists commands supported by DCS for Redis 3.0. NOTE Commands available since later Redis versions are not supported by earlier versions. Run a command on redis-cli to check whether it is supported by DCS for Redis. If the message "(error) ERR unknown command" is returned, the command is not supported. Table 1-1 Commands supported by DCS for Redis 3.0 Category Command Key DEL, DUMP, EXISTS, EXPIRE, MOVE, PERSISI, PTTL, RANDOMKEY, RENAME, RENAMENX, RESTORE, SORT, TTL, TYPE, SCAN, OBJIECT String APPEND, BITCOUNT, BITOP, BITPOS, DECR, DECRBY, GET, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, MGET, MSET, MSETNX, PSETEX, SET, SETBIT, SETEX, SETNX, SETRANGE, STRLEN Hash HDEL, HEXISTS, HGET, HGETALL, HINCRBY, HINCRBYFLOAT, HKEYS, HMGET, HMSET, HSET, HSETNX, HVALS, HSCAN List BLPOP, BRPOP, BRPOPLRUSH, LINDEX, LINSERT, LLEN, LPOP, LPUSHX, LRANGE, LREM, LSET, LTRIM, RPOP, RPOPLPU, RPOPLPUSH, RPUSH, RPUSHX NOTE Proxy Cluster Redis 3.0 instances do not support BLPOP, BRPOP, and BRPOPLRUSH commands. Set SADD, SCARD, SDIFF, SDIFFSTORE, SINTER, SINTERSTORE, SISMEMBER, SMEMBERS, SMOVE, SPOP, SRANDMEMBER, SREM, SUNION, SUNIONSTORE, SSCAN Sorted set ZADD, ZCARD, ZCOUNT, ZINCRBY, ZRANGE, ZRANGEBYSCORE, ZRANK, ZREMRANGEBYRANK, ZREMRANGEBYCORE, ZREVRANGE, ZREVRANGEBYSCORE, ZREVRANK, ZSCORE, ZUNIONSTORE, ZINTERSTORE, ZSCAN, ZRANGEBYLEX HyperLogLo PFADD, PFCOUNT, PFMERGE g Pub/Sub PSUBSCRIBE, PUBLISH, PUBSUB, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE 2020-07-17 4
Distributed Cache Service User Guide 1 Introduction Category Command Transaction DISCARD, EXEC, MULTI, UNWATCH, WATCH Connection AUTH, ECHO, PING, QUIT, SELECT Server FLUSHALL, FLUSHDB, DBSIZE, TIME, INFO, KEYS, CLIENT KILL, CLIENT LIST, CLIENT GETNAME, CLIENT SETNAME, CONFIG GET, MONITOR, SLOWLOG, ROLE NOTE ● Proxy Cluster Redis 3.0 instances do not support CLIENT commands, including CLIENT KILL, CLIENT GETNAME, CLIENT LIST, CLIENT SETNAME, CLIENT PAUSE, and CLIENT REPLY. ● Proxy Cluster Redis 3.0 instances do not support the MONITOR command. Scripting EVAL, EVALSHA, SCRIPT EXISTS, SCRIPT FLUSH, SCRIPT KILL, SCRIPT LOAD Geo GEOADD, GEOHASH, GEOPOS, GEODIST, GEORADIUS, GEORADIUSBYMEMBER Commands Disabled by DCS for Redis 3.0 Redis APIs of single-node and master/standby DCS instances are compatible with open-source Redis for data access. For ease of use and security purposes, some management operations cannot be initiated from a Redis client. Related commands are listed in Table 1-2. Table 1-2 Redis commands disabled in single-node and master/standby Redis 3.0 instances Command Description Key MIGRATE Transfers a key from one Redis instance to another. Server SLAVEOF Changes the replication settings of a replica on the fly. SHUTDOWN Stops all the clients and quits the Redis process. LASTSAVE Returns the time of the last successful data persistence to disk. DEBUG commands Debugging command that should not be used by clients. COMMAND Returns array reply of details about all Redis commands. SAVE Performs a synchronous save on disk, producing a point in time snapshot of all the data inside the Redis instance, in the form of an RDB file. 2020-07-17 5
Distributed Cache Service User Guide 1 Introduction Command Description BGSAVE Asynchronously saves the database on disk. BGREWRITEAOF Starts an Append Only File (AOF) rewrite process. In additional to these commands, Proxy Cluster Redis 3.0 instances do not support the commands listed in Table 1-3. Table 1-3 Redis commands disabled in Proxy Cluster Redis 3.0 instances Command Description Server SYNC An internal command used for full replication. PSYNC An internal command used for partial replication. MONITOR Streams back every command processed by the Redis server for debugging. CLIENT commands CLIENT KILL, CLIENT GETNAME, CLIENT LIST, CLIENT SETNAME, CLIENT PAUSE, and CLIENT REPLY. OBJECT Debugging command that should not be used by clients. ROLE Returns the role of the instance node. Transaction DISCARD Flushes all previously queued commands in a transaction. EXEC Executes all previously queued commands in a transaction. MULTI Marks the start of a transaction block. UNWATCH Flushes all the previously watched keys for a transaction. WATCH Marks the given key or keys to be watched. If the key or keys are modified by other commands before WATCH is executed, the transaction is interrupted. Connection SELECT Selects the Redis database. Note: Parameters of the SELECT command can only be set to 0. Key MOVE Moves key of the currently selected database to the specified destination database. Cluster 2020-07-17 6
Distributed Cache Service User Guide 1 Introduction Command Description CLUSTER Used for cluster management. codis (Proxy Cluster) TIME Returns the current server time. SLOTSINFO Returns the number of slots and the size of each slot in Redis. SLOTSDEL Deletes all key-value pairs in multiple slots in Redis. SLOTSMGRTSLOT Randomly migrates a key-value pair in a slot to the destination. SLOTSMGRTONE Migrates a specified key-value pair to the destination. SLOTSCHECK Checks whether slots meet the following consistency requirements: ● All the keys in the slots have a corresponding value in the database. ● All the keys in the database have a value in the corresponding slot. SLOTSMGRTTAGSLO Migrates all key-value pairs with the same tag as a T randomly selected key in a slot. SLOTSMGRTTAGON Migrates all key-value pairs with the same tag as a E specified key. List BLPOP The blocking version of LPOP because it blocks the connection when there are no elements to pop from any of the given lists until the specified timeout has expired or a non-empty element is popped. BRPOP The blocking version of RPOP because it blocks the connection when there are no elements to pop from any of the given lists until the specified timeout has expired or a non-empty element is popped. BRPOPLPUSH The blocking variant of RPOPLPUSH. When source contains elements, this command behaves exactly like RPOPLPUSH. Restricted Redis Commands Some Redis commands are supported by Proxy Cluster DCS instances for multi-key operations in the same slot. For details, see Table 1-4. 2020-07-17 7
Distributed Cache Service User Guide 1 Introduction Table 1-4 Redis commands restricted in Proxy Cluster DCS instances. Category Description Set SINTER Returns the members of the set resulting from the intersection of all the given sets. SINTERSTORE Equal to SINTER, but instead of returning the result set, it is stored in destination. SUNION Returns the members of the set resulting from the union of all the given sets. SUNIONSTORE Equal to SUNION, but instead of returning the result set, it is stored in destination. SDIFF Returns the members of the set resulting from the difference between the first set and all the successive sets. SDIFFSTORE Equal to SDIFF, but instead of returning the result set, it is stored in destination. SMOVE Moves member from the set at source to the set at destination. Sorted Set ZUNIONSTORE Computes the union of numkeys sorted sets given by the specified keys. ZINTERSTORE Computes the intersection of numkeys sorted sets given by the specified keys. HyperLogLog PFCOUNT Returns the approximated cardinality computed by the HyperLogLog data structure stored at the specified variable. PFMERGE Merges multiple HyperLogLog values into a unique value. Key RENAME Renames key to newkey. RENAMENX Renames key to newkey if newkey does not yet exist. BITOP Performs a bitwise operation between multiple keys (containing string values) and stores the result in the destination key. RPOPLPUSH Returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination. String MSETNX Sets the given keys to their respective values. 2020-07-17 8
Distributed Cache Service User Guide 1 Introduction NOTE While running commands that take a long time to run, such as FLUSHALL, DCS instances may not respond to other commands and may change to the faulty state. After the command finishes executing, the instance will return to normal. Other Command Usage Restrictions Key commands: In case of a large amount of cached data, running a Keys command may block the execution of other commands for a long time or occupy exceptionally large memory. Therefore, when running a Keys command, describe the exact pattern and do not use fuzzy keys *. keys * can be used during commissioning or when the number of keys does not exceed 5 million. Otherwise, the service cannot run properly. Server commands: ● While running commands that take a long time to run, such as FLUSHALL, DCS instances may not respond to other commands and change to the faulty state. After the command finishes executing, the instance will return to normal. ● When the FLUSHDB or FLUSHALL command is run, execution of other service commands may be blocked for a long time in case of a large amount of cached data. EVAL and EVALSHA commands: ● When the EVAL or EVALSHA command is run, at least one key must be contained in the command parameter. Otherwise, the error message "ERR eval/evalsha numkeys must be bigger than zero in redis cluster mode" is displayed. ● When the EVAL or EVALSHA command is run, a Proxy Cluster DCS Redis instance uses the first key to compute slots. Ensure that the keys to be operated in your code are in the same slot. For details, visit https://redis.io/ commands. ● For the EVAL command: – You are advised to learn the Lua script features of Redis before running the EVAL command. For details, see https://redis.io/commands/eval. – The execution timeout time of a Lua script is 5 seconds. Time-consuming statements such as long-time sleep and large loop statements should be avoided. – When calling a Lua script, do not use random functions to specify keys. Otherwise, the execution results are inconsistent on the master and standby nodes. Others: 2020-07-17 9
Distributed Cache Service User Guide 1 Introduction ● The time limit for executing a Redis command is 15 seconds. To prevent other services from failing, a master/replica switchover will be triggered after the command execution times out. ● Proxy Cluster DCS Redis instances created before July 10, 2018 must be upgraded to support the following commands: SINTER, SDIFF, SUNION, PFCOUNT, PFMERGE, SINTERSTORE, SUNIONSTORE, SDIFFSTORE, SMOVE, ZUNIONSTORE, ZINTERSTORE, EVAL, EVALSHA, BITOP, RENAME, RENAMENX, RPOPLPUSH, MSETNX, SCRIPT LOAD, SCRIPT KILL, SCRIPT EXISTS, SCRIPT FLUSH. 1.5 DCS Instance Specifications For each single-node DCS Redis instance, the available memory is less than the total memory because some memory is reserved for system overhead, as shown in Table 1-5. Table 1-5 Specifications of single-node DCS Redis 3.0 instances Total Memory Available Maximum Assured/Maximum (GB) Memory Connections Bandwidth (GB) Allowed (Mbit/s) 2 1.5 10,000 42/512 4 3.2 10,000 64/1,536 8 6.8 10,000 64/1,536 16 13.6 10,000 85/3,072 32 27.2 10,000 85/3,072 64 58.2 12,000 128/5,120 For each master/standby DCS Redis instance, the available memory is less than that of a single-node DCS Redis instance because some memory is reserved for data persistence, as shown in Table 1-7. The available memory of a master/ standby instance can be adjusted to support background tasks such as data persistence and master/standby synchronization. Table 1-6 Specifications of master/standby DCS Redis 3.0 instances Total Memory Available Maximum Assured/Maximum (GB) Memory Connections Bandwidth (GB) Allowed (Mbit/s) 2 1.5 10,000 42/512 4 3.2 10,000 64/1,536 8 6.4 10,000 64/1,536 2020-07-17 10
Distributed Cache Service User Guide 1 Introduction Total Memory Available Maximum Assured/Maximum (GB) Memory Connections Bandwidth (GB) Allowed (Mbit/s) 16 12.8 10,000 85/3,072 32 25.6 10,000 85/3,072 64 51.2 12,000 128/5,120 In addition to larger memory, Proxy Cluster instances feature more connections allowed and higher bandwidth allowed than single-node and master/standby instances. Table 1-7 Specifications of Proxy Cluster DCS Redis 3.0 instances Total Memory Available Maximum Assured/Maximum (GB) Memory Connections Bandwidth (GB) Allowed (Mbit/s) 64 64 90,000 600/5,120 128 128 180,000 600/5,120 256 256 240,000 600/5,120 512 512 480,000 600/5,120 1.6 Accessing DCS 1.6.1 How to Access DCS There are two ways to access DCS: ● Using the management console The DCS provides a web-based management console. To launch the DCS console, create an account on the management console and log in, and then choose Database > Distributed Cache Service on the homepage. On the DCS console, you can create, restart, and delete DCS instances, and change their passwords. ● Using APIs If you want to integrate DCS into a third-party system for secondary development, use APIs to access DCS. For more information about available APIs, see the Distributed Cache Service API Reference. 2020-07-17 11
Distributed Cache Service User Guide 1 Introduction 1.6.2 Related Services Virtual Private Cloud (VPC) The VPC service enables users to create private, isolated virtual networks. DCS instances run in VPCs and use the IP addresses and bandwidths of VPCs. VPCs are based on security groups. A security group is a set of access control rules that implements access control for mutually trusted ECSs with the same security protection requirements in the same VPC. Elastic Cloud Server (ECS) The ECS service provides scalable, on-demand cloud servers for secure, flexible, and efficient application environments, ensuring service reliability. After you create DCS instances, you can connect to them through ECSs. Cloud Trace Service (CTS) CTS provides a history of operations performed on cloud service resources. With CTS, you can query, audit, and review operations. Traces include operation time, resource objects, resource IDs, requesters' IP addresses, resource operation requests, and responses. Currently, CTS records the following operations on DCS instances: ● Creating, starting, restarting, and deleting DCS instances ● Configuring Redis-specific parameters ● Changing instance passwords ● Modifying basic information Identity and Access Management (IAM) IAM provides identity authentication and permission management. It is used to authenticate access to DCS. Cloud Eye Cloud Eye is a secure, scalable monitoring platform. It monitors DCS service metrics and sends notifications if alarms or events occur. For details about DCS metrics, see DCS Metrics. 1.6.3 User Permissions The public cloud system provides two types of user permissions by default: user management and resource management. User management refers to the management of users, user groups, and user group rights. Resource management refers to the control operations that can be performed by users on cloud service resources. 2020-07-17 12
Distributed Cache Service User Guide 1 Introduction For details, see Permissions. 2020-07-17 13
Distributed Cache Service User Guide 2 Getting Started 2 Getting Started 2.1 Setting Up Environments To access DCS instances through a VPC, create a VPC and configure security groups and subnets for it before using DCS. A VPC provides an isolated, user-configurable, and user-manageable virtual network environment for DCS. Using VPCs enhances resource security and simplifies network deployment. Once you have created a VPC, you can use it for all DCS instances you subsequently create. Procedure Step 1 Log in to the management console. Step 2 Click in the upper left corner of the management console and select a region and a project. Step 3 Click Service List, and choose Network > Virtual Private Cloud to launch the VPC console. Step 4 On the Dashboard page, click Create VPC. Step 5 Create a VPC as guided by the VPC console, retaining the default values of the VPC parameters unless otherwise required. For more information on how to create a VPC, see the Virtual Private Cloud User Guide. After a VPC is created, a subnet is also created in the subnet. If the VPC needs more subnets, go to Step 6. Otherwise, go to 7. Step 6 In the navigation pane, choose Virtual Private Cloud. On the Virtual Private Cloud page, click the name of the VPC in which you intend to create a subnet. On the Subnets tab page, click Create Subnet. Create a subnet as guided by the VPC console, retaining the default values of the subnet parameters unless otherwise required. 2020-07-17 14
Distributed Cache Service User Guide 2 Getting Started For more information on how to create a subnet, see the Virtual Private Cloud User Guide. Step 7 In the navigation pane, choose Security Group. On the Security Group page, click Create Security Group. Create a security group for the VPC, retaining the default values of the security group parameters unless otherwise required. For more information on how to create a security group, see the Virtual Private Cloud User Guide. ----End 2.2 Creating a DCS Instance Scenario DCS can be used only after DCS instances are created. DCS supports three types of DCS instances: single-node, master/standby, and Proxy Cluster. NOTICE DCS does not provide built-in encryption. Encrypt any sensitive data before transmitting or storing it. The purpose, scope, processing method, and time limits of data processed by DCS must comply with local laws and regulations. Prerequisites The VPC where the DCS instance to be created is available. Security groups and subnets have been configured for the VPC. For more information on how to create VPCs, security groups, and subnets, see Setting Up Environments or the Virtual Private Cloud User Guide. Procedure Step 1 Log in to the management console. Step 2 Click in the upper left corner of the management console and select a region and a project. Step 3 Click Service List, and choose Database > Distributed Cache Service to launch the DCS console. Step 4 Click Create DCS Instance. Step 5 Specify DCS instance parameters, such as the name, AZ, VPC, security group, and subnet. 2020-07-17 15
Distributed Cache Service User Guide 2 Getting Started Table 2-1 DCS instance parameters Parameter Description Region Region in which DCS is located. To select a different region, use the region selector at the upper left of the main menu bar. Cache Cache engine used. Currently supported: Redis. Engine Version Currently, only Redis 3.0 is supported. Instance Type of the DCS instance being created. Type Single-node, master/standby, and Proxy Cluster types are supported. AZ AZ in which the new DCS instance resides. If the instance type is master/standby or Proxy Cluster, this parameter is displayed as Master AZ. Standby AZ Standby AZ in which the new DCS instance resides. If the instance type is master/standby or Proxy Cluster, Standby AZ is displayed. Select a standby AZ for the standby node of the instance. Instance Total memory of the new DCS instance. Specificatio ● 2, 4, 8, 16, 32, or 64 GB if the DCS instance is in single-node or n master/standby mode ● 64, 128, 256 or 512 GB if the DCS instance is in Proxy Cluster mode When creating a DCS instance on the DCS console, available free memory is listed below the Instance Specification field. If you need more memory, click Increase quota below the Instance Specification field and contact customer service. VPC Select a created VPC, subnet, and specify the IP address. Security Security group that controls access to the new DCS instance. Group A security group is a set of access control rules that implements access control for mutually trusted ECSs with the same security protection requirements in the same VPC. Password Password required for accessing the new DCS instance. NOTE For security purposes, the system prompts you to enter an instance-specific password when you are accessing the DCS instance. Keep your instance password secure and change it periodically. Passwords cannot be left unspecified and must: ● Consist of 8 to 32 characters. ● Contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters (`~!@#$^&*()-_=+\|{}:,/?). More Settings 2020-07-17 16
Distributed Cache Service User Guide 2 Getting Started Parameter Description Name Name of the new DCS instance. A DCS instance name cannot be left unspecified and must: ● Consist of 4 to 64 characters. ● Consist of only letters, digits, hyphens (-), and underscores (_). ● Start with an uppercase or lowercase letter. Description Description of the new DCS instance. Auto Data backup policy. This parameter is displayed only when the Backup instance type is master/standby or Proxy Cluster. For more information on how to configure a backup policy, see Configuring a Backup Policy. Maintenanc Time range for any scheduled maintenance activities to occur for e cache nodes of this DCS instance. Values: ● 02:00-06:00 ● 06:00-10:00 ● 10:00-14:00 ● 14:00-18:00 ● 18:00-22:00 ● 22:00-02:00 Step 6 Click Create Now. The displayed page shows the instance information you have specified. Step 7 Confirm the instance information and click Submit. Step 8 After the new DCS instance has been created, return to the Cache Manager page to view and manage your DCS instances. It takes 5 to 15 minutes to create a DCS instance. However, it will take up to approximately 30 minutes if the DCS instance is in Proxy Cluster mode. After a DCS instance has been successfully created, it enters the Running state by default. 2020-07-17 17
Distributed Cache Service User Guide 2 Getting Started NOTE ● If the new DCS instance failed to be created, delete the unsuccessful instance creation task by following the procedure in Deleting Instance Creation Tasks That Have Failed to Run. Then, create the DCS instance again. If the DCS instance still fails to be created, contact customer service. ● There is the management plane and the tenant plane. The tenant plane is also called the pod zone. During the creation of a DCS instance, a VM is created in the pod zone. If the instance creation fails, the instance status changes to Faulty, and the error message "Failed to connect to the instance. Network exceptions may have occurred in the pod zone." is displayed, indicating that the management plane cannot be connected to the tenant plane. ----End 2.3 Accessing a DCS Redis Instance You can access the created DCS instances through your Redis client. DCS works with multiple types of Redis clients. This section describes how to use the redis-cli and Redis Java (Jedis) clients to access a DCS Redis instance. For more information on how to use other Redis clients, visit https://redis.io/clients. Prerequisites ● The DCS Redis instance you want to access is in the Running state. ● An ECS has been created to serve as your Redis client. For more information on how to create ECSs, see the Elastic Cloud Server User Guide. ● The GNU Compiler Collection (GCC) has been installed on the ECS serving as your Redis client. NOTE The ECS serving as your Redis client and the DCS instance to be accessed must belong to the same VPC and can communicate with each other. Procedure Step 1 Log in to the management console. Step 2 Click in the upper left corner of the management console and select a region and a project. Step 3 Click Service List, and choose Database > Distributed Cache Service to launch the DCS console. Step 4 In the navigation pane, choose Cache Manager. Step 5 Obtain the IP address:port number of the DCS instance. 1. On the Cache Manager page, click the name of the DCS instance you want to access. 2. On the Basic Information tab page of the instance, view the Connection Address in the Connection section. 2020-07-17 18
Distributed Cache Service User Guide 2 Getting Started Step 6 Access the chosen DCS instance. ● By using redis-cli a. Download the source code package of your Redis client from http:// download.redis.io/releases/redis-3.0.7.tar.gz. b. Upload the source code package of your Redis client to the ECS serving as your Redis client. c. Log in to the ECS that serves as your Redis client. d. Run the following command to decompress the redis-3.0.7 directory from the source code package of your Redis client: tar -xzf redis-3.0.7.tar.gz e. Run the following commands to go to the redis-3.0.7 directory and compile the source code of your Redis client: cd redis-3.0.7 make f. Run the following commands to access the chosen DCS instance: cd src ./redis-cli -h 192.168.0.148 -p 6379 In the second command, use the DCS instance IP address and port number obtained in Step 5. g. On redis-cli, run the following command to authenticate access to the selected DCS instance: auth password In this command, password indicates the password used for login to the chosen DCS instance. This password is defined during DCS Redis instance creation. If information similar to the following is displayed, access to the chosen DCS instance is authenticated, and you can now read from and write to the chosen DCS instance: [root@dcs-vm ~]# ./redis-cli -h 192.168.0.148 -p 6379 192.168.0.148:6379> auth ****** OK 192.168.0.148:6379> In this example command output: ▪ 192.168.0.148 is an example IP address of DCS instance, which is obtained in Step 5. ▪ 6379 is an example port number of DCS instance, which is obtained in Step 5. ● By using Jedis a. Obtain the source code of the Jedis client from https://github.com/ xetorthio/jedis. b. Write code. i. Example code for a single Jedis connection //Create a connection String host = "192.168.0.150"; int port = 6379; String pwd = "passwd"; 2020-07-17 19
Distributed Cache Service User Guide 2 Getting Started Jedis client = new Jedis(host, port); client.auth(pwd); client.connect(); //Run the set command String result = client.set("key-string", "Hello, Redis!"); System.out.println( String.format("set command result:%s", result) ); //Run the get command String value = client.get("key-string"); System.out.println( String.format("get command result:%s", value) ); NOTE In actual scenarios, replace passwd with the actual ciphertext password of the Redis instance. Do not hard-code the plaintext password in the code. This advice also applies to passwd configurations in other steps. ii. Example code for a Jedis connection pool //Generate configuration information of a Jedis connection pool String ip = "192.168.0.150"; int port = 6379; String pwd = "passwd"; GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setTestOnBorrow(false); config.setTestOnReturn(false); config.setMaxTotal(100); config.setMaxIdle(100); config.setMaxWaitMillis(2000); JedisPool pool = new JedisPool(config, ip, port, 100000, pwd);//Generate a Jedis connection pool when the client application is being initialized //Get a Jedis connection from the Jedis connection pool when the client initiates a request Jedis client = pool.getResource(); try { //Run commands String result = client.set("key-string", "Hello, Redis!"); System.out.println( String.format("set command result:%s", result) ); String value = client.get("key-string"); System.out.println( String.format("get command result:%s", value) ); } catch (Exception e) { // TODO: handle exception } finally { //Return the Jedis connection to the Jedis connection pool after the client's request is processed if (null != client) { pool.returnResource(client); } } // end of try block //Destroy the Jedis pool when the client application is closed pool.destroy(); c. Compile code according to the readme file in the source code of the Jedis client. Run the Jedis client to access the chosen DCS Redis instance. ----End 2.4 Viewing Details of a DCS Instance Scenario On the DCS console, you can view details about a DCS instance. Procedure Step 1 Log in to the management console. 2020-07-17 20
Distributed Cache Service User Guide 2 Getting Started Step 2 Click in the upper left corner of the management console and select a region and a project. Step 3 Click Service List, and choose Database > Distributed Cache Service to launch the DCS console. Step 4 In the navigation pane, choose Cache Manager. Step 5 On the Cache Manager page, search for DCS instances using any of the following methods: ● Search by keyword. Enter a keyword to search. ● Select attributes and enter their keywords to search. Currently, you can search by name, ID, IP address, AZ, status, and instance type. For more information on how to search, click the question mark to the right of the search box. Step 6 On the DCS instance list, click the name of the chosen DCS instance to display more details about it. Table 2-2 Parameters on the Basic Information page of a DCS instance Section Parameter Description Instance Name Name of the chosen instance. To modify the Details instance name, click the icon. Status State of the chosen instance. ID ID of the chosen instance. Cache Cache engine used by the chosen instance. Engine Currently, only Redis 3.0 is supported. Instance Type of the selected instance. Currently, supported Type types include single-node, master/standby, Proxy Cluster. Cache Size Specification of the chosen instance. (GB) Used/ The used memory space and maximum available Available memory space of the chosen instance. Memory The used memory space includes: (MB) ● Size of data stored on the DCS instance ● Size of Redis-server buffers (including client buffer and repl-backlog) and internal data structures Created Time at which the chosen instance started to be created. 2020-07-17 21
Distributed Cache Service User Guide 2 Getting Started Section Parameter Description Run Time at which the instance was created. Maintenanc Time range for any scheduled maintenance activities e on cache nodes of this DCS instance. To modify the time window, click the icon. Description Description of the chosen DCS instance. To modify the description, click the icon. Connectio Password Currently, you must enable password-protected n Protected access. Connection IP address and port number of the chosen instance. Address Network AZ Availability zone in which the node running the selected DCS instance resides. VPC VPC in which the chosen instance resides. Subnet Subnet in which the chosen instance resides. Security Security group that controls access to the chosen Group instance. To modify the security group, click the icon. ----End 2020-07-17 22
Distributed Cache Service User Guide 3 Operation Guide 3 Operation Guide 3.1 Configuring Redis-Specific Parameters On the DCS console, you can configure Redis-specific parameters to keep DCS instances performing optimally. NOTE The default values are already optimized for typical use cases. Reconfiguring parameters is recommended only when necessary. Prerequisites The DCS instance you want to configure is in the Running state, and the instance type is single-node or master/standby (Redis parameters of DCS instances in Proxy Cluster mode are not modifiable). Procedure Step 1 Log in to the management console. Step 2 Click in the upper left corner of the management console and select a region and a project. Step 3 Click Service List, and choose Database > Distributed Cache Service to launch the DCS console. Step 4 In the navigation pane, choose Cache Manager. Step 5 On the Cache Manager page, click the name of the DCS instance you want to configure. A page with details of the DCS instance is displayed. Step 6 On the instance details page, click the Parameters tab. Step 7 On the Parameters tab page, click Modify. Step 8 Modify Redis-specific parameters based on your requirements. 2020-07-17 23
Distributed Cache Service User Guide 3 Operation Guide NOTE The Redis parameters supported by single-node and master/standby instances are different. The following parameters are only supported by master/standby instances, but are not supported by single-node instances: ● appendfsync ● appendonly ● repl-backlog-size ● repl-backlog-ttl Table 3-1 Redis-specific parameters Param Description Possible Values Default eter Value append Controls how often fsync() ● no everysec fsync transfers cached data to the disk. ● always Note that some OSs will perform a complete data transfer but ● everysec some others only make a "best- effort" attempt. There are three settings: no: fsync() is never called. The OS will flush data when it is ready. This mode offers the highest performance. always: fsync() is called after every write to the AOF. This mode is very slow, but also very safe. everysec: fsync() is called once per second. This mode provides a compromise between safety and performance. repl- The replication backlog size 16,384–1,073,741,824 1,048,57 backlo (bytes). The backlog is a buffer 6 g-size that accumulates replica data when replicas are disconnected from the master. When a replica reconnects, a partial synchronization is performed to synchronize the data that was missed while replicas were disconnected. repl- The amount of time, in seconds, 0–604,800 3,600 backlo before the backlog buffer is g-ttl released, starting from the last a replica was disconnected. The value 0 indicates that the backlog is never released. 2020-07-17 24
Distributed Cache Service User Guide 3 Operation Guide Param Description Possible Values Default eter Value append Indicates whether to log each ● yes yes only modification of the instance. By ● no default, data is written to disks asynchronously in Redis. If this function is disabled, recently- generated data might be lost in the event of a power failure. Options: yes: enabled no: disabled maxme How DCS will select what to volatile-lru noevictio mory- remove when maxmemory is allkeys-lru n policy reached. volatile-random For more information about this parameter, see What Is the allkeys-random Default Data Eviction Policy? volatile-ttl noeviction hash- When the number of entries in 1 to 10000 512 max- hashes is less than the value of ziplist- this parameter, hashes are entries encoded using a memory efficient data structure. hash- When the biggest entry in 1 to 10000 64 max- hashes does not exceed the ziplist- length threshold indicated by value this parameter, hashes are encoded using a memory efficient data structure. list- When the number of entries in 1 to 10000 512 max- lists is less than the value of this ziplist- parameter, lists are encoded entries using a memory efficient data structure. list- When the biggest entry in lists 1 to 10000 64 max- does not exceed the length ziplist- threshold indicated by this value parameter, lists are encoded using a memory efficient data structure. 2020-07-17 25
Distributed Cache Service User Guide 3 Operation Guide Param Description Possible Values Default eter Value set- When a set is composed entirely 1 to 10000 512 max- of strings that happen to be intset- integers in radix 10 in the range entries of 64 bit signed integers, sets are encoded using a memory efficient data structure. zset- When the number of entries in 1 to 10000 128 max- sorted sets is less than the value ziplist- of this parameter, sorted sets are entries encoded using a memory efficient data structure. zset- When the biggest entry in sorted 1 to 10000 64 max- sets does not exceed the length ziplist- threshold indicated by this value parameter, sorted sets are encoded using a memory efficient data structure. latency Only events that run in more 0 to 86400000 ms 0 - time than the configured monito latency-monitor-threshold will be r- logged as latency spikes. thresho ● If the latency-monitor- ld threshold is set to 0, latency monitoring is disabled. ● If the latency-monitor- threshold is set to a value greater than 0, all events blocking the server for a time equal to or greater than the configured latency-monitor- threshold will be logged. By running the LATENCY command, you can perform operations related to latency monitoring, such as enabling latency monitoring, reporting the latest latency events logged, and obtaining statistical data. For more information about the latency-monitor-threshold, visit https://redis.io/topics/latency- monitor. 2020-07-17 26
Distributed Cache Service User Guide 3 Operation Guide Param Description Possible Values Default eter Value reserve Percentage of the maximum 0–80 0 d- available memory reserved for memor background processes, such as y- data persistence and replication. percent timeou Connection between the client 0 to 7200 seconds 0 t and server (DCS instance) will be closed if the client is idle for the timeout period (measured in seconds). A timeout period of 0 seconds indicates that the timeout function is disabled. 2020-07-17 27
Distributed Cache Service User Guide 3 Operation Guide Param Description Possible Values Default eter Value notify- Keyspace event notification. If If the parameter value "" keyspa this parameter is configured, the is an empty character ce- Redis Sub/Pub feature will allow string, keyspace event events clients to receive an event when notification is disabled. a Redis data set is modified. If the parameter value is a string of multiple characters, keyspace event notification is enabled and each character identifies a class of keyspace events for which Redis will send notifications. NOTE ● The parameter value must contain either K or E. ● A is an alias for "g $lshzxe"and cannot be used together with any of the characters "g $lshzxe". ● For example, the value Kl means that Redis will notify Pub/Sub clients about keyspace events and list commands. The value AKE means Redis will notify Pub/Sub clients about all events. K: Keyspace events, published with the __keyspace@__ prefix E: Keyevent events, published with __keyevent@__ prefix g: Generic commands (non-type specific) such as DEL, EXPIRE, and RENAME $: String commands l: List commands s: Set commands h: Hash commands 2020-07-17 28
Distributed Cache Service User Guide 3 Operation Guide Param Description Possible Values Default eter Value z: Sorted set commands x: Expired events (events generated every time a key expires) e: Evicted events (events generated when a key is evicted for maxmemory) A: Alias for "g$lshzxe", so that the "AKE" string means all the events. Note that the parameter value must contain either K or E. slowlog The maximum amount of time 0–1,000,000 10,000 -log- allowed, in microseconds, for slower- command execution. If this than threshold is exceeded, Redis Slow Log will record the command. slowlog The maximum allowed length of 0–1,000 128 -max- the Redis Slow Log logs. Slow len Log consumes memory, but you can reclaim this memory by running the SLOWLOG RESET command. NOTE ● For more information about Redis-specific parameters, visit https://redis.io/topics/ memory-optimization. ● The latency-monitor-threshold parameter is usually used for fault location. After locating faults based on the latency information collected, change the value of latency- monitor-threshold to 0 to avoid unnecessary latency. Step 9 After you have finished setting parameters, click Save. Step 10 Click Yes to confirm. ----End 2020-07-17 29
Distributed Cache Service User Guide 3 Operation Guide 3.2 Starting DCS Instances Scenario On the DCS console, you can start one or multiple DCS instances at a time. NOTE This function is not supported by recent instances. You can only start old instances that have been stopped. Once started, these instances can only be restarted and can no longer be stopped or started. Procedure Step 1 Log in to the management console. Step 2 Click in the upper left corner of the management console and select a region and a project. Step 3 Click Service List, and choose Database > Distributed Cache Service to launch the DCS console. Step 4 In the navigation pane, choose Cache Manager. Step 5 Click Start in the same row as the instance. Step 6 In the Start dialog box, click OK to confirm that you want to start the instances. It takes 1 to 30 minutes to start DCS instances. After DCS instances are started, their status changes from Stopped to Running. ----End 3.3 Restarting DCS Instances Scenario On the DCS console, you can restart one or multiple DCS instances at a time. NOTICE ● While a DCS instance is restarting, it cannot be read from or written to. ● If the DCS instance is a single-node instance, data will also be deleted from it when it is restarted. ● An attempt to restart a DCS instance while it is being backed up may result in a failure. Prerequisites The DCS instances you want to restart are in the Running or Faulty state. 2020-07-17 30
You can also read