1 上传redis安装包,并解压
[root@centos local]# ls
bin etc games include lib lib64 libexec redis-3.2.1.tar.gz sbin share src
[root@centos local]# tar xf redis-3.2.1.tar.gz
2 使用make安装
[root@centos local]# cd redis-3.2.1
[root@centos redis-3.2.1]# make
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory `/usr/local/redis-3.2.1/src'
出现如上表示正确安装
3 安装检查
[root@centos redis-3.2.1] make test
\o/ All tests passed without errors!
Cleanup: may take some time... OK
4 环境变量中加入redis
[root@centos src]# vim /etc/profile
export PATH="$PATH:/usr/local/redis/src"
[root@centos src]# source /etc/profile
5 直接使用redis-server命令出现如下警告
[root@centos src]# redis-server
8114:C 16 Jul 07:28:49.983 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
8114:M 16 Jul 07:28:49.986 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.1 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 8114
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
8114:M 16 Jul 07:28:49.990 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
8114:M 16 Jul 07:28:49.990 # Server started, Redis version 3.2.1
8114:M 16 Jul 07:28:49.990 # 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, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
8114:M 16 Jul 07:28:49.990 * DB loaded from disk: 0.000 seconds
8114:M 16 Jul 07:28:49.990 * The server is now ready to accept connections on port 6379
6 解决方式如下
[root@centos src]# echo 511 > /proc/sys/net/core/somaxconn
[root@centos src]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@centos src]# vim /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
7 将redis.conf拷贝到/etc/下
[root@centos redis-3.2.1]# cp /usr/local/redis-3.2.1/redis.conf /etc/redis.conf
8 修改redis.conf配置文件
daemonize no -> daemonize yes
bind 127.0.0.1 -> bind 127.0.0.1 192.168.8.205
9 使用/etc/redis.conf进行启动redis
[root@centos redis-3.2.1]# redis-server /etc/redis.conf
10 设置redis访问密码
[root@centos redis-3.2.1]# redis-cli
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) ""
127.0.0.1:6379> CONFIG set requirepass "redis"
OK
127.0.0.1:6379> CONFIG get requirepass
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth redis
OK
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "redis"
11 远程登录方式
[root@centos redis-3.2.1]# redis-cli -h 192.168.8.205 -p 6379
192.168.8.205:6379>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29812844/viewspace-2122387/ ,如需转载,请注明出处,否则将追究法律责任。