redis部署记录一
部署环境:centos7.2
1.上传部署包并解压
tar -zxvf redis-4.0.1.tar.gz -C /home/
cd /home && mv redis-4.0.1 redis
cd /home/redis && mkdir conf log run
mv redis.conf conf/
2.配置修改
vim /home/redis/conf/redis.conf修改如下地方配置
bind 0.0.0.0#注意这里是修改原来的bind 127.0.0.1,不可以直接添加这一行内容会出问题,导致配置的内容无效
pidfile /home/redis/run/redis_6379.pid
logfile /home/redis/log/6379.log
requirepass wallet0925 #密码设置为wallet0925
rename-command CONFIG "RENAME_CONFIG"
rename-command FLUSHALL ""
rename-command FLUSHDB ""
daemonize yes #这里是设置为yes 以守护进程启动;表明需要在后台运行
3.编译并安装
cd /home/redis && make -j4 && make test 编译并测试
cd /home/redis && make install 安装 正常结果如下
Hint: It's a good idea to run 'make test' 😉
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
4.启动配置
cd /home/redis/src && mv mkreleasdhdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server /home/redis/bin/
启动脚本:
cd /home/redis;vim start.sh
bin/redis-server /home/redis/conf/redis.conf &
5.测试
cd /home/redis/bin && ./redis-cli -h 192.168.1.5 -p 6379
auth wallet0925
6.添加环境变量并生效
在/etc/profile最后一行添加如下内容
export PATH="$PATH:/home/redis/bin"
让其生效source /etc/profile
7.内核参数配置
配置下面的内核参数,否则Redis脚本在重启或停止redis时,将会报错,并且不能自动在停止服务前同步数据到磁盘上/etc/sysctl.conf加上
vim /etc/sysctl.conf
vm.overcommit_memory = 1
生效sysctl -p