If it is in ZIP format, first

[root@localhost ~]# yum -y install zip unzip

[root@localhost ~]# unzip *.zip

IO /download or github.com/antirez/red…

The tar XZF redis – 3.2.12. Tar. Gz

Chmod -r 777 redis-3.2.12 # Linux -r -r redis-3.2.12 make

/redis/redis-3.2.12/deps/jemalloc will fail because it has no permissions

(2)make uses jemalloc’s memory allocator by default.

(3) Finally, you don’t need to execute the command make install, so that the new version of Redis is not easy to manage.

(4) If compilation error occurs:

In file included from adlist.c:34:0:

zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory

#include <jemalloc/jemalloc.h>

^

compilation terminated.

make[1]: *** [adlist.o] Error 1

make[1]: Leaving directory `/home/redis-3.2.12/src’

make: *** [all] Error 2

Go to the jemalloc folder manually and make

# cd deps/jemalloc/

# make

(5) If compilation error occurs:

Debug. o: In function ‘debugCommand’: /home/redis-3.2.12/src/debug.c:535: Use of undefined constant reference to ‘je_mallctl’ /home/redis-3.2.12/src/debug.c:537: Use of undefined constant reference to ‘je_mallctl’ /home/redis-3.2.12/src/debug.c:529: Undefined reference to ` je_malloc_stats_print ‘zmalloc. O: In function ` zmalloc’ : / home/redis – 3.2.12 / SRC/zmalloc. C: 125: Undefined reference to ` je_malloc ‘/ home/redis – 3.2.12 / SRC/zmalloc. C: 129: undefined reference to ` je_malloc_usable_size’

Make CFLAGS=”-march=x86-64″

(6) After compiling, users can directly start the Redis server in the source folder path.

2, the author of the redis path is/root/Downloads/redis/redis – 3.2.12 /

Copy the configuration file/root/Downloads/redis/redis – 3.2.12 / redis. Conf to the following path: / root/Downloads/redis/redis – 3.2.12 / SRC in terminal execute commands, start the redis server [root @ localhost SRC] #. / redis – server redis. Conf

If the command does not contain a configuration parameter file, the default parameters are used. Redis does not run as a daemon by default and can be modified with this configuration item by enabling the daemon with yes, line 136 daemonize yes

Check the running status [root @ localhost SRC] # ps – ef | grep redis

Start the client and exit

[root@localhost SRC]#./redis-cli 127.0.0.1:6379> quit

By default, only local access is allowed to Redis. To enable remote access to Redis, modify redis.conf

Open/root/Downloads/redis/redis – 3.2.12 / SRC/redis. Conf file, line 69, in the NETWORK

 

################################## NETWORK ##################################### # By default, if no “bind” configuration directive is specified, Redis listens# for connections from all the network interfaces available on the server.# It is possible to listen to just one or multiple selected interfaces using# the “bind” configuration directive, Followed by one or more IP addresses.## Examples:## bind 192.168.1.100 10.0.0.1# bind 127.0.0.1 ::1## ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the# internet, binding to all the interfaces is dangerous and will expose the# instance to everybody on the internet. So by default we uncomment the# following bind directive, that will force Redis to listen only into# the IPv4 lookback interface address (this means Redis will be able to# accept connections only from clients running into the same computer it# is running).## IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES# JUST COMMENT THE FOLLOWING LINE.# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ the bind 127.0.0.1

 

Workaround: Comment out bind 127.0.0.1 to enable all IP addresses to access Redis, or change 127.0.0.1 to 0.0.0.0

You can bind if you want to specify multiple IP accesses but not all of them

Pay attention to

Here’s another explanation, line 88

 

# Protected mode is a layer of security protection, in order to avoid that# Redis instances left open on the internet are accessed and exploited.## When protected mode is on and if:## 1) The server is not binding explicitly to a set of addresses using the# “bind” directive.# 2) No password is configured.## The server only accepts connections from clients connecting from the# IPv4 and IPv6 loopback addresses 127.0.0.1 and: : 1, and from Unix domain# sockets.## By default protected mode is enabled. You should disable it only if# you are sure you want clients from other hosts to connect to Redis# even if no authentication is configured, nor a specific set of interfaces# are explicitly listed using the “bind” directive.protected-mode yes

 

After Redis3.2, Redis added protected-mode. In this mode, even if you commented out bind 127.0.0.1, redisd still returns an error, as shown below

 

(error) DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command ‘CONFIG SET protected-mode no’ from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to ‘no’, and then restarting the server. 3) If you started the server manually just for testing, restart it with the ‘–protected-mode no’ option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

 

Change method: protected-mode no

4. Local client access

./redis-cli

 

5, external clients want to access, but also need to consider the problem of the firewall.

The default firewall of CentOS7 is firewall. Disable it

Disable the firewall firewall: sudo systemctl stop firewalld.service

Disable the firewall startup: sudo systemctl disable firewalld.service

Firewall-cmd –state # Check the status

# # # # # # # # # # # # # # # # # # # learning materials redis. Conf # # # # # # # # # # # # # # # # # # # # # # # # # # # #

In the process of using Redis, in addition to knowing the operation method of the five data types of Redis, the most important amount is to configure the Redis. Parameter Description Redis. Conf Configuration items are described as follows:

1: Redis does not run as a daemon by default. This configuration item can be modified by using yes to enable the daemon, line 136 daemonize no

Pid is written to the /var/run/redis.pid file by default when Redis runs as a daemon. Pidfile can be specified as pidfile /var/run/redis.pid

The default port is 6379. The author explained in a blog post why 6379 was chosen as the default port, because 6379 is the number corresponding to MERZ on the phone keys, and MERZ is derived from the name of Italian singer Alessia MERZ. Port 6379

4: indicates the IP address of the bound host. Bind 127.0.0.1

5: Closes the connection after the client is idle. If this parameter is set to 0, timeout 300 is disabled

6: specifies the loglevel. Redis supports four levels: debug, verbose, notice, and warning. The default value is verbose loglevel verbose

7: Log mode. The default value is standard output. If Redis is configured to run in daemon mode and the log mode is configured as standard output, logs will be sent to /dev/null logfile stdout

8: Set the number of databases. The default database is 0. You can use the SELECT command to specify the database ID on the connection

9: The default Redis configuration file provides three conditions: Save 900 1 Save 300 10 Save 60 10000 indicates 1 change in 900 seconds (15 minutes), 10 changes in 300 seconds (5 minutes), and 10000 changes in 60 seconds respectively.

Default: yes. Redis uses LZF compression. If you want to save CPU time, you can disable this option, but it will cause database files to become large RDBcompression yes

11: Specifies the name of the local database file. The default value is dump. RDB dbfilename dump. RDB

12: Specify the local database directory dir./

If Slav service is used on the host, set the IP address and port number of the master service. When Redis starts, it will automatically synchronize data from the master to Slaveof

14: If password protection is enabled for the master service, the Slav service connects to the master using the masterauth password

15: Set the Redis connection password. If the password is configured, the client needs to use the AUTH command to provide the password when connecting to Redis. Requirepass foobared is disabled by default

16: Sets the maximum number of client connections at a time. The default limit is unlimited. The maximum number of client connections that Redis can open at a time is the maximum number of file descriptors that the Redis process can open. When the number of clients reached the limit, Redis will close new connections and return Max Number of clients reached error message maxClients 128

17: Specifies the maximum memory limit for Redis. When Redis starts up, it loads data into memory. When the maximum memory is reached, Redis tries to clear expired or expiring keys first. The new VM mechanism of Redis will store the Key in memory and the Value in swap maxMemory

18: Specifies whether to log after each update operation. Redis writes data to disk asynchronously by default. If this function is not enabled, data may be lost for a period of time in the event of a power failure. Because redis itself synchronizes data files according to the above save conditions, some data will only exist in memory for a period of time. The default is no appendonly No

19: specifies the update log filename. The default value is appendone.aof appendfilename appendone.aof

20: Three values are available: no: data is cached by the operating system and synchronized to disk (fast) always: data is written to disk (slow and safe) manually by calling fsync() after each update operation everysec: Represents synchronization once per second (compromise, default) appendfSync everysec

21: Specifies whether to enable the virtual memory mechanism. The default value is no. For a brief introduction, the VM mechanism stores data in paging mode, and Redis swaps cold data on less visited pages to disk. Frequently visited pages are automatically swapped out from disk to memory (I will analyze Redis VM mechanism in detail in a later article) VM-enabled No

The default value is/TMP /redis.swap. Multiple Redis instances cannot share vm-swap-file/TMP /redis.swap

23: All data larger than VM-max-memory is stored in virtual memory. No matter how small the VM-max-memory setting is, all index data is stored in memory (Redis index data) Keys), which means that when vM-max-memory is set to 0, all values actually exist on disk. The default value is 0 vM-max-memory 0

24: The Redis swap file is divided into many pages. An object can be stored on multiple pages, but a page cannot be shared by multiple objects. Vm-page-size is set according to the size of the stored data. The page size is best set to 32 or 64bytes; If you store large objects, you can use a larger page, or if in doubt, use the default vM-page-size 32

25: set the number of pages in the swap file. Since the page table (a bitmap indicating that a page is free or used) is in memory, every 8 pages on disk consumes 1byte of memory. vm-pages 134217728

26: Set the number of threads accessing the swap file. It is better not to exceed the number of cores on the machine. If set to 0, all operations on the swap file are serial and may cause a long delay. The default value is 4 VM-max-threads 4

27: Sets whether to combine small packets into one packet when replying to clients. By default, glueOutputBuf yes is enabled

28: Specifies a special hash algorithm to be used when the number of elements exceeds a certain threshold or the maximum number exceeds a threshold 64 hash-max-zipmap-value 512

Activerehashing yes: Specifies whether to enable rehash. Default: Enable

30: Specify to include additional configuration files. You can use the same configuration file among multiple Redis instances on the same host, and each instance has its own specific configuration file include /path/to/local.conf