Redis安装及编译报错处理
一、Redis安装
cd /usr/local/soft
wget http://download.redis.io/releases/redis-7.0.0.tar.gz
tar -zxvf redis-7.0.0.tar.gz
cd redis-7.0.0
make test
make PREFIX=/usr/local/tools/redis-7.0.0 install
这里多了一个关键字 PREFIX= 这个关键字的作用是编译的时候用于指定程序存放的路径。比如我们现在就是指定了redis必须存放在/usr/local/redis目录。假设不添加该关键字Linux会将可执行文件存放在/usr/local/bin目录,
库文件会存放在/usr/local/lib目录。配置文件会存放在/usr/local/etc目录。其他的资源文件会存放在usr/local/share目录。这里指定号目录也方便后续的卸载,后续直接rm -rf /usr/local/redis 即可删除redis。
mkdir /usr/local/tools/redis-7.0.0/conf
cd /usr/local/soft/redis-7.0.0/
cp redis.conf /usr/local/tools/redis-7.0.0/conf/
vi /lib/systemd/system/redis7.service
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/tools/redis-7.0.0/bin/redis-server /usr/local/tools/redis-7.0.0/conf/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start redis7
systemctl stop redis7
二、编译时错误
You need tcl 8.5 or newer in order to run the Redis test.
安装Redis,运行make test的时候出错:
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
安装tcl就行了:
复制代码
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
sudo tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
sudo ./configure
sudo make
sudo make install