Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install Redis under centOS

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

First, stand-alone mode

1. Download the installation package

Wget http://download.redis.io/releases/redis-4.0.2.tar.gz

2. Unpack the installation package and install it

Tar-zxvf redis-4.0.2.tar.gz

Cd redis-4.0.2

Make

Error: jemalloc/jemalloc.h: do not have that file or directory, execute make MALLOC=libc

Cd / usr/local/redis-4.0.2/src

Make install

3. Set up two folders to store redis configuration and command files

Mkdir-p / usr/local/redis/etc

Mkdir-p / usr/local/redis/bin

4, put the redis configuration and command files in the newly created folder

Cd / usr/local/redis-4.0.2

Cp redis.conf / usr/local/redis/etc

Cd / usr/local/redis-4.0.2/src

Mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server / usr/local/redis/bin

5, start up and specify the configuration file

Front desk launch: / usr/local/redis/bin/redis-server / usr/local/redis/etc/redis.conf

6. Verify that the startup is successful:

Ps-ef | grep 6379

Netstat-tunpl | grep redis

7. Modify backend startup

Vim / usr/local/redis/etc/redis.conf

Daemonize yes makes Redis run in daemon mode

8, stop Redis

/ usr/local/redis/bin/redis-cli SHUTDOWN

Second, master-slave replication mode (read-write separation: master writable, slave read-only)

Planning: 101master node, 102103 slave node

Remote recursive copy

Log in to 101service and cd / usr/local/

Scp-r redis-4.0.2/ 192.168.0.102:/usr/local/

Scp-r redis/ 192.168.0.102:/usr/local/

Scp-r redis-4.0.2/ 192.168.0.103:/usr/local/

Scp-r redis/ 192.168.0.103:/usr/local/

two。 Modify slave node 102103 configuration file

Vim / usr/local/redis/etc/redis.conf

Modify the following

# Redis uses background mode

Daemonize yes

Slaveof 192.168.0.101 6379

# turn off protection mode

Protected-mode no

# Note the following to enable remote access

# bind 127.0.0.1

3. Modify 101 configuration file

Daemonize yes

# turn off protection mode

Protected-mode no

# Note the following to enable remote access

# bind 127.0.0.1

4. Restart the service

Enter the 101 client

Redis client command: / usr/local/redis/bin/redis-cli

View node information through info

Enter 102 client

Redis client command: / usr/local/redis/bin/redis-cli

View node information through info

Third, Sentinel mode

Planning: deployment servers with 102 as sentinels the following operations are performed on 102 servers

(1) copy file sentinel.conf to / usr/local/redis/etc/

Cd / usr/local/redis-4.0.2

Cp sentinel.conf / usr/local/redis/etc

(2) modify sentinel.con file:

Vim / usr/local/redis/etc/sentinel.conf

Sentinel monitor mymaster 192.168.1.101 6379 1

Sentinel down-after-milliseconds mymaster 5000

Sentinel failover-timeout mymaster 900000

Sentinel parallel-syncs mymaster 2

(3) activate sentinel Sentinel

/ usr/local/redis/bin/redis-server / usr/local/redis/etc/sentinel.conf-- sentinel &

(4) View Sentinel related information command

/ usr/local/redis/bin/redis-cli-h 192.168.0.102-p 26379 info Sentinel

An error is reported here:

(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.

Modify the sentinel.conf file

Vim / usr/local/redis/etc/sentinel.conf

# bind 127.0.0.1

Protected-mode no

The corresponding 101102103 redis.conf configuration files should also be configured in this way.

Reboot restart service executes again

/ usr/local/redis/bin/redis-cli-h 192.168.0.102-p 26379 info Sentinel

(5) close the master server to view the cluster information:

/ usr/local/redis/bin/redis-cli-h 192.168.0.101-p 6379 shutdown

Master node transferred successfully (essentially modified the parameter slaveof of the corresponding redis.conf configuration file)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report