共计 1980 个字符,预计需要花费 5 分钟才能阅读完成。
一、筹备工作
- 下载
redis
安装包, 放到root
目录外面下载地址 -
在 /usr/local/ 下创立 redis ⽂件夹并进⼊
cd /usr/local/ mkdir redis cd redis
-
将
redis
安装包解压到/usr/local/redis
tar -zxvf /root/redis-6.2.5.tar.gz -C ./
解压完之后,
/usr/local/redis
⽬录中会呈现⼀个redis-6.2.5
的⽬录
二、编译装置
-
编译并装置
cd redis-6.2.5 make && make install
三、将 redis 服务装置零碎服务并后盾启动
-
进⼊
utils
⽬录,并执⾏上面命令cd utils/ ./install_server.sh
这步可能会报错
Welcome to the redis service installer This script will help you easily set up a running redis server This systems seems to use systemd. Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
正文上面的代码
vim install_server.sh
76 行 #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 #unset _pid_1_exe
-
查看 redis 服务启动状况
systemctl status redis_6379.service
看状态是不是
Active: active (running)
, 如果状态是Active: active (exited)
● redis_6379.service - LSB: start and stop redis_6379 Loaded: loaded (/etc/rc.d/init.d/redis_6379; bad; vendor preset: disabled) Active: active (exited) since 二 2021-09-14 16:46:05 CST; 8min ago Docs: man:systemd-sysv-generator(8) Process: 8528 ExecStart=/etc/rc.d/init.d/redis_6379 start (code=exited, status=0/SUCCESS) 9 月 14 16:46:05 localhost.localdomain systemd[1]: Starting LSB: start and stop redis_6379... 9 月 14 16:46:05 localhost.localdomain redis_6379[8528]: /var/run/redis_6379.pid exists, process is al...ed 9 月 14 16:46:05 localhost.localdomain systemd[1]: Started LSB: start and stop redis_6379. Hint: Some lines were ellipsized, use -l to show in full.
Active: active (exited)
状态 删除 pid 文件cd /var/run rm redis_6379.pid
Active: active (exited)
状态 删除 dump.rdb(内存快照)文件cd /var/lib/redis/6379 mv dump.rdb dump.rdb_bak
Active: active (exited)
状态ps -ef |grep redis kill -9 过程 id(如果有) systemctl start redis
-
设置容许近程连贯, 编辑
redis
配置⽂件vim /etc/redis/6379.conf
将
bind 127.0.0.1
批改为0.0.0.0
bind 0.0.0.0 systemctl restart redis_6379.service
-
设置拜访明码
vim /etc/redis/6379.conf
找到
#requirepass foobared
去掉正文,批改 foobared 为⾃⼰想要的明码,保留即可。requirepass admin
保留,重启 Redis 服务即可
systemctl restart redis_6379.service
正文完