仔细研究了mysqld_safe脚本,发现脚本中,有个函数parse_arguments(),用来解析参数文件中的一些必要参数,这里把plugin_dir这个变量解析出来,赋给了脚本变量$PLUGIN_DIR,
但是,在调用这个函数之前,脚本就有一段代码对$PLUGIN_DIR这个变量做了是否为空的判断,并据此定义$plugin_dir的值:
if [ -n "${PLUGIN_DIR}" ]; then
plugin_dir="${PLUGIN_DIR}"
else
# Try to find plugin dir relative to basedir
for dir in lib/mysql/plugin lib/plugin
do
if [ -d "${MY_BASEDIR_VERSION}/${dir}" ]; then
plugin_dir="${MY_BASEDIR_VERSION}/${dir}"
break
fi
done
# Give up and use compiled-in default
if [ -z "${plugin_dir}" ]; then
plugin_dir='/usr/local/mysql/lib/plugin'
fi
fi
plugin_dir="${plugin_dir}${PLUGIN_VARIANT}"
注意,我是经过反复测试后确认,这段代码是在调用parse_arguments之前就执行了,所以$PLUGIN_DIR为空,自然$plugin_dir也就是默认值了,既然$PLUGIN_DIR还没有初始化,就做判断,这里的逻辑是不是有问题,这是我疑惑的地方!
不知道有没有哪位高手研究过这个脚本,请帮忙看看 作者: cenalulu 时间: 2012-12-03 13:18
你说的这段是初始化,之后会调用parse_arguments 把配置文件的所有参数过一遍,进行赋值。
my.cnf内容:
# All files in this package is subject to the GPL v2 license
# More information is in the COPYING file in the top directory of this package.
# Copyright (C) 2011 severalnines.com
#REPLICATION SPECIFIC - GENERAL
#server-id must be unique across all mysql servers participating in replication.
server-id=1
#REPLICATION SPECIFIC - MASTER
#log-bin=binlog
#binlog-format=ROW
#expire-logs-days=5
#LOGS
log-error=error.log
#log
#log-slow-queries
#OTHER THINGS, BUFFERS ETC
key_buffer_size = 256M
max_allowed_packet = 16M
sort_buffer_size = 512K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
#thread_cache_size=1024
myisam_sort_buffer_size = 8M
memlock=0
skip_name_resolve
sysdate_is_now=1
max-connections=500
thread-cache-size=128
###QUERY CACHE IS DISABLED
###THE QUERY CACHE IN MYSQL CLUSTER CAN HAMPER PERFORMANCE A LOT. HENCE IT IS DISABLED
###BECAUSE INVALIDATION OF IT TAKES TIME (REMEMBER, IT IS A DISTRIBUTED ENVIRONMENT)
###ONLY ENABLE IT AND USE SQL_CACHE TO CACHE ONLY CERTAIN QUERIES ON READONLY TABLES
query_cache_type = 0
query_cache_size = 0
table_open_cache=1024
lower-case-table-names=0