1、安裝redis:
上傳檔案到固定目錄下;版本為: redis-3.2.0
tar xzvf redis-3.2.0.tar.gzcd redis-3.2.0make && make install
2、啟動redis
redis-server redis.conf
3、一般不會在原設定檔上進行修改,原設定檔相當於備份。所以在centos7上建立
mkdir /etc/redis
4、拷貝redis原設定檔到 /etc/redis
cp redis.conf /etc/redis/
按照最新的設定檔啟動:
redis-server /etc/redis/redis.conf
啟動後如果直接關閉命令列視窗,redis會在後台運行,但是不能按ctrl+c,如果按這個會終止redis,所以直接關掉視窗即可
[root@localhost ~]# ps -ef |grep redisroot 30337 1 0 09:10 ? 00:00:00 redis-server 127.0.0.1:6379root 32116 28120 0 09:18 pts/1 00:00:00 grep --color=auto redis
以上redis就啟動了。
5、啟動後,如何關閉redis。
redis-cli shutdown[root@localhost ~]# redis-cli shutdown[root@localhost ~]# ps -ef |grep redisroot 32257 28120 0 09:19 pts/1 00:00:00 grep --color=auto redis
執行後redis就關閉了。
6、redis添加後台啟動
daemonize yes
7、配置redis記錄檔位置:
logfile "/Users/wang/Documents/redis.log"
7、添加到
開機啟動配置
echo "/usr/local/bin/redis-server /etc/redis/redis.conf &" >> /etc/rc.local
8、添加密碼
vi /etc/redis/redis.confrequire pass paas2016
添加密碼paas2016
redis是預設不允許其他用戶端串連的:
需要在設定檔中放開: bind 127.0.0.1 才能允許其他用戶端操作
用戶端串連:
ss:~ wqp$ redis-cli -h hostname -p 6379 -a paas2016hostname:6379> set aa "aaaa"OKhostname:6379> get aa"aaaa"