zoukankan      html  css  js  c++  java
  • 自动交互安装服务应用,以redis为例

    #!/bin/bash
    #新建preinstall.sh文件,该文件完成安装前的准备
    yum install gcc gcc-* wget expect -y #expect是因为后面我们用到,安装后可用来检测内容进行自动交互输入 mkdir -p /software/redis mkdir -p /opt/redis mkdir -p /opt/redis/data/6379 mkdir -p /opt/redis/log touch /opt/redis/log/redis_6379.log cd /software/redis/ wget http://download.redis.io/releases/redis-4.0.9.tar.gz tar -zxvf redis-4.0.9.tar.gz -C /opt/redis cd /opt/redis/redis-4.0.9 make MALLOC=libc cd /opt/redis/redis-4.0.9/src make install

    开始安装

    #!/usr/bin/expect
    #新建startinstall.sh文件,该文件开始正式安装,其中
    是指回车
    spawn /opt/redis/redis-4.0.9/utils/install_server.sh    #需要这样写,否则可能识别不出路径
    #等待this instance出现,最好在前后也加上*,如下
    expect "*this instance*"
    #上面的内容出来后就可以自动输入6379了
    
    send "6379
    "
    expect "*config file name*"
    send "/etc/redis/6379.conf
    "
    expect "*log file name*"
    send "/opt/redis/log/redis_6379.log
    "
    expect "*this instance*"
    send "/opt/redis/data/6379
    "
    expect "*path*"
    send "/usr/local/bin/redis-server
    "
    #这里也要检测ENTER
    expect "*ENTER*"  
    #回车
    send "
    "
    #最好是检测到这个安装成功后再expect eof
    
    expect "Installation successful!"
    expect eof

    至此,redis已经算是安装好了执行/etc/init.d/redis_6379 start即可开启服务

  • 相关阅读:
    mysql中的enum型
    mysql中的时间year/date/time/datetime
    一些数字的属性
    mysql增删
    Perl6 Bailador框架(8):自定义400/500
    react: typescript jest && enzyme
    webstorm tslint配置
    react: typescript import images alias
    JSONP原理及简单实现
    纯css画三角形
  • 原文地址:https://www.cnblogs.com/biaopei/p/9156187.html
Copyright © 2011-2022 走看看