Specific steps for installing Redis3.0.2 under CentOS 6.564-bit
System environment: CentOS 6.564 bit
Installation method: compile and install
Firewalls: turning on
Redis version: Redis 3.0.2
I. Environmental preparation
1. Install gcc gcc-c++
[root@iZ94ebgv853Z ~] # yum install gcc gcc-c++-y
2. Download redis-3.0.2.tar.gz
[root@iZ94ebgv853Z ~] # wget http://download.redis.io/releases/redis-3.0.2.tar.gz
Second, install Redis
[root@iZ94ebgv853Z ~] # tar xf redis-3.0.2.tar.gz # decompress [root@iZ94ebgv853Z ~] # cd redis-3.0.2 [root@iZ94ebgv853Z redis-3.0.2] # make [root@iZ94ebgv853Z redis-3.0.2] # make test
The error is as follows:
Cd src&& make test
Make [1]: Entering directory `/ root/redis-3.0.2/src'
You needtcl 8.5 or newer in order to run the Redis test
Make [1]: * * [test] Error 1
Make [1]: Leaving directory `/ root/redis-3.0.2/src'
Make: * * [test] Error 2
Reason: tcl needs to be installed
[root@iZ94ebgv853Zredis-3.0.2] # yum install tcl-y [root@iZ94ebgv853Zredis-3.0.2] # make test [root@iZ94ebgv853Zredis-3.0.2] # cp redis.conf / etc/ # copy configuration file
If you need to customize the configuration redis, modify its configuration file / etc/redis.conf
3. Under the redis3.0.2 folder, the last step of installing redis:
[root@localhost redis-3.0.2] # ls [root@localhost redis-3.0.2] # cd src [root@localhost src] # make install
4. Start redis
[root@iZ94ebgv853Z ~] # redis-server / etc/redis.conf
Fifth, set up a firewall
# # Firewall configuration written bysystem-config-firewall# Manual customization of this file is notrecommended.*filter:INPUT ACCEPT [0:0]: FORWARD ACCEPT [0:0]: OUTPUT ACCEPT [0:0]-An INPUT-m state-- stateESTABLISHED RELATED-j ACCEPT-An INPUT-p icmp- j ACCEPT-An INPUT-I lo-j ACCEPT-An INPUT-m state-- state NEW-m tcp- p tcp--dport 22-j ACCEPT-An INPUT-j REJECT-- reject-withicmp-host-prohibited-A FORWARD-j REJECT-- reject-withicmp-host-prohibitedCOMMIT##
Write the contents of the text box to / etc/sysconfig/iptables, overwriting the original content, if any.
[root@iZ94ebgv853Z ~] # service iptables start # start firewall [root@iZ94ebgv853Z ~] # iptables-I INPUT 1-p tcp-- dport6379-j ACCEPT # Open port 6379 [root@iZ94ebgv853Z ~] # service iptables save # save firewall configuration
6. Set up boot boot
[root@iZ94ebgv853Z~] # chkconfig iptables on # set iptables to boot
Set redis to boot:
Add: / usr/local/bin/redis-server / etc/redis.conf > / dev/null & to / etc/rc.local
(Linux's redis service is turned on and off.
1. Launch: redis-server (redis-server redis.conf)
two。 Login: redis-cli (redis-cli-p 6379)
3. Turn off: redis-cli shutdown
View redis process: ps aux | grep redis
How to kill the process: kill-9 PID)
7. Redis password setting
First shut down the redis service, which has
Then check the current directory in the unzipped redis-3.0.2: [root@localhost redis-3.0.2] # ls
Find the redis.conf configuration file and edit redis.conf: [root@localhost redis-3.0.2] # vim redis.conf
Find the content # requirepass foobared, remove the comments, and change foobared to your own password. Here, I change it to: requirepass 123456
Then save exit and restart the redis service
(note: due to the complexity of the configuration in redis, it is not easy to find note # requirepass foobared, but
1 、
Note # requirepass foobared in
# # LUA SCRIPTING # # Line 13 below this comment
2. Note # requirepass foobared in
# # LIMITS # # the twentieth line above this comment
3. Redis-3.0.2 this version of the redis.conf configuration file has 937 lines. This # requirepass foobared comment is on line 391.
)
8. Jedis connects to redis
Java code mode
/ / Connect to redis server, 192.168.0.100 new Jedis 6379 jedis = new Jedis ("ip", 6379); / / permission authentication jedis.auth ("password")
Configuration file mode
Other commands of redis.
If you need to close redis:
[root@iZ94jzcra1hZ bin] # pkill redis
If you need to enable redis:
[root@iZ94jzcra1hZ bin] # redis-server &
The purpose of the plus-symbol is to convert this process into a background process without consuming shell services.
Summary
The above is the specific steps of installing Redis3.0.2 under CentOS 6.564-bit introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!