更改yum源
將Centos的yum源更換為國內(nèi)的阿里云源
備份你的原鏡像文件括丁,保證出錯(cuò)后可以恢復(fù):
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下載新的CentOS-Base.repo
到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
安裝redis
yum install redis
啟動(dòng)redis
systemctl start redis.service
設(shè)置redis開機(jī)啟動(dòng)
systemctl enable redis.service
高級(jí)設(shè)置
設(shè)置redis密碼
打開文件/etc/redis.conf
骨望,找到其中的# requirepass foobared
勉躺,去掉前面的#
傻寂,并把foobared
改成你的密碼哪怔。
redis.conf
文件默認(rèn)在/etc
目錄下旺订,你可以更改它的位置和名字援制,更改后决瞳,注意在文件/usr/lib/systemd/system/redis.service
中货徙,把ExecStart=/usr/bin/redis-server /etc/redis/6379.conf --daemonize no
中的redis.conf
的路徑改成的新的路徑。