Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8139326
  • 博文数量: 594
  • 博客积分: 13065
  • 博客等级: 上将
  • 技术积分: 10324
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-26 16:44
个人简介

推荐: blog.csdn.net/aquester https://github.com/eyjian https://www.cnblogs.com/aquester http://blog.chinaunix.net/uid/20682147.html

文章分类

全部博文(594)

分类: 系统运维

2018-09-02 22:04:22

使用之前准备工作:
1)配置好与端口无关的公共redis.conf文件,和工具放在同一目录下
2)配置好与端口相关的模板redis-PORT.conf文件,也和工具放在同一目录下(部署时PORT会被替换成具体的端口号)
3)配置好组成集群的节点文件redis_cluster.nodes,也和工具放在同一目录下
redis_cluster.nodes的文件格式为每行一个组成Redis集群的节点,支持“#”打头的注释行,格式示例:
127.0.0.1 6381
127.0.0.1 6382
127.0.0.1 6383
127.0.0.1 6384
127.0.0.1 6385
127.0.0.1 6386
4)创建好安装redis的目录(可建筑批量工具mooon_ssh完成,deploy_redis_cluster.sh主要也是利用了该批量工具)
5)其它更详细的可以直接看源代码,有详细的说明。


建立将下载到一个目录,运行deploy_redis_cluster.sh工具时,它会提示各种前置条件,比如redis-cli是否可用等。


源码(可从下载):
  1. #!/bin/bash
  2. # 源代码:
  3. # a tool to deploy a redis cluster
  4. #
  5. # 自动化部署redis集群工具,
  6. # 远程操作即可,不需登录到Redis集群中的任何机器。
  7. #
  8. # 以root用户批量创建用户redis示例:
  9. # export H=192.168.0.5,192.168.0.6,192.168.0.7,192.168.0.8,192.168.0.9
  10. # export U=root
  11. # export P='root^1234'
  12. # mooon_ssh -c='groupadd redis; useradd -g redis -m redis; echo "redis:redis#1234"|chpasswd'
  13. #
  14. # 批量创建redis安装目录/data/redis-4.0.11,并设置owner为用户redis,用户组为redis示例:
  15. # mooon_ssh -c='mkdir /data/redis-4.0.11;ln -s /data/redis-4.0.11 /data/redis;chown redis:redis /data/redis*'
  16. #
  17. # 可使用process_monitor.sh监控redis-server进程重启:
  18. #
  19. # 使用示例:
  20. # * * * * * /usr/local/bin/process_monitor.sh "/usr/local/redis/bin/redis-server 6379" "/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis-6379.conf"
  21. # * * * * * /usr/local/bin/process_monitor.sh "/usr/local/redis/bin/redis-server 6380" "/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis-6380.conf"
  22. # 可在/tmp目录找到process_monitor.sh的运行日志,当对应端口的进程不在时,5秒内即会重启对应端口的进程。
  23. #
  24. # 运行参数:
  25. # 参数1 SSH端口
  26. # 参数2 安装用户
  27. # 参数3 安装用户密码
  28. # 参数4 安装目录
  29. #
  30. # 前置条件(可借助批量工具mooon_ssh和mooon_upload完成):
  31. # 1)安装用户已经创建好
  32. # 2)安装用户密码已经设置好
  33. # 3)安装目录已经创建好,并且目录的owner为安装用户
  34. # 4)执行本工具的机器上安装好了ruby,且版本号不低于2.0.0
  35. # 5)执行本工具的机器上安装好了redis-X.Y.Z.gem,且版本号不低于redis-3.0.0.gem
  36. #
  37. # 6)同目录下存在以下几个可执行文件:
  38. # 6.1)redis-server
  39. # 6.2)redis-cli
  40. # 6.3)redis-check-rdb
  41. # 6.4)redis-check-aof
  42. # 6.5)redis-trib.rb
  43. #
  44. # 7)同目录下存在以下两个配置文件:
  45. # 7.1)redis.conf
  46. # 7.2)redis-PORT.conf
  47. # 其中redis.conf为公共配置文件,
  48. # redis-PORT.conf为指定端口的配置文件模板,
  49. # 同时,需要将redis-PORT.conf文件中的目录和端口分别使用INSTALLDIR和REDISPORT替代,示例:
  50. # include INSTALLDIR/conf/redis.conf
  51. # pidfile INSTALLDIR/bin/redis-REDISPORT.pid
  52. # logfile INSTALLDIR/log/redis-REDISPORT.log
  53. # port REDISPORT
  54. # dbfilename dump-REDISPORT.rdb
  55. # dir INSTALLDIR/data/REDISPORT
  56. #
  57. # 其中INSTALLDIR将使用参数4的值替换,
  58. # 而REDISPORT将使用redis_cluster.nodes中的端口号替代
  59. #
  60. # 配置文件redis_cluster.nodes,定义了安装redis的节点
  61. # 文件格式(以“#”打头的为注释):
  62. # 每行由IP和端口号组成,两者间可以:空格、逗号、分号、或TAB符分隔
  63. #
  64. # 依赖:
  65. # 1)mooon_ssh 远程操作多台机器批量命令工具
  66. # 2)mooon_upload 远程操作多台机器批量上传工具
  67. # 3)
  68. # 4)libmooon又依赖libssh2()
  69. BASEDIR=$(dirname $(readlink -f $0))
  70. REDIS_CLUSTER_NODES=$BASEDIR/redis_cluster.nodes
  71. # 批量命令工具
  72. MOOON_SSH=mooon_ssh
  73. # 批量上传工具
  74. MOOON_UPLOAD=mooon_upload
  75. # 创建redis集群工具
  76. REDIS_TRIB=$BASEDIR/redis-trib.rb
  77. # redis-server
  78. REDIS_SERVER=$BASEDIR/redis-server
  79. # redis-cli
  80. REDIS_CLI=$BASEDIR/redis-cli
  81. # redis-check-aof
  82. REDIS_CHECK_AOF=$BASEDIR/redis-check-aof
  83. # redis-check-rdb
  84. REDIS_CHECK_RDB=$BASEDIR/redis-check-rdb
  85. # redis.conf
  86. REDIS_CONF=$BASEDIR/redis.conf
  87. # redis-PORT.conf
  88. REDIS_PORT_CONF=$BASEDIR/redis-PORT.conf
  89. # 全局变量
  90. # 组成redis集群的总共节点数
  91. num_nodes=0
  92. # 组成redis集群的所有IP数组
  93. redis_node_ip_array=()
  94. # 组成redis集群的所有节点数组(IP+port构造一个redis节点)
  95. redis_node_array=()
  96. # 用法
  97. function usage()
  98. {
  99. echo -e "\033[1;33mUsage\033[m: `basename $0` \033[0;32;32mssh-port\033[m install-user \033[0;32;32minstall-user-password\033[m install-dir"
  100. echo -e "\033[1;33mExample\033[m: `basename $0` \033[0;32;32m22\033[m redis \033[0;32;32mredis^1234\033[m /usr/local/redis-4.0.11"
  101. }
  102. # 需要指定五个参数
  103. if test $# -ne 4; then
  104. usage
  105. echo ""
  106. exit 1
  107. fi
  108. ssh_port="$1"
  109. install_user="$2"
  110. install_user_password="$3"
  111. install_dir="$4"
  112. echo -e "[ssh port] \033[1;33m$ssh_port\033[m"
  113. echo -e "[install user] \033[1;33m$install_user\033[m"
  114. echo -e "[install directory] \033[1;33m$install_dir\033[m"
  115. echo ""
  116. # 检查ruby是否可用
  117. which ruby > /dev/null 2>&1
  118. if test $? -eq 0; then
  119. echo -e "Checking ruby OK"
  120. else
  121. echo -e "ruby \033[0;32;31mnot exists or not executable\033[m"
  122. echo ""
  123. echo -e "Exit now\n"
  124. exit 1
  125. fi
  126. # 检查gem是否可用
  127. which gem > /dev/null 2>&1
  128. if test $? -eq 0; then
  129. echo -e "Checking gem OK"
  130. else
  131. echo -e "gem \033[0;32;31mnot exists or not executable\033[m"
  132. echo ""
  133. echo -e "Exit now\n"
  134. exit 1
  135. fi
  136. # 检查mooon_ssh是否可用
  137. which "$MOOON_SSH" > /dev/null 2>&1
  138. if test $? -eq 0; then
  139. echo -e "Checking $MOOON_SSH OK"
  140. else
  141. echo -e "$MOOON_SSH \033[0;32;31mnot exists or not executable\033[m"
  142. echo "There are two versions: C++ and GO:"
  143. echo ""
  144. echo "/master/tools/mooon_ssh.cpp"
  145. echo "/master/tools/mooon_ssh.go"
  146. echo -e "Exit now\n"
  147. exit 1
  148. fi
  149. # 检查mooon_upload是否可用
  150. which "$MOOON_UPLOAD" > /dev/null 2>&1
  151. if test $? -eq 0; then
  152. echo -e "Checking $MOOON_UPLOAD OK"
  153. else
  154. echo -e "$MOOON_UPLOAD \033[0;32;31mnot exists or not executable\033[m"
  155. echo "There are two versions: C++ and GO:"
  156. echo ""
  157. echo "/master/tools/mooon_upload.cpp"
  158. echo "/master/tools/mooon_upload.go"
  159. echo -e "Exit now\n"
  160. exit 1
  161. fi
  162. # 检查redis-trib.rb是否可用
  163. which "$REDIS_TRIB" > /dev/null 2>&1
  164. if test $? -eq 0; then
  165. echo -e "Checking $REDIS_TRIB OK"
  166. else
  167. echo -e "$REDIS_TRIB \033[0;32;31mnot exists or not executable\033[m"
  168. echo -e "Exit now\n"
  169. exit 1
  170. fi
  171. # 检查redis-server是否可用
  172. which "$REDIS_SERVER" > /dev/null 2>&1
  173. if test $? -eq 0; then
  174. echo -e "Checking $REDIS_SERVER OK"
  175. else
  176. echo -e "$REDIS_SERVER \033[0;32;31mnot exists or not executable\033[m"
  177. echo -e "Exit now\n"
  178. exit 1
  179. fi
  180. # 检查redis-cli是否可用
  181. which "$REDIS_CLI" > /dev/null 2>&1
  182. if test $? -eq 0; then
  183. echo -e "Checking $REDIS_CLI OK"
  184. else
  185. echo -e "$REDIS_CLI \033[0;32;31mnot exists or not executable\033[m"
  186. echo -e "Exit now\n"
  187. exit 1
  188. fi
  189. # 检查redis-check-aof是否可用
  190. which "$REDIS_CHECK_AOF" > /dev/null 2>&1
  191. if test $? -eq 0; then
  192. echo -e "Checking $REDIS_CHECK_AOF OK"
  193. else
  194. echo -e "$REDIS_CHECK_AOF \033[0;32;31mnot exists or not executable\033[m"
  195. echo -e "Exit now\n"
  196. exit 1
  197. fi
  198. # 检查redis-check-rdb是否可用
  199. which "$REDIS_CHECK_RDB" > /dev/null 2>&1
  200. if test $? -eq 0; then
  201. echo -e "Checking $REDIS_CHECK_RDB OK"
  202. else
  203. echo -e "$REDIS_CHECK_RDB \033[0;32;31mnot exists or not executable\033[m"
  204. echo -e "Exit now\n"
  205. exit 1
  206. fi
  207. # 检查redis.conf是否可用
  208. if test -r "$REDIS_CONF"; then
  209. echo -e "Checking $REDIS_CONF OK"
  210. else
  211. echo -e "$REDIS_CONF \033[0;32;31mnot exists or not readable\033[m"
  212. echo -e "Exit now\n"
  213. exit 1
  214. fi
  215. # 检查redis-PORT.conf是否可用
  216. if test -r "$REDIS_PORT_CONF"; then
  217. echo -e "Checking $REDIS_PORT_CONF OK"
  218. else
  219. echo -e "$REDIS_PORT_CONF \033[0;32;31mnot exists or not readable\033[m"
  220. echo -e "Exit now\n"
  221. exit 1
  222. fi
  223. # 解析redis_cluster.nodes文件,
  224. # 从而得到组成redis集群的所有节点。
  225. function parse_redis_cluster_nodes()
  226. {
  227. redis_nodes_str=
  228. redis_nodes_ip_str=
  229. while read line
  230. do
  231. # 删除前尾空格
  232. line=`echo "$line" | xargs`
  233. if test -z "$line" -o "$line" = "#"; then
  234. continue
  235. fi
  236. # 跳过注释
  237. begin_char=${line:0:1}
  238. if test "$begin_char" = "#"; then
  239. continue
  240. fi
  241. # 取得IP和端口
  242. eval $(echo "$line" | awk -F[\ \:,\;\t]+ '{ printf("ip=%s\nport=%s\n",$1,$2); }')
  243. # IP和端口都必须有
  244. if test ! -z "$ip" -a ! -z "$port"; then
  245. if test -z "$redis_nodes_ip_str"; then
  246. redis_nodes_ip_str=$ip
  247. else
  248. redis_nodes_ip_str="$redis_nodes_ip_str,$ip"
  249. fi
  250. if test -z "$redis_nodes_str"; then
  251. redis_nodes_str="$ip:$port"
  252. else
  253. redis_nodes_str="$redis_nodes_str,$ip:$port"
  254. fi
  255. fi
  256. done < $REDIS_CLUSTER_NODES
  257. if test -z "$redis_nodes_ip_str"; then
  258. num_nodes=0
  259. else
  260. # 得到IP数组redis_node_ip_array
  261. redis_node_ip_array=`echo "$redis_nodes_ip_str" | tr ',' '\n' | sort | uniq`
  262. # 得到节点数组redis_node_array
  263. redis_node_array=`echo "$redis_nodes_str" | tr ',' '\n' | sort | uniq`
  264. for redis_node in ${redis_node_array[@]};
  265. do
  266. num_nodes=$((++num_nodes))
  267. echo "$redis_node"
  268. done
  269. fi
  270. }
  271. # check redis_cluster.nodes
  272. if test ! -r $REDIS_CLUSTER_NODES; then
  273. echo -e "File $REDIS_CLUSTER_NODES \033[0;32;31mnot exits\033[m"
  274. echo ""
  275. echo -e "\033[0;32;32mFile format\033[m (columns delimited by space, tab, comma, semicolon or colon):"
  276. echo "IP1 port1"
  277. echo "IP2 port2"
  278. echo ""
  279. echo -e "\033[0;32;32mExample\033[m:"
  280. echo "127.0.0.1 6381"
  281. echo "127.0.0.1 6382"
  282. echo "127.0.0.1 6383"
  283. echo "127.0.0.1 6384"
  284. echo "127.0.0.1 6385"
  285. echo "127.0.0.1 6386"
  286. echo -e "Exit now\n"
  287. exit 1
  288. else
  289. echo -e "\033[0;32;32m"
  290. parse_redis_cluster_nodes
  291. echo -e "\033[m"
  292. if test $num_nodes -lt 1; then
  293. echo -e "Checking $REDIS_CLUSTER_NODES \033[0;32;32mfailed\033[m: no any node"
  294. echo -e "Exit now\n"
  295. exit 1
  296. else
  297. echo -e "Checking $REDIS_CLUSTER_NODES OK, the number of nodes is \033[1;33m${num_nodes}\033[m"
  298. fi
  299. fi
  300. # 确认后再继续
  301. while true
  302. do
  303. # 组成一个redis集群至少需要六个节点
  304. if test $num_nodes -lt 6; then
  305. echo -e "\033[0;32;32mAt least 6 nodes are required to create a redis cluster\033[m"
  306. fi
  307. # 提示是否继续
  308. echo -en "Are you sure to continue? [\033[1;33myes\033[m/\033[1;33mno\033[m]"
  309. read -r -p " " input
  310. if test "$input" = "no"; then
  311. echo -e "Exit now\n"
  312. exit 1
  313. elif test "$input" = "yes"; then
  314. echo "Starting to install ..."
  315. echo ""
  316. break
  317. fi
  318. done
  319. # 是否先清空安装目录再安装?
  320. clear_install_directory=
  321. while true
  322. do
  323. echo -en "Clear install directory? [\033[1;33myes\033[m/\033[1;33mno\033[m]"
  324. read -r -p " " clear_install_directory
  325. if test "$clear_install_directory" = "no"; then
  326. echo ""
  327. break
  328. elif test "$clear_install_directory" = "yes"; then
  329. echo ""
  330. break
  331. fi
  332. done
  333. # 安装公共的,包括可执行程序文件和公共配置文件
  334. function install_common()
  335. {
  336. redis_ip="$1"
  337. # 检查安装目录是否存在,且有读写权限
  338. echo "$MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c=\"test -d $install_dir && test -r $install_dir && test -w $install_dir && test -x $install_dir\""
  339. $MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c="test -d $install_dir && test -r $install_dir && test -w $install_dir && test -x $install_dir"
  340. if test $? -ne 0; then
  341. echo ""
  342. echo -e "Directory $install_dir \033[1;33mnot exists or no (rwx) permission\033[m"
  343. echo -e "Exit now\n"
  344. exit 1
  345. fi
  346. # 清空安装目录
  347. if test "$clear_install_directory" = "yes"; then
  348. echo ""
  349. echo "$MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c=\"killall -q -w -u $install_user redis-server\""
  350. $MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c="killall -q -w -u $install_user redis-server"
  351. echo "$MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c=\"rm -fr $install_dir/*\""
  352. $MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c="rm -fr $install_dir/*"
  353. if test $? -ne 0; then
  354. echo -e "Exit now\n"
  355. exit 1
  356. fi
  357. fi
  358. # 创建公共目录(create directory)
  359. echo ""
  360. echo "$MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c=\"cd $install_dir;mkdir -p bin conf log data\""
  361. $MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c="cd $install_dir;mkdir -p bin conf log data"
  362. if test $? -ne 0; then
  363. echo -e "Exit now\n"
  364. exit 1
  365. fi
  366. # 上传公共配置文件(upload configuration files)
  367. echo ""
  368. echo "$MOOON_UPLOAD -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -s=redis.conf -d=$install_dir/conf"
  369. $MOOON_UPLOAD -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -s=redis.conf -d=$install_dir/conf
  370. if test $? -ne 0; then
  371. echo -e "Exit now\n"
  372. exit 1
  373. fi
  374. # 上传公共执行文件(upload executable files)
  375. echo ""
  376. echo "$MOOON_UPLOAD -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -s=redis-server,redis-cli,redis-check-aof,redis-check-rdb -d=$install_dir/bin"
  377. $MOOON_UPLOAD -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -s=redis-server,redis-cli,redis-check-aof,redis-check-rdb,redis-trib.rb -d=$install_dir/bin
  378. if test $? -ne 0; then
  379. echo -e "Exit now\n"
  380. exit 1
  381. fi
  382. }
  383. # 安装节点配置文件
  384. function install_node_conf()
  385. {
  386. redis_ip="$1"
  387. redis_port="$2"
  388. # 生成节点配置文件
  389. cp redis-PORT.conf redis-$redis_port.conf
  390. sed -i "s|INSTALLDIR|$install_dir|g;s|REDISPORT|$redis_port|g" redis-$redis_port.conf
  391. # 创建节点数据目录(create data directory for the given node)
  392. echo ""
  393. echo "$MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c=\"cd $install_dir;mkdir -p data/$redis_port\""
  394. $MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c="cd $install_dir;mkdir -p data/$redis_port"
  395. if test $? -ne 0; then
  396. rm -f redis-$redis_port.conf
  397. echo -e "Exit now\n"
  398. exit 1
  399. fi
  400. # 上传节点配置文件(upload configuration files)
  401. echo ""
  402. echo "$MOOON_UPLOAD -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -s=redis-$redis_port.conf -d=$install_dir/conf"
  403. $MOOON_UPLOAD -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -s=redis-$redis_port.conf -d=$install_dir/conf
  404. if test $? -ne 0; then
  405. rm -f redis-$redis_port.conf
  406. echo -e "Exit now\n"
  407. exit 1
  408. fi
  409. rm -f redis-$redis_port.conf
  410. }
  411. function start_redis_node()
  412. {
  413. redis_ip="$1"
  414. redis_port="$2"
  415. # 启动redis实例(start redis instance)
  416. echo ""
  417. echo "$MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c=\"$install_dir/bin/redis-server $install_dir/conf/redis-$redis_port.conf\""
  418. $MOOON_SSH -h=$redis_ip -P=$ssh_port -u=$install_user -p=$install_user_password -c="nohup $install_dir/bin/redis-server $install_dir/conf/redis-$redis_port.conf > /dev/null 2>&1 &"
  419. if test $? -ne 0; then
  420. echo -e "Exit now\n"
  421. exit 1
  422. fi
  423. }
  424. # 安装公共的,包括可执行程序文件和公共配置文件
  425. echo ""
  426. echo -e "\033[1;33m================================\033[m"
  427. for redis_node_ip in $redis_node_ip_array;
  428. do
  429. echo -e "[\033[1;33m$redis_node_ip\033[m] Installing common ..."
  430. install_common $redis_node_ip
  431. done
  432. # 安装节点配置文件
  433. echo ""
  434. echo -e "\033[1;33m================================\033[m"
  435. for redis_node in ${redis_node_array[@]};
  436. do
  437. node_ip=
  438. node_port=
  439. eval $(echo "$redis_node" | awk -F[\ \:,\;\t]+ '{ printf("node_ip=%s\nnode_port=%s\n",$1,$2); }')
  440. if test -z "$node_ip" -o -z "$node_port"; then
  441. continue
  442. fi
  443. echo -e "[\033[1;33m$node_ip:$node_port\033[m] Installing node ..."
  444. install_node_conf $node_ip $node_port
  445. done
  446. # 确认后再继续
  447. echo ""
  448. echo -e "\033[1;33m================================\033[m"
  449. while true
  450. do
  451. echo -en "Start redis? [\033[1;33myes\033[m/\033[1;33mno\033[m]"
  452. read -r -p " " input
  453. if test "$input" = "no"; then
  454. echo ""
  455. exit 1
  456. elif test "$input" = "yes"; then
  457. echo "Starting to start redis ..."
  458. echo ""
  459. break
  460. fi
  461. done
  462. # 启动redis实例(start redis instance)
  463. for redis_node in ${redis_node_array[@]};
  464. do
  465. eval $(echo "$redis_node" | awk -F[\ \:,\;\t]+ '{ printf("node_ip=%s\nnode_port=%s\n",$1,$2); }')
  466. if test -z "$node_ip" -o -z "$node_port"; then
  467. continue
  468. fi
  469. echo -e "[\033[1;33m$node_ip:$node_port\033[m] Starting node ..."
  470. start_redis_node $node_ip $node_port
  471. done
  472. echo ""
  473. echo -e "\033[1;33m================================\033[m"
  474. echo "Number of nodes: $num_nodes"
  475. if test $num_nodes -lt 6; then
  476. echo "Number of nodes less than 6, can not create redis cluster"
  477. echo -e "Exit now\n"
  478. exit 1
  479. else
  480. redis_nodes_str=`echo "$redis_nodes_str" | tr ',' ' '`
  481. # 确认后再继续
  482. echo ""
  483. while true
  484. do
  485. echo -en "Create redis cluster? [\033[1;33myes\033[m/\033[1;33mno\033[m]"
  486. read -r -p " " input
  487. if test "$input" = "no"; then
  488. echo ""
  489. exit 1
  490. elif test "$input" = "yes"; then
  491. echo "Starting to create redis cluster with $redis_nodes_str ... ..."
  492. echo ""
  493. break
  494. fi
  495. done
  496. # 创建redis集群(create redis cluster)
  497. # redis-trib.rb create --replicas 1
  498. $REDIS_TRIB create --replicas 1 $redis_nodes_str
  499. echo -e "Exit now\n"
  500. exit 0
  501. fi


阅读(2308) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~