【问题标题】:Upstart script doesn't know mysql serviceUpstart 脚本不知道 mysql 服务
【发布时间】:2014-07-17 14:28:10
【问题描述】:

我会创建 upstart 脚本,它会在关机前从数据库中刷新脏页。我使用 Ubuntu 14.04 和 MariaDB。我用这个启动新贵脚本:

start on stopping mysql

script
    [something]
end script

但脚本返回:

start: Unknown job: on
Script started, file is typescript

但是脚本什么都不做...我哪里出错了?有人可以帮我吗?这;)

【问题讨论】:

  • 脚本部分有问题,你需要给我们看看。

标签: ubuntu init mariadb upstart


【解决方案1】:

脚本:

#
# mysql-shutdown - This script clean innodb dirty pages
# from: http://www.mysqlperformanceblog.com/2009/04/15/how-to-decrease-innodb-shutdown-times/
#

start on stopping mysql
console output

script
    echo "Mysql-shutdown script start:"
    pct=0

    # Call the given function, require that it complete successfully, and then
    # return the status.
    rcall() {
        echo -n '+'
        echo -n $@
        $@
        status=$?

        if [ $status != 0 ]; then
            echo " FAILED"
            exit $status
        fi

        echo
        return $status
    }

    if [ "$1" = "--allow_dirty_buffers" ]; then
        pct=90
    fi

    innodb_status=$(echo "SHOW ENGINES;" | rcall mysql --user=root | grep InnoDB | cut -f2)
    if [ "$innodb_status" = "DISABLED" ]; then
        echo "The Innodb storage engine is disabled"
        exit 0
    fi

    # tell mysql that we need to shutdown so start flushing dirty pages to disk.
    # Normally InnoDB does this by itself but only when port 3306 is closed which
    # prevents us from monitoring the box.
    rcall mysql --user=root << EOF
    SLAVE STOP;
    SET GLOBAL innodb_max_dirty_pages_pct=$pct;
    EOF

    # ..... how wait until the dirty buffer size goes down to zero.
    IFS=
    if [ "$1" = "--progress" ]; then
        echo "Innodb dirty pages:"
        while [ true ]; do
            status=$(echo 'SHOW INNODB STATUS\G' | rcall mysql --user=root)
            modified_db_pages=$(echo $status | grep -E '^Modified db pages' | grep -Eo '[0-9]+$')

            if [ "$modified_db_pages" = "0" ]; then
                echo
                break
            fi

            echo -ne "$modified_db_pages\r";
            sleep 1
        done
    fi
end script

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-27
    • 1970-01-01
    • 2017-02-06
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多