设为首页 收藏本站
查看: 694|回复: 0

[经验分享] Redis的make,make test,make install、单机多实例配置,以及API程序写数据!

[复制链接]

尚未签到

发表于 2018-11-4 13:10:41 | 显示全部楼层 |阅读模式
  最近学习王家林老师的大数据蘑菇云行动,要实现将Spark Streaming分析的数据写入到Redis。今天正好开始入手。
  一、Ubuntu16安装Redis3.2.1
  遇到了不少的问题,其中,make倒是没问题,make test的时候,出现了:
  !!! WARNING The following tests failed:
  ***[err]: Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl
  Replication not started.
  Cleanup: may take some time... OK
  Makefile:215: recipe for target 'test' failed
  make[1]: *** [test] Error 1
  make[1]: Leaving directory '/home/dyq/Documents/redis-3.2.1/src'
  Makefile:6: recipe for target 'test' failed
  make: *** [test] Error 2
  貌似是没有和master取得同步连接,但是我这不是还没安装的吗?
  百度,看到了一片文章,说是用这个命令:make CFLAGS="-march=i686"
  但直接就出错了,没办法。
  忽略这个错误,直接运行make install吧:
  cd src && make install
  make[1]: Entering directory '/home/dyq/Documents/redis-3.2.1/src'

  Hint: It's a good>  INSTALL install
  install: cannot create regular file '/usr/local/bin/redis-server': Permission denied
  Makefile:256: recipe for target 'install' failed
  make[1]: *** [install] Error 1
  make[1]: Leaving directory '/home/dyq/Documents/redis-3.2.1/src'
  Makefile:9: recipe for target 'install' failed
  make: *** [install] Error 2
  权限?
  sudo make
  sudo make install
  提示错误,要进入src
  好的,OK!
  \o/ All tests passed without errors!
  Cleanup: may take some time... OK
  继续出现错误:
  [exception]: Executing test client: NOREPLICAS Not enough good slaves to write..
  NOREPLICAS Not enough good slaves to write.
  继续找度娘:
  https://my.oschina.net/u/1049845/blog/203370
  这篇文章有说明:
  在make test中可能会遇到时间相关的失败,比如
  Executing test client: NOREPLICAS Not enough good slaves to write..
  这种情况下,可以修改文件tests/integration/replication-2.tcl,将after 1000改为after 10000以延长等待时间。
  修改,继续出错!
  !!! WARNING The following tests failed:
  *** [err]: PEXPIRE/PSETEX/PEXPIREAT can set sub-second expires in tests/unit/expire.tcl
  Expected 'somevalue {}' to equal or match '{} {}'
  *** [err]: Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl
  Replication not started.
  Cleanup: may take some time... OK
  Makefile:215: recipe for target 'test' failed
  make: *** [test] Error 1
  注意看错误信息,注意看错误信息,注意看错误信息!
  是修改tests/unit/expire.tcl:
  tags {"slow"} {
  test {EXPIRE - After 2.1 seconds the key should no longer be here} {
  after 21000
  list [r get x] [r exists x]
  } {{} 0}
  }
  test {EXPIRE - write on expire should work} {
  r del x
  r lpush x foo
  r expire x 10000
  r lpush x bar
  r lrange x 0 -1
  } {bar foo}
  终于看到了绿色:
  \o/ All tests passed without errors!
  有多少坑!!!
  dyq@ubuntu:~/Documents/redis-3.2.1$ sudo make install
  cd src && make install
  make[1]: Entering directory '/home/dyq/Documents/redis-3.2.1/src'

  Hint: It's a good>  INSTALL install
  INSTALL install
  INSTALL install
  INSTALL install
  INSTALL install
  make[1]: Leaving directory '/home/dyq/Documents/redis-3.2.1/src'
  
  虚拟机中安装的时候,机器性能不够的话,很容易出现上述错误!换机器或者更换参数,以及在机器不忙的时候进行编译安装,会顺利通过!
  GIT上的说明:
  For timing issues, one test isn't very representative. Did you try running them 5-10 times? Is there anything unusual about your machine (very small memory, very slow, shared, overloaded, etc)? Some of the tests are based on timing, so if the machine can't deliver results in time then tests can't complete properly. (you can manually edit some of the tests to increase the timeout waiting)
  在src目录下,输入redis-server,进入熟悉的界面,看提示,配置文件是
  29181:C 06 Oct 13:48:16.321 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server
  /path/to/redis.conf
  算了吧,还是指定一个配置文件,在上层目录下,有一个redis.conf。
  
  src/redis-server redis.conf
  二、配置Redis3.2.1
  1、配置生产环境,并设置redis的开机启动。
  首先,建立存放redis配置文件和持久化RDB数据的文件夹:
sudo mkdir /etc/redis  
sudo mkdir /var/redis
  拷贝redis的启动脚本到/etc/init.d文件夹中:
sudo cp utils/redis_init_script /etc/init.d/redis_6379  拷贝redis的配置文件到/etc/redis中,并且以端口号作为文件名:
sudo cp redis.conf /etc/redis/6379.conf  在/var/redis中创建文件夹作为redis实例的数据和工作目录:
sudo mkdir /var/redis/6379  按下面要求修改配置文件:

  •   设置 demonize 为 yes(默认是no)
  •   设置 pidfile 为 /var/run/redis_6379.pid
  •   设置 loglevel 为相应级别
  •   设置 logfile 为 /var/log/redis_6379.log
  •   设置 dir 为 /var/redis/6379
  redis-server /etc/redis/6379.conf
  redis-cli客户端连接服务器,出现>,输入set name="dyq"
  用get name得到dyq。成功!
  redis的官方配置文档地址为:http://redis.io/topics/quickstart
  为了能远程连接redis服务器,需要修改/etc/redis/6379.conf,将ip_bind从127.0.0.1修改为192.168.0.10。
  三、安装单机多实例Redis
  1、拷贝配置文件
  cp /etc/6379.conf /etc/6380.conf
  cp /etc/6379.conf /etc/6381.conf
  
  2、修改配置文件
  sudo gedit /etc/6380.conf
  修改
  bind 192.168.0.10
  port 6380     
  daemonize yes     
  logfile /var/log/redis_6380.log      
  dir /var/redis/6380/
  pidfile /var/run/redis_6380.pid
  
  创建文件目录:
  
  sudo mkdir /var/redis/6380/
  sudo gedit /var/log/redis_6380.log
  3、修改主从设置
  将6380.conf中的
  slaveof 192.168.0.10 6379
  4、验证主从同步
  启动6380和6381
  dyq@ubuntu:~/Documents/redis-3.2.1$ src/redis-server.sh /etc/redis/6380.conf
  -bash: src/redis-server.sh: No such file or directory
  dyq@ubuntu:~/Documents/redis-3.2.1$ src/redis-server /etc/redis/6380.conf
  *** FATAL CONFIG FILE ERROR ***
  Reading the configuration file, at line 163
  >>> 'logfile /var/log/redis6380.log'
  Can't open the log file: Permission denied
  
  可以发现实文件没有写权限。sudo chown dyq /var/log/redis6380.log
  
  src/redis-cli -h 192.168.0.10 -p 6379
  >set name='testredis'
  >get name
  
  从库登录:
  src/redis-cli -h 192.168.0.10 -p 6380
  >get name
  
  src/redis-cli -h 192.168.0.10 -p 6381
  >get name
  
  可以看到主从数据实现同步。成功!
  
  四、从IDES远程访问Redis,并写入数据
  



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-630690-1-1.html 上篇帖子: redis可视化工具 下篇帖子: Spark Streaming写数据到Redis
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表