学校网站 cms,会计网站建设意义,网站开发课程介绍,seo网站设计营销工具一、Linux环境
1、下载
官网提供的源码下载地址#xff1a; https://github.com/redis/redis/archive/7.0.5.tar.gz 2、将源码上传至服务器 3、解压缩
# 将解压缩后的文件放置在同目录的source文件夹下
tar -zxvf redis-7.0.5.tar.gz -C ./source4、编译安装
对源码进行编…一、Linux环境
1、下载
官网提供的源码下载地址 https://github.com/redis/redis/archive/7.0.5.tar.gz 2、将源码上传至服务器 3、解压缩
# 将解压缩后的文件放置在同目录的source文件夹下
tar -zxvf redis-7.0.5.tar.gz -C ./source4、编译安装
对源码进行编译、安装
# PREFIX参数表示安装在哪个目录下
make PREFIX/home/ubuntu/redis/redis-7.0.5 install5、复制配置文件
# 将源码提供的配置文件复制到安装目录下
cp /home/ubuntu/redis/source/redis-7.0.5/redis.conf /home/ubuntu/redis/redis-7.0.5/bin/6、启动redis
# 启动redis时需要指定配置文件
./redis-server /home/ubuntu/redis/redis-7.0.5/bin/redis.conf7、修改配置文件
# 将下面一行配置添加注释使其他主机可以访问redis服务
# bind 127.0.0.1 -::1# 将以下配置取消注释修改密码
requirepass ********
# 下面配置必须打开密码才能生效
protected-mode yes# 修改日志文件
logfile /home/ubuntu/redis/redis.7.0.5/bin/redis.log8、设置服务 # 将源码文件中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创建服务脚本 vim install_server_command.sh sudo REDIS_PORT6379 \REDIS_CONFIG_FILE/home/ubuntu/redis/redis-7.0.5/bin/redis.conf \REDIS_LOG_FILE/home/ubuntu/redis/redis.7.0.5/bin/redis.log \REDIS_DATA_DIR/home/ubuntu/redis/redis.7.0.5/bin/ \REDIS_EXECUTABLEcommand -v /home/ubuntu/redis/redis-7.0.5/bin/redis-server \/home/ubuntu/redis/source/redis-7.0.5/utils/install_server.sh创建服务文件 cd /lib/systemd/systemsudo touch redis.servicesudo chmod 644 redis.servicesudo vim redis.service [Unit]
DescriptionRedis
Afternetwork.target[Service]
ExecStart/home/ubuntu/redis/redis-7.0.5/bin/redis-server /home/ubuntu/redis/redis-7.0.5/bin/redis.conf --daemonize no
ExecStop/home/ubuntu/redis/redis-7.0.5/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown[Install]
WantedBymulti-user.target创建软链接为服务自启动准备
ln -s /lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service刷新配置
systemctl daemon-reload杀死已存在的redis进程
ps aux|grep redis
kill -9 [pid]启动redis
systemctl start redis