redis installation -linux

1, redis.tar.gz upload files to / usr / local /

2, extract

tar zxvf redis.tar.gz

3, a new log file, in / var / log directory

touch /var/log/redis.log

4, copy the relevant files to the bin directory, if the directory already exists, do this step. Jingjing the actual existence of the archive directory after unzip the following files, no need to copy.

  • cp redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server redis-trib.rb /usr/local/redis/bin/

5. Copy the file to the etc directory redis.conf

cp redis.conf /usr/local/redis/etc

6, modify redis.conf files, detailed configuration is shown in another file. (Actual operation do not change anything)

vi /usr/local/redis/etc/redis.conf

Common settings are as follows:

  • Making redis resident in the background

  daemonize no -> daemonize yes 

  • Redis modify the ip default binding, so that all machines can access, of course, you can specify ip

  bind 127.0.0.1 -> bind 0.0.0.0 

  • The protection mode off

  protected-mode yes -> protected-mode no

7, the redis set from the start  

we /etc/rc.local

 Add content in a casual line:

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

 This command will invoke the boot open redis

8, open port 6379 (redis default port can be modified, if the firewall to open the case)

  Open ports command:  

/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT

 Check ports open the case:

/sbin/iptables -L -n

9, start redis (If you have already started redis, you will need to close and open)

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

10, other supplements

Close redis:

pkill redis
killall redis-server // may be 2-to-1

Connection redis

./redis-cli
redis-cli -h 127.0.0.1 -p 16000 -a '123456' // connection Redis, -h designated host, -p specify the listener port, -a specify the login password

View the process, search port 6379

ss -lnp | grep 6379

 

Guess you like

Origin www.cnblogs.com/qdlh/p/12195870.html