[root@bogon ~]# cd /usr/local/
[root@bogonlocal]# wget http://download.redis.io/releases/redis-3.0.0.tar.gz
[root@bogonlocal]# ls
bin games lib libexec redis-3.0.0.tar.gz.1 share
etc include lib64 redis-3.0.0.tar.gz sbin src
进入local文件夹再下载是为了将文件下载到local文件夹
3、解压文件夹
[root@bogonlocal]# tar zxf redis-3.0.0.tar.gz
[root@bogonlocal]# ls
bin games lib libexec redis-3.0.0.tar.gz share wget-log
etc include lib64 redis-3.0.0 sbin src
4、将文件安装到指定文件夹
[root@bogon redis-3.0.0]# cd ..
[root@bogonlocal]# cd redis-3.0.0/
[root@bogon redis-3.0.0]# make PREFIX=/usr/local/redis install
说明:
make PREFIX=/usr/local/redis install :是为了将文件安装到/usr/local/redis 中
/usr/local/redis-3.0.0:是redis的源码文件夹
/usr/local/redis:是redis的安装文件夹
5、拷贝配置文件
将源码文件夹中的redis配置文件复制到安装目录
[root@localhost redis-3.0.0]# cd ..
[root@localhostlocal]# cd redis
[root@bogon redis]# mkdir conf
[root@bogon redis]# cp /usr/local/redis-3.0.0/redis.conf /usr/local/redis/bin/
[root@bogon redis]# ls
bin conf
6、前端启动redis
[root@bogon redis]# cd bin
[root@bogon bin]# ls
redis-benchmark redis-check-dump redis.conf redis-server
redis-check-aof redis-cli redis-sentinel
[root@localhost bin]# ./redis-server
4657:C 09 Jul 22:51:15.379 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
4657:M 09 Jul 22:51:15.379 * Increased maximum number of open files to 10032 (it was originally setto1024).
_._
_.-``__ ''-._
_.-```. `_. ''-._ Redis 3.0.0 (00000000/0) 64bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 4657
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'4657:M 09 Jul 22:51:15.416 # Server started, Redis version 3.0.04657:M 09 Jul 22:51:15.416 # WARNING overcommit_memory issetto0! Background save may fail under low memory condition. To fix this issue add'vm.overcommit_memory = 1'to /etc/sysctl.conf andthen reboot or run the command 'sysctl vm.overcommit_memory=1'for this to take effect.
4657:M 09 Jul 22:51:15.416 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled'as root, andadd it to your /etc/rc.localinorderto retain the setting after a reboot. Redis must be restarted after THP is disabled.
4657:M 09 Jul 22:51:15.416 # WARNING: The TCP backlog setting of511 cannot be enforced because /proc/sys/net/core/somaxconn issetto the lower valueof128.4657:M 09 Jul 22:51:15.416 * The server is now ready to accept connections on port 6379
说明:
./redis-server :前端方式启动redis
./redis-sentinel:启动哨兵,但不是启动redis,容易被弄错
./redis-cli:连接redis数据库命令
7、配置后端启动
修改配置文件:redis.conf
文件地址:/usr/local/redis/bin/redis.conf
[root@localhost bin]# vim redis.conf
修改内容:
将后台启动配置设置为yes即可
# Bydefault Redis does not run as a daemon. Use 'yes'if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes