Redis主从搭建
redis安装方法见:初识Redis邂逅 安装环境: [root@localhost redis]# redis-server --versionRedis server v=2.8.7 sha=00000000:0 malloc=jemalloc-3.2.0 bits=32 build=df8b796b6fcf0127[root@localhost redis]# cat /proc/versionLinux version 2.6.18-9
redis安装方法见:初识Redis——邂逅
安装环境:[root@localhost redis]# redis-server --version Redis server v=2.8.7 sha=00000000:0 malloc=jemalloc-3.2.0 bits=32 build=df8b796b6fcf0127 [root@localhost redis]# cat /proc/version Linux version 2.6.18-92.el5 (mockbuild@builder16.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Jun 10 18:49:47 EDT 2008
#master配置文件 cp redis.conf redis-master.conf #slave配置文件 cp redis.conf redis-slave.conf #备份配置文件 cp redis.conf redis-bak.conf
#master配置文件 #保证PID文件区分,PID文件主要用于保证守护进程单例运行 pidfile /var/run/redis-master.pid #区分LOG文件 logfile "/data/redis/6379/log/redis.log" #区分持久化文件 dir /data/redis/6379/data #区分端口 port 6379 #slave配置文件 pidfile /var/run/redis-slave.pid logfile "/data/redis/6380/log/redis.log" dir /data/redis/6380/data port 6380 slaveof 127.0.0.1 6379 #如果为yes,slave实例只读,如果为no,slave实例可读可写。默认 slave-read-only yes
redis-server /etc/redis/redis-master.conf redis-server /etc/redis/redis-slave.conf
[root@localhost redis]# cat /data/redis/6379/log/redis.log [24787] 13 Sep 10:39:45.143 * Max number of open files set to 10032 [24787] 13 Sep 10:39:45.145 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.7 (00000000/0) 32 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 24787 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [24787] 13 Sep 10:39:45.146 # Server started, Redis version 2.8.7 [24787] 13 Sep 10:39:45.146 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. [24787] 13 Sep 10:39:45.146 * The server is now ready to accept connections on port 6379 [24787] 13 Sep 10:40:54.342 * DB saved on disk [24787] 13 Sep 10:42:50.581 * Slave asks for synchronization [24787] 13 Sep 10:42:50.581 * Full resync requested by slave. [24787] 13 Sep 10:42:50.581 * Starting BGSAVE for SYNC [24787] 13 Sep 10:42:50.582 * Background saving started by pid 24816 [24816] 13 Sep 10:42:50.586 * DB saved on disk [24816] 13 Sep 10:42:50.587 * RDB: 0 MB of memory used by copy-on-write [24787] 13 Sep 10:42:50.673 * Background saving terminated with success [24787] 13 Sep 10:42:50.673 * Synchronization with slave succeeded [24787] 13 Sep 10:47:04.093 * DB saved on disk
[root@localhost redis]# cat /data/redis/6380/log/redis.log [24813] 13 Sep 10:42:50.578 * Max number of open files set to 10032 [24813] 13 Sep 10:42:50.579 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.7 (00000000/0) 32 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6380 | `-._ `._ / _.-' | PID: 24813 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [24813] 13 Sep 10:42:50.580 # Server started, Redis version 2.8.7 [24813] 13 Sep 10:42:50.580 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. [24813] 13 Sep 10:42:50.580 * The server is now ready to accept connections on port 6380 [24813] 13 Sep 10:42:50.580 * Connecting to MASTER 127.0.0.1:6379 [24813] 13 Sep 10:42:50.580 * MASTER <-> SLAVE sync started [24813] 13 Sep 10:42:50.580 * Non blocking connect for SYNC fired the event. [24813] 13 Sep 10:42:50.581 * Master replied to PING, replication can continue... [24813] 13 Sep 10:42:50.581 * Partial resynchronization not possible (no cached master) [24813] 13 Sep 10:42:50.583 * Full resync from master: 9ef3d846e366f7643db9e9250b508d64a34c1079:1 [24813] 13 Sep 10:42:50.673 * MASTER <-> SLAVE sync: receiving 31 bytes from master [24813] 13 Sep 10:42:50.673 * MASTER <-> SLAVE sync: Flushing old data [24813] 13 Sep 10:42:50.673 * MASTER <-> SLAVE sync: Loading DB in memory [24813] 13 Sep 10:42:50.674 * MASTER <-> SLAVE sync: Finished with success [24813] 13 Sep 10:47:04.096 * DB saved on disk
[root@localhost redis]# redis-cli 127.0.0.1:6379> set name test OK 127.0.0.1:6379> save OK [root@localhost redis]# redis-cli -p 6380 127.0.0.1:6380> keys * 1) "name"

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

On CentOS systems, you can limit the execution time of Lua scripts by modifying Redis configuration files or using Redis commands to prevent malicious scripts from consuming too much resources. Method 1: Modify the Redis configuration file and locate the Redis configuration file: The Redis configuration file is usually located in /etc/redis/redis.conf. Edit configuration file: Open the configuration file using a text editor (such as vi or nano): sudovi/etc/redis/redis.conf Set the Lua script execution time limit: Add or modify the following lines in the configuration file to set the maximum execution time of the Lua script (unit: milliseconds)

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

When configuring Hadoop Distributed File System (HDFS) on CentOS, the following key configuration files need to be modified: core-site.xml: fs.defaultFS: Specifies the default file system address of HDFS, such as hdfs://localhost:9000. hadoop.tmp.dir: Specifies the storage directory for Hadoop temporary files. hadoop.proxyuser.root.hosts and hadoop.proxyuser.ro

The Hadoop task execution process mainly includes the following steps: Submit the job: the user uses the command line tools or API provided by Hadoop on the client machine to build the task execution environment and submit the task to YARN (Hadoop's resource manager). Resource application: After YARN receives the task submission request, it will apply for resources from the nodes in the cluster based on the resources required by the task (such as memory, CPU, etc.). Task Start: Once the resource allocation is completed, YARN will send the task's startup command to the corresponding node. On the node, NodeMana

Enable Redis slow query logs on CentOS system to improve performance diagnostic efficiency. The following steps will guide you through the configuration: Step 1: Locate and edit the Redis configuration file First, find the Redis configuration file, usually located in /etc/redis/redis.conf. Open the configuration file with the following command: sudovi/etc/redis/redis.conf Step 2: Adjust the slow query log parameters in the configuration file, find and modify the following parameters: #slow query threshold (ms)slowlog-log-slower-than10000#Maximum number of entries for slow query log slowlog-max-len

This article describes how to use TigerVNC to share files on Debian systems. You need to install the TigerVNC server first and then configure it. 1. Install the TigerVNC server and open the terminal. Update the software package list: sudoaptupdate to install TigerVNC server: sudoaptinstalltigervnc-standalone-servertigervnc-common 2. Configure TigerVNC server to set VNC server password: vncpasswd Start VNC server: vncserver:1-localhostno
