1 . 下载Redis 使用wget下载,命令如下:
$ wget http://download.redis.io/releases/redis-3.0.4.tar.gz
- 1
2 . 解压Redis
下载完成后,使用tar命令解压下载文件:
$ tar -xzvf redis-3.0.4.tar.gz
- 1
3 . 编译安装Redis
切换至程序目录,并执行make命令编译:
$ cd redis-3.0.4
$ make
- 1
- 2
4.安装
切换至redis的src目录
$cd src
$ cp redis-server redis-cli /usr/local/bin
$cp redis-sentinel redis-benchmark redis-check-aof redis-check-dump /usr/local/bin
- 1
- 2
- 3
创建配置目录
$mkdir /etc/redis
$mkdir -p /var/lib/redis/6379
$cp redis.conf /etc/redis/6379.conf
$vi /etc/redis/6379.conf
- 1
- 2
- 3
- 4
修改6379.conf中的内容
daemonize yes
pidfile /var/run/redis_6379.pid
port 6379
oglevel notice
dir /var/lib/redis/6379
- 1
- 2
- 3
- 4
- 5
5.创建服务
$sysctl -w vm.overcommit_memory=1
$sysctl -w net.core.somaxconn=512.
$echo never > /sys/kernel/mm/transparent_hugepage/enabled
$cp utils/redis_init_script /etc/init.d/redis_6379
$vi /etc/systemd/system/redis.service
- 1
- 2
- 3
- 4
- 5
redis.service的内容
[Unit]
Description=Redis on port 6379
[Service]
Type=forking
ExecStart=/etc/init.d/redis_6379 start
ExecStop=/etc/init.d/redis_6379 stop
[Install]
WantedBy=multi-user.target
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
6.服务更新
$systemctl enable redis
#务必要进行reload
$systemctl daemon-reload
#在centos7下可用service命令启动
$service redis start
#查看服务状态
$service redis status
#在低于centos7版本下用systemctl
$systemctl start redis
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9