虚拟机安装CENTOS的步骤略过。
1.配置网络
# 关闭防火强
systemctl stop firewalld
# 安装 epel
yum install epel-release
# 安装常用工具
yum install wget net-tools telnet tree nmap sysstat lrzsz dos2unix bind-utils nc -y
# 修改网络配置文件
vi /etc/sysconfig/network-scripts/ifcfg-ens33
ifcfg-ens33配置文件内容如下
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=2d30e58d-0954-4959-b44f-04c0c0beac65
DEVICE=ens33
ONBOOT=yes
# GATEWAY和IPADDR自己设置就可以,格式正常就行
GATEWAY=10.4.7.1
IPADDR=10.4.7.189
NETMASK=255.255.252.0
# DNS要设置的与网络中的DNS的一致
DNS1=10.2.3.20
查看DNS方式
2.安装GCC
sudo yum group install "Development Tools"
3.下载redis编译
mkdir -p /usr/redis
cd /usr/redis
wget http://download.redis.io/releases/redis-3.2.9.tar.gz
tar -vxzf redis-3.2.9.tar.gz
ln -s redis-3.2.9 redis
cd redis
# 直接make会报错误, zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录
# 加 MALLOC=libc 参数可以正常编译
make MALLOC=libc
# 将运行文件安装到 /usr/local/bin 下,可以在任意目录下执行redis命令
make install
安装好以后,可以测试启动redis服务
[root@localhost redis]# redis-server
33024:C 23 Sep 10:45:37.530 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
33024:M 23 Sep 10:45:37.531 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 33024
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
33024:M 23 Sep 10:45:37.531 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
33024:M 23 Sep 10:45:37.531 # Server started, Redis version 3.2.9
33024:M 23 Sep 10:45:37.531 # 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.
33024:M 23 Sep 10:45:37.531 # 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.
33024:M 23 Sep 10:45:37.531 * The server is now ready to accept connections on port 6379