redis学习1
1、linux下安装redis
打算安装在 /usr/local/soft/redis
安装包放到 /usr/local/src
配置文件复制到 /usr/local/soft/redis/bin
1、创建目录
mkdir /usr/local/soft/redis
2、进入安装目录
cd /usr/local/src
3、下载安装包
wget https://download.redis.io/releases/redis-7.0.0.tar.gz
4、 解压源码包
tar xf redis-7.0.0.tar.gz
5、进入解压后目录
cd redis-7.0.0
6、安装到指定目录中
make PREFIX=/usr/local/soft/redis install
7、将配置文件拷贝到指定目录的bin目录下
cp redis.conf /usr/local/soft/redis/bin/
8.、人工启动
cd /usr/local/soft/redis/bin
./redis-server /usr/local/soft/redis/bin/redis.conf
9、构建多实例服务启动
配置redis环境变量
vim /etc/profile
··· 开始编译
export REDIS_HOME=/usr/local/soft/redis
export PATH=$PATH:$REDIS_HOME/bin
··· 保存退出
source /etc/profile
echo $PATH
进入目录
cd /usr/local/src/redis-7.0.0/utils
ls
安装实例
./install_server.sh
安装报错
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!
解决办法
vi ./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
重新运行
./install_server.sh
多个实例设置多个端口号
启动后通过多次修改端口号来启动不同的实例
第一个实例:默认端口号为 6379
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CTbee0sQ-1661727134388)(assets/1661671426720.png)]
查看状态
开机启动目录:/etc/init.d
cd /etc/init.d
ls
service redis_6379 status
创建第二个实例端口号为: 6380
cd /usr/local/src/redis-7.0.0/utils
ls
./install_server.sh
输入6380一直回车
查看服务状态
cd /etc/init.d
ls
service redis_6380 status
服务安装完毕后,可以使用服务命令操作redis
service redis_6379 start/stop/status
ps -fe | grep redis