linux之centos安装redis
linux之centos安装redis # 首先看一下c语言有没有安装 gcc -v # 如果没有安装 yum install -y gcc # 创建并进入一个目录 专门下载软件的目录 mkdir /software cd /software # 下载 wget http://download.redis.io/releases/redis-5.0.3.tar.gz # 解压 tar -zxvf redis-5.0.3.tar.gz # 进入目录 cd redis-5.0.3 # 编译 make # 指定安装目录 make install PREFIX=/usr/local/redis # 设置后台启动 cp /software/redis-5.0.3/redis.conf /usr/local/redis/bin/ # 修改redis.conf配置文件 把 daemonize no 改为 daemonize yes vim redis.conf # 后台启动 cd /usr/local/redis/bin/ ./redis-server redis.conf ######设置为开机自启#### vi /etc/systemd/system/redis.service 复制代码 [Unit] Description=redis-server After=network.target [Service] Type=forking ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf PrivateTmp=true [Install] WantedBy=multi-user.target 复制代码 注意:ExecStart配置成自己的路径 # 设置开机自启 systemctl daemon-reload systemctl start redis.service systemctl enable redis.service # 创建redis命令的软连接 ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis # redis命令操作 systemctl start redis.service #启动redis服务 systemctl stop redis.service #停止redis服务 systemctl restart redis.service #重新启动服务 systemctl status redis.service #查看服务当前状态 systemctl enable redis.service #设置开机自启动 systemctl disable redis.service #停止开机自启动
-----------------------------------------------------------------------------------------------------------------------------------------