redis:https://redis.io/download
本文提供两个版本5.0.3和6.2.3安装示例
安装(6.2.3)
# 下载
[root@localhost local]# wget https://download.redis.io/releases/redis-6.2.3.tar.gz
# 解压
[root@localhost local]# tar -xzvf redis-6.2.3.tar.gz
[root@localhost local]# mv redis-6.2.3 redis
# 安装
[root@localhost local]# cd redis
[root@localhost redis]# make
# 运行
[root@localhost redis]# src/redis-server
# 配置环境变量
[root@localhost redis]# vim /etc/profile
export REDIS_HOME=/usr/local/redis
export PATH=$REDIS_HOME/src:$PATH
# 注册服务
[root@localhost redis]# utils/install_server.sh
# 如果出现下列错误
This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
[root@localhost utils]# utils/install_server.sh
注释下面的代码
#bail if this system is managed by systemd
#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
# echo "This systems seems to use systemd."
# echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
# exit 1
#fi
[root@localhost redis]# utils/install_server.sh
下列为配置信息
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [] /usr/local/redis/src/redis-server
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/redis/src/redis-server
Cli Executable : /usr/local/redis/src/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
# 运行
[root@localhost utils]# systemctl start redis_6379
# 停止
[root@localhost utils]# systemctl stop redis_6379
# 重新启动
[root@localhost redis]# systemctl restart redis_6379
安装(5.0.3)
下载
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
安装
# 解压
tar xzf redis-5.0.3.tar.gz
cd redis-5.0.3
make
# 创建文件夹
mkdir /usr/local/redis/conf
mkdir /usr/local/redis/data
mkdir /usr/local/redis/logs
# run
src/redis-server
# warning 1 > 提示修改 linux内核参数
# WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
echo 1024 >/proc/sys/net/core/somaxconn
# warn 2 > 提示如下
# 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.
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1
# warning 3
# 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
echo never > /sys/kernel/mm/transparent_hugepage/enabled
# 云服务器要注意ip要写对,端口要开放
# 虚拟机要注意防火墙要关闭 systemctl stop firewalld.service
- 编译的几种方式
- 强制使用 libc malloc 的编译
- % make MALLOC=libc 或者 make USE_JEMALLOC=no
- 使用 jemalloc 编译
- % make 或 MALLOC=jemalloc 或者 make USE_JEMALLOC=yes
- 使用 tcmalloc 编译
- % make MALLOC=tcmalloc 或者 make USE_JEMALLOC=yes
- 运行 redis-server redis.conf
- 清除编译方法
- make distclean
- centos 环境英文切换
- export LC_ALL=en_US.UTF-8
- export LANGUAGE=en_US.UTF-8
- export LANG=en_US.UTF-8
网友评论