码迷,mamicode.com
首页 > 其他好文 > 详细

centos6 redis3.2.8 安装记录

时间:2017-05-20 01:15:34      阅读:326      评论:0      收藏:0      [点我收藏+]

标签:lower   ons   命令行   auth   redis主从   ted   core   文件   figure   

安装:
/**
yum install gcc gcc-c++ pcre* openssl* gd-devel* zlib-devel pcre-devel libxml2-devel curl-devel

**

下载安装文件
wget http://download.redis.io/releases/redis-3.2.8.tar.gztar -zxvf redis-3.2.8.tar.gz 

cd redis-3.2.8
make
ls /usr/local/
cd src/
cd ../
cd utils/
cat INSTALL
make PREFIX=/usr/local/redis install
ls /usr/local/redis/bin/
mkdir /usr/local/redis/conf
cp redis.conf /usr/local/redis/conf/
cd utils/
cat install_server.sh
telnet
tree /usr/local/redis/

 


配置并启动redis服务

echo ‘PATH=/usr/local/redis/bin/:$PATH‘ >> /etc/profile
tail -1 /etc/profile
. /etc/profile

which redis-server

redis-server -h

启动:
redis-server /usr/local/redis/conf/redis.conf &


启动时出现警告:

26221:M 22 Mar 04:38:06.362 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
26221:M 22 Mar 04:38:06.362 # Server started, Redis version 3.2.8
26221:M 22 Mar 04:38:06.365

echo ‘511‘ > /proc/sys/net/core/somaxconn

 

# WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1‘ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1‘ for this to take effect.
26221:M 22 Mar 04:38:06.365


# 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.
26221:M 22 Mar 04:38:06.365 * The server is now ready to accept connections on port 6379

 


yum -y install lsof

lsof -i :6379

sysctl vm.overcommit_memory=1

vim /etc/sysctl.conf
最后一行加上:vm.overcommit_memory = 1

sysctl -p


关闭redis 服务

redis-cli shutdown save

 


用nc 命令在linux也可以操作redis:
echo ‘set name lisi‘ | nc 127.0.0.1 6379


设置密码:

配置文件:requirepass 123456

重启redis

redis-cli -a 135456 登录进去
或在redis-cli 命令行 auth 123456

配置文件可以改名或禁用危险命令:
rename-command 原命令 新命令
rename-command set ‘‘ 禁用所有命令


php 安装phpredis扩展

/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make && make install

提示扩展安装到了 /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/

php.ini:
extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/redis.so

 

netstat -lntup |grep 6379

 

配置主从:

slave:
slaveof 192.168.1.199 6379 (支持域名)
masterauth 123456

slave-serve-stale-data yes


打开master

开启slave 就开始同步了

/****
在Docker容器中配置Redis主从关系是遇到slave redis节点启动时报

Error condition on socket for SYNC: Connection refused
解决方法

修改redis master节点配置文件

bind 0.0.0.0
重启服务

**/


slave : redis-cli命令行 : monitor 监控

slave 不能写数据

 

centos6 redis3.2.8 安装记录

标签:lower   ons   命令行   auth   redis主从   ted   core   文件   figure   

原文地址:http://www.cnblogs.com/shijiu520/p/6880678.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!