mysql的redis安装以及远程登录配置

3 Redis 安装配置及运用
3.1 redis安装

[root@ser1 ~]# wget http://download.redis.io/releases/redis-5.0.4.tar.gz
[root@ser02 redis-5.0.4]# make
[root@localhost conf]# mkdir -p /data/redis
[root@ser02 redis-5.0.4]# make PREFIX=/data/redis install
[root@ser02 redis]# mkdir /data/redis/conf
[root@ser02 redis]# cd /opt/redis-5.0.4/
[root@ser02 redis-5.0.4]# cp -p redis.conf /data/redis/conf/

3.2 生成的指令

[root@ser02 redis-5.0.4]# cd /data/redis/bin/
[root@ser02 bin]# ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel
redis-server

3.3 启动

[root@ser02 bin]# /data/redis/bin/redis-server /data/redis/conf/redis.conf

查看进程

# ps -ef |grep redis
root 6236 1687 0 22:25 pts/1 00:00:00 /data/redis/bin/redis-server
[root@ser02 ~]# netstat -alpn |grep 6236
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN

3.4 调优
在启动时会出现一些警告,

[root@localhost conf]# 29409:C 28 Jul 2019 09:34:41.541 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
29409:C 28 Jul 2019 09:34:41.541 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=29409, just started
29409:C 28 Jul 2019 09:34:41.541 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 29409
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

29409:M 28 Jul 2019 09:34:41.543 # Server initialized
29409:M 28 Jul 2019 09:34:41.543 # 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.
29409:M 28 Jul 2019 09:34:41.543 * Ready to accept connections

所以我们执行以下命令 :

[root@ser02 ~]# cat /proc/sys/net/core/somaxconn
128
[root@ser02 ~]# echo 1024 > /proc/sys/net/core/somaxconn
[root@ser02 ~]# echo 1 > /proc/sys/vm/overcommit_memory
#overcommit_memory 1 容许过量使用内存 《= 物理内存 + swap 8G+2G ==10G
#12G内存 linux内存 oom内存泄漏 oom_kill
[root@ser02 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
[root@ser02 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
[root@ser02 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

然后再启动就会没警告(warning)

[root@localhost ~]# /data/redis/bin/redis-server /data/redis/conf/redis.conf
29625:C 28 Jul 2019 09:49:47.850 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
29625:C 28 Jul 2019 09:49:47.850 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=29625, just started
29625:C 28 Jul 2019 09:49:47.850 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.4 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 29625
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

29625:M 28 Jul 2019 09:49:47.853 # Server initialized
29625:M 28 Jul 2019 09:49:47.853 * DB loaded from disk: 0.000 seconds
29625:M 28 Jul 2019 09:49:47.853 * Ready to accept connections

测试本地连接是可以的,虽说有几个不能执行的东西,主要是127.0.0.1的出现

[root@localhost redis]# /data/redis/bin/redis-cli
127.0.0.1:6379> AUTH 123456
(error) ERR Client sent AUTH, but no password is set

然后远程连接:

修改安装目录的文件、/data/redis/conf/redis.conf

1.这个原本是127.0.0.1
bind 192.168.140.106

2.这个原本被注释了,后面数字是密码,如果是要免密码可以继续注释掉不用管
requirepass 123456

改好后保存退出,重启redis

找另一个安装redis的主机:

[root@localhost bin]# ./redis-cli -h 192.168.140.106 -p 6379 -a 123456

[root@localhost bin]# ./redis-cli -h 192.168.140.106 -p 6379 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.140.106:6379> set var "sadv"
OK
192.168.140.106:6379> get AUTH
(nil)
192.168.140.106:6379> 


这样redis的本地和远程就安装测试好了!
遇到的纠结:忘记修改配置文件中的bind 127.0.0.1为bind192.168.140.106导致不能远程

————下节内容是redis集群配置~~~~

                                                                                         QQ:2525226830
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值