安装环境(redis3.0以上才支持集群部署)linux
1.服务器环境:linux Centos release 6.8redis
2.Redis版本(2.8.13)下载地址:http://download.redis.io/releases/mongodb
3.预装软件(gcc、tcl)服务器
(两部分 Redis Server和Redis Cli)spa
服务器安装使用rest
tar -xf redis-2.8.13.tar.gz cd redis-2.8.13 make sudo make install
安装路径:/usr/local/bin/redis-server/code
启动 (启动每每后面要加一个配置文件redis.conf)server
这个配置文件的原型 在编译后的文件夹能够找到(能够拷贝到home的目录下)修改一下后台启动daemonize yes和端口blog
启动:./redis-server /home/redis.confip
查看是否启动:ps aux|grep redis-server
客户端安装
其实客户端已经在上面的 命令中安装了,能够直接使用了
which redis-cli (查看路径)
用reids客户端登陆服务端
redis-cli -h 127.0.0.1 -p 端口
命令 info
-----------------------
将Redis添加到系统服务中去。
#表示基础信息 [Unit] #描述 Description=Redis #在哪一个服务以后启动 After=syslog.target network.target remote-fs.target nss-lookup.target #表示服务信息 [Service] Type=forking #注意:须要和redis.conf配置文件中的信息一致 PIDFile=/var/run/redis_6379.pid #启动服务的命令 #redis-server安装的路径 和 redis.conf配置文件的路径 ExecStart=/usr/local/bin/redis-server /opt/redis/redis.conf #从新加载命令 ExecReload=/bin/kill -s HUP $MAINPID #中止服务的命令 ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true #安装相关信息 [Install] #以哪一种方式启动 WantedBy=multi-user.target #multi-user.target代表当系统以多用户方式(默认的运行级别)启动时,这个服务须要被自动运行。
文件建立好保存以后,要执行 systemctl daemon-reload
命令,使配置生效。
开机启动: systemctl enable mongodb.service
查看mongodb服务是否设置开机启动: systemctl is-enabled mongodb.service
中止mongodb服务开机启动: systemctl disable mongodb.service
启动: systemctl start mongodb.service
查看状态: systemctl status mongodb.service
重启: systemctl restart mongodb.service
中止: systemctl stop mongodb.service
monodb 换 redis