1.安装gcc tcl
sudo yum -y install gcc tcl
2. 解压redis包,解压后的目录如下:
3. 到deps目录下编译 jemalloc,lua,linenoise,hiredis
make jemalloc lua linenoise hiredis
4.到redis的根目录下执行make
5.安装到指定位置:
make PREFIX=/opt/cdh5.15.0/redis install
6. redis目录:
7.设置环境变量:
export REDIS_HOME=/opt/cdh5.15.0/redis
export PATH=$PATH:$REDIS_HOME/bin
别忘了还要:
source /etc/profile
8. 将redis改为service:
切换为root用户,到目录/opt/cdh5.15.0/redis-2.8.18/utils目录下:
执行:
./install_server.sh
[root@slave2 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 [/opt/cdh5.15.0/redis/bin/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 : /opt/cdh5.15.0/redis/bin/redis-server
Cli Executable : /opt/cdh5.15.0/redis/bin/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!
9.进入/etc/init.d目录下:
[root@slave2 utils]# cd /etc/init.d/
[root@slave2 init.d]# ll
total 44
-rw-r--r--. 1 root root 17500 May 3 2017 functions
-rwxr-xr-x. 1 root root 4334 May 3 2017 netconsole
-rwxr-xr-x. 1 root root 7293 May 3 2017 network
-rw-r--r--. 1 root root 1160 Aug 5 2017 README
-rwxr-xr-x 1 root root 1698 Nov 3 16:47 redis_6379
将redis_6379改为redisd
设置开机启动服务:
systemctl enable redisd
启动并查看:
[root@slave2 init.d]# chkconfig redisd
[root@slave2 init.d]# service redisd start
/var/run/redis_6379.pid exists, process is already running or crashed
You have new mail in /var/spool/mail/root
[root@slave2 init.d]# ss -tanl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:6379 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::6379 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
10.启动client:
[root@slave2 init.d]# redis-cli
127.0.0.1:6379>