A1-Linux下 Redis 服务安装
方式一、yum安装
1、配置yum源
本次所用服务器清空了所有源,重新配置。下载阿里的镜像源与epel源。
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
2、检查安装包
可见,默认环境下安装的是redis-3.2版本,与当前最新稳定版不同。
3、获取安装包
https://pkgs.org/download/redis
这里安装最新稳定版:redis-5.0.7(假装看不到6.0,因为没测试过,其后再补上算了╮(╯▽╰)╭ )
找到链接long下来
4、安装
先装依赖 jemalloc(有了epel源,就自然有了)
yum install -y jemalloc
看得出,就一个包哈
再安装 redis
rpm -ivh redis-5.0.7-1.el7.remi.x86_64.rpm
或
yum install redis-5.0.7-1.el7.remi.x86_64.rpm -y
或
yum localinstall redis-5.0.7-1.el7.remi.x86_64.rpm -y
我用了:yum install redis-5.0.7-1.el7.remi.x86_64.rpm -y。。。随便啦 看 又只下了一个包!亏在rpm包页面说了这么多依赖[○・`Д´・ ○]
5、配置
默认项太多,先就改两处即可
#bind 127.0.0.1:关闭本机访问限制
requirepass 123456:设置密码
sed -i -e "s/bind 127.0.0.1/#bind 127.0.0.1/g" /etc/redis.conf
sed -i -e "s/# requirepass foobared/requirepass 123456/g" /etc/redis.conf
6、启动
systemctl start redis
这里就安装完成了 之后肯定是要搞集群的,得看yum安装与编译安装对之后集群的建设哪个好用些。
方式二、编译安装
这个主要针对于无网环境,更具有建设性(这个挺重要的!)
1、获取安装包
http://download.redis.io/releases/
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
也给它Long下来
2、安装依赖
安装的编译工具:make、gcc
。。。突然发现服务器已经有了(*^▽^*),那就不搞了,之后再单独搞一篇吧
3、解压编译
解压至当前目录
tar xf redis-5.0.7.tar.gz
编译
make
make PREFIX=/usr/local/redis install
应该是安装好了
4、配置
拷贝主配置文件
cp redis.conf /usr/local/redis/
编辑配置文件
daemonize yes:支持后台进程
sed -i -e "s/bind 127.0.0.1/#bind 127.0.0.1/g" /usr/local/redis/redis.conf
sed -i -e "s/# requirepass foobared/requirepass 123456/g" /usr/local/redis/redis.conf
sed -i -e "s/daemonize no/daemonize yes/g" /usr/local/redis/redis.conf
5、启动
cd /usr/local/redis/bin/
./redis-server ../redis.conf
6、检查
好了,两种方式搭建都搞定了o(* ̄) ̄*)o