Specific steps for installing Redis3.0.2 on CentOS 6.5 64 bit
- 2020-06-15 10:28:16
- OfStack
System environment: CentOS 6.5 64-bit
Installation: Compile installation
Firewall: on
Redis version: Redis 3.0.2
1. Environmental preparedness
1. Install gcc ES15en-ES16en ++
[root@iZ94ebgv853Z ~]# yum install gcc gcc-c++ -y
2. Download ES20en-3.0.2.ES21en. gz
[root@iZ94ebgv853Z ~]# wget http://download.redis.io/releases/redis-3.0.2.tar.gz
2. Install Redis
[root@iZ94ebgv853Z ~]# tar xf redis-3.0.2.tar.gz # Unpack the
[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@iZ94ebgv853Z redis-3.0.2]# make test
[root@iZ94ebgv853Zredis-3.0.2]# cp redis.conf /etc/ # Copy configuration file
If you need to customize the configuration of redis, modify its configuration file /etc/ redis.conf
3. In the es60EN3.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
5. 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]
-A INPUT -m state --stateESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp--dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-withicmp-host-prohibited
-A FORWARD -j REJECT --reject-withicmp-host-prohibited
COMMIT
#####################################
Write the text box content to /etc/sysconfig/iptables, overwriting the original content, if any.
[root@iZ94ebgv853Z ~]# service iptables start # Start the firewall
[root@iZ94ebgv853Z ~]# iptables -I INPUT 1 -p tcp --dport6379 -j ACCEPT # open 6379 port
[root@iZ94ebgv853Z ~]# service iptables save # Save the configuration of the firewall
6. Set startup
[root@iZ94ebgv853Z~]# chkconfig iptables on # Set up the iptables Powered up
Setup redis Boot up:
In/etc rc. Add: local/usr/local/bin/redis - server/etc/redis conf > /dev/null &
(Linux redis service on and off
1. Launch: redis-server (ES106en-ES107en ES108en.ES109en)
2. Landing: redis-ES113en (redis-ES115en-ES116en 6379)
3. Close: redis-ES120en shutdown
View redis process :ps aux | grep redis
How to kill processes: kill-9 PID)
7. redis password setting
First, close the redis service.
Then go to the unzipped ES141en-3.0.2 to see the current directory: [root@localhost ES144en-3.0.2]# ls;
Find the ES148en.conf profile and edit redis.conf: [root@localhost ES154en-3.0.2]# vim ES156en.conf
Find #requirepass foobared uncomment, foobared change to your own password, I will change here: requirepass 123456
Then save, exit, and restart the redis service
Note: It is not easy to find the comment #requirepass foobared due to the variety of configurations in redis, but
1.
Note #requirepass foobared is at
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # LUA SCRIPTING # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # below this annotation line 103;
2. Note #requirepass foobared in
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # LIMITS # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # this annotation on top of the line 210;
The redis.ES187en profile in this version contains 937 lines. The #requirepass foobared comment is at line 391
)
8. Jedis connects redis
java code mode
// The connection redis The server, 192.168.0.100:6379
jedis = new Jedis("ip", 6379);
// Authority certification
jedis.auth("password");
Configuration file mode
[root@iZ94ebgv853Z ~]# wget http://download.redis.io/releases/redis-3.0.2.tar.gz
0
Other commands of redis.
If redis needs to be turned off:
[root@iZ94jzcra1hZ bin]# pkill redis
If redis needs to be turned on:
[root@iZ94jzcra1hZ bin]# redis-server
&
add & The purpose of the symbol is to convert this process to a background process without using shell's services.
conclusion