This article briefly describes the steps to install a Redis server under Linux, with a brief introduction to server configuration, startup, and state detection. It also describes some of the problems encountered when installing Redis under 32-bit CentOS.
First, view Linux related information
Version view
cat/etc/issue
CentOS release 5.5 (Final)
Number of digits view
getconf long_bit
+
second, the installation of TCL
Install Tcl first, or Redis's make test will not pass. You can also install Redis and go back to installing TCL.
1. Download TCL installation package
To access http://sourceforge.net/projects/tcl/files/Tcl/, select the version you want to download. The author chooses the latest stable version of tcl8.6.1-src.tar.gz, size 8.5 MB. The author also uploaded a copy to csdn resources, if you suspect the foreign server speed slow, you can download this: tcl8.6.1 installation package.
2. Installation
Tar xvzf tcl8.6.1-src.tar.gz
CD tcl8.6.1/unix/
./configure
Make
Make Test
Make install
iii. installation of Redis
1. Download the Redis installation package
Visit Http://redis.io/download and choose the version that suits your scenario to download. The author chooses the latest stable version of Redis-2.8.10.tar.gz, which is 1 MB in size. The author also uploaded a copy to csdn resources, if you suspect the foreign server speed slow, you can download this: redis-2.8.10 installation package.
2. Lan Sharing
Most people's development environment is Windows, the author is no exception (of course, the Linux software development environment is also very good, such as the author has been under Linux for half a year Java Mobile development, the experience is wonderful).
So it's usually first downloaded to Windows local (if your speed is also available with wget), then FTP to Linux. Of course, you can also use the way of mount, for example, the author will download redis-2.8.10.tar.gz to the D:\defonds\work\20140610, first to share this folder, Win7 platform, right click Need file 20140610, properties, select "Share" page item, point "Share ..." button-and-File Sharing dialog box, click the "Share" button to confirm the share, and you will be prompted to share and display the Shared Item:
Local Network view:
3. Mounting
To create a new Redis directory:
Mkdir/home/defonds/redis
For example, the previous step to share the IP is 192.21.40.134, the machine user name defonds, password is defonds:
mount-o "Username=defonds,password=defonds"//192.21.40.134/20140610/home/defonds/redis
After the mount is successful, you can use DF to view the mount results, such as:
//192.21.40.134/20140610 133122588 72559176 60563412 55%/home/defonds/redis
4. Installation
Cd/home/defonds/redis
Tar xvzf redis-2.8.10.tar.gz
CD redis-2.8.10
Make
Mkdir/usr/local/redis
Make Prefix=/usr/local/redis Install
Mkdir/usr/local/redis/etc
mkdir/usr/local/redis/var/
CP redis.conf/usr/local/redis/etc/6379.conf
Note
If you encounter the following error while executing make (such as the author's 32-bit CentOS5.5):
zmalloc.o:in function ' zmalloc_used_memory ':
/home/defonds/redis/redis-2.8.10/src/zmalloc.c:223:undefined reference to ' __sync_add_and_fetch_4 '
Collect2:ld returned 1 exit status
MAKE[1]: * * * [redis-server] Error 1
MAKE[1]: Leaving directory '/HOME/DEFONDS/REDIS/REDIS-2.8.10/SRC '
Make: * * * [ALL] Error 2
Add the parameter cflags= "-march=i686" When you execute make:
Make cflags= "-march=i686"
Iv. Configuring Redis
Make a slight adjustment to the default/usr/local/redis/etc/6379.conf. Note that this configuration disables the auto-save feature, and the i/0 and memory consumption of save and BGSAVE are not negligible, and we allow the app or user to submit their own save.
Daemonize yespidfile/usr/local/redis/var/6379.pidlogfile/usr/local/redis/var/6379.logdatabases 2dbfilename 6379. Rdbdir/usr/local/redis/varappendfsync No
v. Operation and Testing
After installation and configuration, you can start Redis:
Cd/usr/local/redis
Nice-n -10 bin/redis-server etc/6379.conf
At this point, the service should be up and running. We can check these two ways:
ps aux | grep redis
BIN/REDIS-CLI INFO
The second way of printing results:
# BIN/REDIS-CLI INFO
# Server
redis_version:2.8.10
redis_git_sha1:00000000
redis_git_dirty:0
Redis_build_id:d911badb15bd35b1
Redis_mode:standalone
Os:linux 2.6.18-194.el5 i686
Arch_bits:32
Multiplexing_api:epoll
gcc_version:4.1.2
process_id:17537
run_id:0258835fab4aa7235c861a7ff812c197b3674003
tcp_port:6379
Uptime_in_seconds:33
uptime_in_days:0
Hz:10
lru_clock:9976904
Config_file:/usr/local/redis/etc/6379.conf
# clients
Connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:629768
used_memory_human:615.01k
used_memory_rss:1617920
used_memory_peak:629768
used_memory_peak_human:615.01k
used_memory_lua:22528
mem_fragmentation_ratio:2.57
mem_allocator:jemalloc-3.2.0
# persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1402485799
Rdb_last_bgsave_status:ok
Rdb_last_bgsave_time_sec:-1
Rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
Aof_last_rewrite_time_sec:-1
Aof_current_rewrite_time_sec:-1
Aof_last_bgrewrite_status:ok
Aof_last_write_status:ok
# Stats
Total_connections_received:1
total_commands_processed:0
instantaneous_ops_per_sec:0
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
# Replication
Role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:0.01
used_cpu_user:0.00
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
# Keyspace
Finally, the Redis is detected. Redis-benchmark runs a set of REDIS commands and requires only GET and SET to test the host hardware and compilers:
Cd/usr/local/redis/bin
./redis-benchmark-t Get,set
Printing results:
#./redis-benchmark-t Get,set
====== SET ======
10000 requests completed in 0.66 seconds
Parallel clients
3 bytes Payload
Keep Alive:1
30.00% <= 1 milliseconds
61.02% <= 2 milliseconds
92.35% <= 3 milliseconds
99.01% <= 4 milliseconds
99.80% <= 5 milliseconds
100.00% <= 8 milliseconds
15082.96 Requests per second
====== GET ======
10000 requests completed in 0.64 seconds
Parallel clients
3 bytes Payload
Keep Alive:1
31.43% <= 1 milliseconds
63.78% <= 2 milliseconds
94.87% <= 3 milliseconds
98.69% <= 4 milliseconds
99.33% <= 5 milliseconds
99.73% <= 7 milliseconds
99.80% <= 8 milliseconds
99.93% <= 9 milliseconds
100.00% <= 9 milliseconds
15552.10 Requests per second
Of course, you can also add-Q to refine the output:
./redis-benchmark-q-T Get,set
Printing results:
#./redis-benchmark-q-T Get,set
set:14204.55 Requests per second
get:14245.01 Requests per second
References
- Http://redis.io/topics/quickstart
- http://bommaritollc.com/2012/01/building-configuring-and-benchmarking-redis-from-github-source/