Redis安装文档,按照以下步骤即可安装成功。最近要用Redis,翻出了很久以前整理的安装文档,顺便贴到这。
1.下载安装包
redis下载地址:http://download.redis.io/releases/redis-3.0.5.tar.gz
tcl下载地址:http://mirror.centos.org/centos/6/os/x86_64/Packages/tcl-8.5.7-6.el6.x86_64.rpm
2.安装redis
[root@mr205 local]# rpm -ivh tcl-8.5.7-6.el6.x86_64.rpm
[root@mr205 local]# tar -zxvf redis-3.0.5.tar.gz
[root@mr205 local]# cd redis-3.0.5
[root@mr205 redis-3.0.5]# make
…
Hint: To run 'make test' is a good idea ;)
make[1]: Leaving directory `/usr/local/src/redis-3.0.5/src'
[root@mr205 redis-3.0.5]# make test
...
\o/ All tests passed without errors!
Cleanup: may take some time... OK
make[1]: Leaving directory `/usr/local/redis-3.0.5/src'
[root@mr205 redis-3.0.5]# make install
[root@mr205 redis-3.0.5]# cd /usr/local/bin/
[root@mr205 bin]# ll
-rwxr-xr-x 1 root root 4581067 10月 28 15:42 redis-benchmark
-rwxr-xr-x 1 root root 22177 10月 28 15:42 redis-check-aof
-rwxr-xr-x 1 root root 45395 10月 28 15:42 redis-check-dump
-rwxr-xr-x 1 root root 4685226 10月 28 15:42 redis-cli
lrwxrwxrwx 1 root root 12 10月 28 15:42 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 6458557 10月 28 15:42 redis-server
3.编辑redis配置文件
[root@mr205 redis-3.0.5]# cp redis.conf /etc/
[root@mr205 redis-3.0.5]# vim /etc/red
添加:redhat-release redis.conf
[root@mr205 redis-3.0.5]# vim /etc/redis.conf
把里面的
daemonize no 修改成 daemonize yes
4.启动redis服务
[root@mr205 redis-3.0.5]# redis-server /etc/redis.conf
5.测试redis服务:
[root@mr205 redis-3.0.5]# redis-cli
127.0.0.1:6379> set kin kin
OK
127.0.0.1:6379> get kin
"kin"
6.关闭redis服务
[root@mr205 redis-3.0.5]# redis-cli shutdown
7.将redis设为开机启动
[root@mr205 ~]# vim /etc/rc.local
加入 /usr/local/bin/redis-server /etc/redis.conf
8.在其他点安装遇到问题,原来是改点之前已经安装了redis,并且运行了redis
[root@mr203 bin]# redis-server /etc/redis.conf
15826:M 28 Oct 16:28:16.630 * Increased maximum number of open files to 10032 (it was originally set to 1024).
15826:M 28 Oct 16:28:16.631 # Creating Server TCP listening socket *:6379: bind: Address already in use
[root@mr203 bin]# ps -ef | grep redis
root 12705 1 0 16:13 ? 00:00:00 redis-server *:6379
root 16035 11955 0 16:31 pts/0 00:00:00 grep redis
安装twemproxy
[root@mr205 local]# tar -zxvf nutcracker-0.4.0.tar.gz
[root@mr205 local]# cd nutcracker-0.4.0
[root@mr205 nutcracker-0.4.0]# ./configure
[root@mr205 nutcracker-0.4.0]# make && make install
编辑配置文件
[root@mr205 nutcracker-0.4.0]# cd /usr/local/nutcracker-0.4.0/conf
[root@mr205 conf]# cp nutcracker.yml /etc/
[root@mr205 conf]# vim /etc/nutcracker.yml
alpha:
listen: 127.0.0.1:22121
hash: fnv1a_64
distribution: ketama
auto_eject_hosts: true
redis: true
server_retry_timeout: 2000
server_failure_limit: 1
servers: --两台redis服务器的地址和端口
- 172.16.8.204:6379:1
- 172.16.8.205:6379:1
测试配置文件
[root@mr205 nutcracker-0.4.0]# nutcracker -t /etc/nutcracker.yml
nutcracker: configuration file 'conf/nutcracker.yml' syntax is ok
启动twemproxy
[root@mr205 local]# nutcracker --help
This is nutcracker-0.4.0
Usage: nutcracker [-?hVdDt] [-v verbosity level] [-o output file]
[-c conf file] [-s stats port] [-a stats addr]
[-i stats interval] [-p pid file] [-m mbuf size]
Options:
-h, --help : this help
-V, --version : show version and exit
-t, --test-conf : test configuration for syntax errors and exit
-d, --daemonize : run as a daemon
-D, --describe-stats : print stats description and exit
-v, --verbosity=N : set logging level (default: 5, min: 0, max: 11)
-o, --output=S : set logging file (default: stderr)
-c, --conf-file=S : set configuration file (default: conf/nutcracker.yml)
-s, --stats-port=N : set stats monitoring port (default: 22222)
-a, --stats-addr=S : set stats monitoring ip (default: 0.0.0.0)
-i, --stats-interval=N : set stats aggregation interval in msec (default: 30000 msec)
-p, --pid-file=S : set pid file (default: off)
-m, --mbuf-size=N : set size of mbuf chunk in bytes (default: 16384 bytes)
[root@mr205 nutcracker-0.4.0]# nutcracker -d -c /etc/nutcracker.yml
You have mail in /var/spool/mail/root
[root@mr205 nutcracker-0.4.0]# ps -ef|grep nutcracker
root 2717 1 0 16:25 ? 00:00:00 nutcracker -d -c /etc/nutcracker.yml
root 2721 19151 0 16:25 pts/0 00:00:00 grep nutcracker
测试twemproxy:
[root@mr205 local]# redis-cli -p 22121
127.0.0.1:22121> get kin
(nil)
127.0.0.1:22121> set kin king
OK
127.0.0.1:22121> get kin
"king"