官网:https://redis.io/
中文网:http://www.redis.cn/
安装:
wget http://download.redis.io/releases/redis-4.0.9.tar.gz
tar -zxvf redis-4.0.9.tar.gz
cd redis-4.0.9
make
make install
然后在/redis-4.0.9/src下可以看到redis提供的一些工具
ll | grep redis-
启动:
1默认启动:redis-server 默认端口6379
2动态参数启动:redis-server --port 6380
3通过配置文件启动:
cd到解压后的redis目录
将默认配置中的注释过滤后写入新配置文件redis-6380.conf中
cat redis.conf | grep -v "#" | grep -v "^$" > redis-6380.conf
redis-server redis-6380.conf
4由于以上启动方式登录窗口关闭后redis即使止,建议用以下方式设置开机启动(建议用此文章中的方式1):
步骤:
切换到redis解压后的目录
[root@iZwz99m0qp1swglw9om6zxZ redis-4.0.9]# pwd
/root/download/redis-4.0.9
vi redis.conf
修改daemonize 后面的no为yes
cd /etc/
mkdir redis
cd redis/
cp /root/download/redis-4.0.9/redis.conf /etc/redis/6379.conf
ls
6379.conf
cp /root/download/redis-4.0.9/utils/redis_init_script /etc/init.d/redis
然后就可以用以下命令了:
打开redis命令:service redis start
关闭redis命令:service redis stop
设为开机启动:chkconfig redis on
设为开机关闭:chkconfig redis off
一般安装好后都是通过127.0.0.1或localhost来访问的,如果想通过外网ip访问,修改6379.conf:
NETWORK下bind 127.0.0.1注释掉,或将bind的ip改为 0.0.0.0
重启redis即可
如果设置密码后停止不了redis:
修改redis服务脚本,加入如下所示的红色授权信息即可:
vi /etc/init.d/redis
$CLIEXEC -a "password" -p $REDISPORT shutdown
客户端连接及测试:
[root@localhost ~]# redis-cli -h 127.0.0.1 -p 6379
[root@localhost ~]# redis-cli(这样和上面的连接一样的效果)
127.0.0.1:6379> ping
PONG
redis密码设置:
打开redis.conf文件,搜索requirepass关键字
设置密码的方法就是去掉注释的#,把foobared替换成自己的密码即可,例如将密码设置为123456:
修改完成后重启redis,再次通过redis客户端redis-cli登录并操作可以发现会报一个身份认证错误:
这就说明我们已经成功的设置了密码,所以通过客户端连接的话必须加上密码参数才能正常连接:
客户端连接时要带上参数:
redis-cli -a 123456
配置参数说明
bind 127.0.0.1 服务器地址
protected-mode yes 是否以守护进程启动
port 6379 端口号
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid 进程号
loglevel notice
logfile "" 日志文件
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./ 工作目录
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
- 相关文章
- windows下使用MongoDB Compass Com
- Oracle VM VirtualBox中设置共享文
- linux安装openvpn并保存密码
- deepin v20深度系统安装docker及do
- 域名在阿里云服务器换成腾讯云后备
- windows下安装VirtualBox增强工具
- 国内访问github慢或打不开的解决方
- linux下安装phpstorm2018及激活码
- vmware中虚拟机上不了网及共享文件
- linux版phpstorm2020.3.3及激活码
- 热门文章
- win7中将文件拷贝到虚拟机linux下
- phpexcel设置行高及列宽,背景颜色,
- rabbitmq无法启动
- intellij idea不显示git push按钮
- php7中使用mongodb的aggregate进行
- laravel页面静态化的方法
- centos7.4 64位下swoole安装及配置
- navicate连接mycat报1184错误
- curl设置超时不起作用(CURLOPT_TIM
- devops-jenkins容器为pending状态
- 好评文章
- phpexcel设置行高及列宽,背景颜色,
- php7中使用mongodb的aggregate进行
- intellij idea打开文件所在文件夹
- windows下使用MongoDB Compass Com
- win7中将文件拷贝到虚拟机linux下
- laravel 中悲观锁 & 乐观锁的使用
- 单点登录sso原理及php实现方式及de
- navicate连接mycat报1184错误
- rabbitmq无法启动
- laravel整合dingo/api方法步骤:jwt
- 我的项目
- 【github】www.github.com/hurong241
- 【码云】gitee.com/hu_rong/projects
- 【docker hub】hub.docker.com/repositories/hurong241
- 【packagist】packagist.org/users/hurong241/packages
- 站点信息
- 建站时间:2011年
- 文章数:623篇
- 浏览数:1303109