Redis数据库源码安装部署
2019-01-31 20:05
393 查看
- 挂载本地镜像并安装编译工具包:
[root@localhost ~]# mount /dev/sr0 /mnt/cdrom/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@localhost ~]# yum install gcc tcl -y Loaded plugins: fastestmirror, refresh-packagekit, security Determining fastest mirrors jyy | 4.0 kB 00:00 ... Setting up Install Process Package gcc-4.4.7-4.el6.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package tcl.x86_64 1:8.5.7-6.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================== Package Arch Version Repository Size =========================================================================== Installing: tcl x86_64 1:8.5.7-6.el6 jyy 1.9 M Transaction Summary =========================================================================== Install 1 Package(s) Total download size: 1.9 M Installed size: 4.4 M Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 1:tcl-8.5.7-6.el6.x86_64 1/1 Verifying : 1:tcl-8.5.7-6.el6.x86_64 1/1 Installed: tcl.x86_64 1:8.5.7-6.el6 Complete!
- 下载源码包并进行编译安装:
redis软件包官方网站: http://download.redis.io/releases/
[root@localhost ~]# wget http://download.redis.io/releases/redis-2.8.18.tar.gz --2019-01-31 19:44:41-- http://download.redis.io/releases/redis-2.8.18.tar.gz 正在解析主机 download.redis.io... 109.74.203.151 正在连接 download.redis.io|109.74.203.151|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:1254077 (1.2M) [application/x-gzip] 正在保存至: “redis-2.8.18.tar.gz” 100%[=================================>] 1,254,077 668K/s in 1.8s 2019-01-31 19:44:43 (668 KB/s) - 已保存 “redis-2.8.18.tar.gz” [1254077/1254077]) [root@localhost ~]# ls anaconda-ks.cfg install.log.syslog 公共的 视频 文档 音乐 install.log redis-2.8.18.tar.gz 模板 图片 下载 桌面 [root@localhost ~]# [root@localhost ~]# tar -xf redis-2.8.18.tar.gz [root@localhost ~]# cd redis-2.8.18 [root@localhost redis-2.8.18]# ls 00-RELEASENOTES COPYING Makefile redis.conf sentinel.conf utils BUGS deps MANIFESTO runtest src CONTRIBUTING INSTALL README runtest-sentinel tests [root@localhost redis-2.8.18]# make //开始编译 cd src && make all make[1]: Entering directory `/root/redis-2.8.18/src' rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html (cd ../deps && make distclean) make[2]: Entering directory `/root/redis-2.8.18/deps' (cd hiredis && make clean) > /dev/null || true ......过程省略..... [root@localhost redis-2.8.18]# mkdir /usr/local/redis [root@localhost redis-2.8.18]# make PREFIX=/usr/local/redis/ install cd src && make install make[1]: Entering directory `/root/redis-2.8.18/src' Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install make[1]: Leaving directory `/root/redis-2.8.18/src' [root@localhost redis-2.8.18]#
3.拷贝文件和添加环境变量:
[root@localhost redis-2.8.18]# vim /root/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH export REDIS_HOME=/usr/local/redis //定义redis的变量 PATH=$REDIS_HOME/bin:$PATH //添加到用户变量中 ~ ~ ~ ~ ~ ~ :wq [root@localhost redis-2.8.18]# source /root/.bash_profile [root@localhost redis-2.8.18]# [root@localhost src]# cd .. [root@localhost redis-2.8.18]# cd src/ [root@localhost src]# ls redis-se redis-sentinel redis-server [root@localhost src]# ls redis-sentinel redis-sentinel [root@localhost src]# cp redis-sentinel /usr/local/redis/bin/ //拷贝此文件到安装目录里 [root@localhost src]# ls /usr/local/redis/bin/ redis-benchmark redis-check-dump redis-sentinel redis-check-aof redis-cli redis-server [root@localhost src]#
4.执行安装脚本初始化
[root@localhost redis-2.8.18]# cd utils/ [root@localhost utils]# ls build-static-symbols.tcl mkrelease.sh redis-sha1.rb generate-command-help.rb redis-copy.rb speed-regression.tcl hyperloglog redis_init_script whatisdoing.sh install_server.sh redis_init_script.tpl [root@localhost utils]# ./install_server.sh Welcome to the redis service installer This script will help you easily set up a running redis server Please select the redis port for this instance: [6379] //redis的端口号 Selecting default: 6379 Please select the redis config file name [/etc/redis/6379.conf] //redis的配置文件位置 Selected default - /etc/redis/6379.conf Please select the redis log file name [/var/log/redis_6379.log] //redis的日志位置 Selected default - /var/log/redis_6379.log Please select the data directory for this instance [/var/lib/redis/6379] //redis的一些端口信息 Selected default - /var/lib/redis/6379 Please select the redis executable path [/usr/local/redis/bin/redis-server] //redis的服务启动位置 Selected config: Port : 6379 Config file : /etc/redis/6379.conf Log file : /var/log/redis_6379.log Data dir : /var/lib/redis/6379 Executable : /usr/local/redis/bin/redis-server Cli Executable : /usr/local/redis/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort. Copied /tmp/6379.conf => /etc/init.d/redis_6379 Installing service... Successfully added to chkconfig! Successfully added to runlevels 345! Starting Redis server... Installation successful! //安装成功! [root@localhost utils]#
5.修改服务脚本并启动服务
[root@localhost utils]# cd /etc/init.d/ [root@localhost init.d]# ls abrt-ccpp firstboot messagebus psacct smartd abrtd functions mysql.server quota_nld snmpd abrt-oops haldaemon netconsole rdisc snmptrapd acpid halt netfs redis_6379 spice-vdagentd atd htcacheclean network restorecond sshd auditd httpd NetworkManager rngd sssd autofs ip6tables nfs rpcbind sysstat blk-availability iptables nfslock rpcgssd udev-post bluetooth irqbalance nginx rpcidmapd wdaemon certmonger kdump ntpd rpcsvcgssd winbind cpuspeed killall ntpdate rsyslog wpa_supplicant crond lvm2-lvmetad oddjobd sandbox ypbind cups lvm2-monitor portreserve saslauthd dnsmasq mdmonitor postfix single [root@localhost init.d]# mv redis_6379 redisd //修改启动脚本名称 [root@localhost init.d]# chkconfig --add redisd //添加redis服务 [root@localhost init.d]# chkconfig redisd on //把redis服务设为开机自启 [root@localhost init.d]# service redisd start Starting Redis server... [root@localhost init.d]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:6379 //redis的端口号 *:* LISTEN 0 128 :::6379 :::* LISTEN 0 128 :::111 :::* LISTEN 0 128 *:111 *:* LISTEN 0 128 *:80 *:* LISTEN 0 128 :::53426 :::* LISTEN 0 128 :::22 :::* LISTEN 0 128 *:22 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 128 ::1:631 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 *:49254 *:* [root@localhost init.d]# [root@localhost init.d]# redis-cli -n 127.0.0.1 -p 6379 127.0.0.1:6379[127]> set name xiaoming OK 127.0.0.1:6379[127]> get name "xiaoming" 127.0.0.1:6379[127]>
相关文章推荐
- 【Redis 1】Redis数据库的学习与实践—安装与部署
- Redis数据库安装部署
- Redis数据库的安装与部署
- NoSQL数据库之Redis数据库管理一(Redis的介绍与安装部署)
- redis 数据库 rpm 安装部署
- redis 数据库 3.0.5 源码安装
- 部署mariadb数据库到linux(源码编译安装)
- NoSQL数据库之Redis数据库:Redis的介绍与安装部署
- Linux系统 Redis数据库安装与部署使用
- NoSQL数据库之Redis数据库:Redis的介绍与安装部署(redis-2.8.19/3.2.5)
- 结合redis设计与实现的redis源码学习-11-数据库(server.h/redisDb,notify.c)
- windows环境redis主从安装部署
- [转] Visual Studio 2005 项目部署2[带安装数据库] [http://blog.csdn.net/yongping8204/archive/2007/06/26/1666885.aspx]
- 安装和部署,同时支持多个数据库安装
- Kibana+Logstash+Elasticsearch+Redis安装部署
- 缓存数据库-redis安装和配置
- LAMP Ubuntu 12.04 LTS 搭建 ---附带memcache redis安装(源码)
- Centos7安装部署Redis3.2.9 (普通用户)
- redis以及php的redis扩展安装部署
- linux 安装redis数据库