зеркало из https://github.com/github/vitess-gh.git
Various renames
This commit is contained in:
Родитель
88034dde67
Коммит
a2402fec64
|
@ -50,7 +50,7 @@ skip_slave_start
|
|||
slave_net_timeout = 60
|
||||
slow-query-log
|
||||
slow-query-log-file = {{.SlowLogPath}}
|
||||
socket = {{.SocketPath}}
|
||||
socket = {{.SocketFile}}
|
||||
sort_buffer_size = 2M
|
||||
table_cache = 2048
|
||||
thread_cache = 200
|
||||
|
|
|
@ -34,7 +34,7 @@ func main() {
|
|||
mycnf := mysqlctl.NewMycnf(uint(*tabletUid), *mysqlPort, *keyspace, vtRepl)
|
||||
dbaconfig := map[string]interface{}{
|
||||
"uname": "vt_dba",
|
||||
"unix_socket": mycnf.SocketPath,
|
||||
"unix_socket": mycnf.SocketFile,
|
||||
"pass": "",
|
||||
"dbname": "",
|
||||
"charset": "utf8",
|
||||
|
|
|
@ -34,7 +34,7 @@ var logLevel = flag.String("log.level", "debug", "set log level")
|
|||
var logFilename = flag.String("logfile", "/dev/stderr", "log path")
|
||||
|
||||
// FIXME(msolomon) temporary, until we are starting mysql ourselves
|
||||
var mycnfPath = flag.String("mycnf-path", "/etc/my.cnf", "path to my.cnf")
|
||||
var mycnfFile = flag.String("mycnf-file", "/etc/my.cnf", "path to my.cnf")
|
||||
|
||||
func init() {
|
||||
expvar.NewString("binary-name").Set("vtaction")
|
||||
|
@ -70,13 +70,13 @@ func main() {
|
|||
}
|
||||
}()
|
||||
|
||||
mycnf, mycnfErr := mysqlctl.ReadMycnf(*mycnfPath)
|
||||
mycnf, mycnfErr := mysqlctl.ReadMycnf(*mycnfFile)
|
||||
if mycnfErr != nil {
|
||||
relog.Fatal("mycnf read failed: %v", mycnfErr)
|
||||
}
|
||||
dbaconfig := map[string]interface{}{
|
||||
"uname": "vt_dba",
|
||||
"unix_socket": mycnf.SocketPath,
|
||||
"unix_socket": mycnf.SocketFile,
|
||||
"pass": "",
|
||||
"dbname": "",
|
||||
"charset": "utf8",
|
||||
|
|
|
@ -40,10 +40,10 @@ var (
|
|||
lameDuckPeriod = flag.Float64("lame-duck-period", DefaultLameDuckPeriod, "how long to give in-flight transactions to finish")
|
||||
rebindDelay = flag.Float64("rebind-delay", DefaultRebindDelay, "artificial delay before rebinding a hijacked listener")
|
||||
tabletPath = flag.String("tablet-path", "", "path to zk node representing the tablet")
|
||||
qsConfigFile = flag.String("qsconfig", "", "config file name for the query service")
|
||||
dbCredsFile = flag.String("dbcreds", "", "db connection credentials file")
|
||||
mycnfFile = flag.String("mycnf", "", "my.cnf file")
|
||||
queryLog = flag.String("querylog", "", "for testing: log all queries to this file")
|
||||
qsConfigFile = flag.String("queryserver-config-file", "", "config file name for the query service")
|
||||
dbCredsFile = flag.String("db-credentials-file", "", "db connection credentials file")
|
||||
mycnfFile = flag.String("mycnf-file", "", "my.cnf file")
|
||||
queryLog = flag.String("debug-querylog-file", "", "for testing: log all queries to this file")
|
||||
)
|
||||
|
||||
var qsConfig ts.Config = ts.Config{
|
||||
|
@ -127,7 +127,7 @@ func initAgent(dbcreds map[string]interface{}, mycnf *mysqlctl.Mycnf) {
|
|||
if _, ok := dbcreds["dba"]; ok {
|
||||
dbaconfig = dbcreds["dba"].(map[string]interface{})
|
||||
}
|
||||
dbaconfig["unix_socket"] = mycnf.SocketPath
|
||||
dbaconfig["unix_socket"] = mycnf.SocketFile
|
||||
mysqld := mysqlctl.NewMysqld(mycnf, dbaconfig)
|
||||
|
||||
// The TabletManager rpc service allow other processes to query for management
|
||||
|
@ -150,7 +150,7 @@ func initQueryService(dbcreds map[string]interface{}, mycnf *mysqlctl.Mycnf) {
|
|||
return
|
||||
}
|
||||
appconfig := dbcreds["app"].(map[string]interface{})
|
||||
appconfig["unix_socket"] = mycnf.SocketPath
|
||||
appconfig["unix_socket"] = mycnf.SocketFile
|
||||
if *queryLog != "" {
|
||||
if f, err := os.OpenFile(*queryLog, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644); err == nil {
|
||||
ts.QueryLogger = relog.New(f, "", log.Ldate|log.Lmicroseconds, relog.DEBUG)
|
||||
|
|
|
@ -33,11 +33,11 @@ type Mycnf struct {
|
|||
ServerId uint
|
||||
TabletDir string
|
||||
DataDir string
|
||||
MycnfPath string
|
||||
MycnfFile string
|
||||
InnodbDataHomeDir string
|
||||
InnodbLogGroupHomeDir string
|
||||
DatabaseName string // for replication
|
||||
SocketPath string
|
||||
SocketFile string
|
||||
MysqlPort int
|
||||
VtHost string
|
||||
VtPort int
|
||||
|
@ -59,10 +59,10 @@ func NewMycnf(uid uint, mysqlPort int, keyspace string, vtRepl VtReplParams) *My
|
|||
cnf.MysqlPort = mysqlPort
|
||||
cnf.TabletDir = fmt.Sprintf("/vt/vt_%010d", uid)
|
||||
cnf.DataDir = path.Join(cnf.TabletDir, "data")
|
||||
cnf.MycnfPath = path.Join(cnf.TabletDir, "my.cnf")
|
||||
cnf.MycnfFile = path.Join(cnf.TabletDir, "my.cnf")
|
||||
cnf.InnodbDataHomeDir = path.Join(cnf.TabletDir, innodbDataSubdir)
|
||||
cnf.InnodbLogGroupHomeDir = path.Join(cnf.TabletDir, innodbLogSubdir)
|
||||
cnf.SocketPath = path.Join(cnf.TabletDir, "mysql.sock")
|
||||
cnf.SocketFile = path.Join(cnf.TabletDir, "mysql.sock")
|
||||
// this might be empty if you aren't assigned to a keyspace
|
||||
cnf.DatabaseName = keyspace
|
||||
cnf.VtHost = vtRepl.TabletHost
|
||||
|
@ -144,13 +144,13 @@ func (cnf *Mycnf) MysqlAddr() string {
|
|||
/*
|
||||
Join cnf files cnfPaths and subsitute in the right values.
|
||||
*/
|
||||
func MakeMycnf(cnfPaths []string, mycnf *Mycnf, header string) (string, error) {
|
||||
func MakeMycnf(cnfFiles []string, mycnf *Mycnf, header string) (string, error) {
|
||||
myTemplateSource := new(bytes.Buffer)
|
||||
for _, line := range strings.Split(header, "\n") {
|
||||
fmt.Fprintf(myTemplateSource, "## %v\n", strings.TrimSpace(line))
|
||||
}
|
||||
myTemplateSource.WriteString("[mysqld]\n")
|
||||
for _, path := range cnfPaths {
|
||||
for _, path := range cnfFiles {
|
||||
data, dataErr := ioutil.ReadFile(path)
|
||||
if dataErr != nil {
|
||||
return "", dataErr
|
||||
|
@ -171,29 +171,29 @@ func MakeMycnf(cnfPaths []string, mycnf *Mycnf, header string) (string, error) {
|
|||
return mycnfData.String(), nil
|
||||
}
|
||||
|
||||
/* Create a config for this instance. Search cnfPath for the appropriate
|
||||
/* Create a config for this instance. Search cnfFiles for the appropriate
|
||||
cnf template files.
|
||||
*/
|
||||
func MakeMycnfForMysqld(mysqld *Mysqld, cnfPath, header string) (string, error) {
|
||||
func MakeMycnfForMysqld(mysqld *Mysqld, cnfFiles, header string) (string, error) {
|
||||
// FIXME(msolomon) determine config list from mysqld struct
|
||||
cnfs := []string{"default", "master", "replica"}
|
||||
paths := make([]string, len(cnfs))
|
||||
for i, name := range cnfs {
|
||||
paths[i] = fmt.Sprintf("%v/%v.cnf", cnfPath, name)
|
||||
paths[i] = fmt.Sprintf("%v/%v.cnf", cnfFiles, name)
|
||||
}
|
||||
return MakeMycnf(paths, mysqld.config, header)
|
||||
}
|
||||
|
||||
func ReadMycnf(cnfPath string) (*Mycnf, error) {
|
||||
f, err := os.Open(cnfPath)
|
||||
func ReadMycnf(cnfFile string) (*Mycnf, error) {
|
||||
f, err := os.Open(cnfFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
buf := bufio.NewReader(f)
|
||||
mycnf := &Mycnf{SocketPath: "/var/lib/mysql/mysql.sock",
|
||||
MycnfPath: cnfPath,
|
||||
mycnf := &Mycnf{SocketFile: "/var/lib/mysql/mysql.sock",
|
||||
MycnfFile: cnfFile,
|
||||
// FIXME(msolomon) remove this whole method, just asking for trouble
|
||||
VtHost: "localhost",
|
||||
VtPort: 6612,
|
||||
|
@ -221,7 +221,7 @@ func ReadMycnf(cnfPath string) (*Mycnf, error) {
|
|||
} else if bytes.HasPrefix(line, []byte("innodb_data_home_dir")) {
|
||||
mycnf.InnodbDataHomeDir = string(bytes.TrimSpace(bytes.Split(line, []byte("="))[1]))
|
||||
} else if bytes.HasPrefix(line, []byte("socket")) {
|
||||
mycnf.SocketPath = string(bytes.TrimSpace(bytes.Split(line, []byte("="))[1]))
|
||||
mycnf.SocketFile = string(bytes.TrimSpace(bytes.Split(line, []byte("="))[1]))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ func Start(mt *Mysqld) error {
|
|||
dir := os.ExpandEnv("$VTROOT/dist/vt-mysql")
|
||||
name := dir + "/bin/mysqld_safe"
|
||||
arg := []string{
|
||||
"--defaults-file=" + mt.config.MycnfPath}
|
||||
"--defaults-file=" + mt.config.MycnfFile}
|
||||
env := []string{
|
||||
os.ExpandEnv("LD_LIBRARY_PATH=$VTROOT/dist/vt-mysql/lib/mysql"),
|
||||
}
|
||||
|
@ -73,14 +73,14 @@ func Start(mt *Mysqld) error {
|
|||
// we are in good shape
|
||||
for i := 0; i < MysqlWaitTime; i++ {
|
||||
time.Sleep(1e9)
|
||||
_, statErr := os.Stat(mt.config.SocketPath)
|
||||
_, statErr := os.Stat(mt.config.SocketFile)
|
||||
if statErr == nil {
|
||||
return nil
|
||||
} else if statErr.(*os.PathError).Err != syscall.ENOENT {
|
||||
return statErr
|
||||
}
|
||||
}
|
||||
return errors.New(name + ": deadline exceeded waiting for " + mt.config.SocketPath)
|
||||
return errors.New(name + ": deadline exceeded waiting for " + mt.config.SocketFile)
|
||||
}
|
||||
|
||||
/* waitForMysqld: should the function block until mysqld has stopped?
|
||||
|
@ -90,7 +90,7 @@ flushed - on the order of 20-30 minutes.
|
|||
func Shutdown(mt *Mysqld, waitForMysqld bool) error {
|
||||
relog.Info("mysqlctl.Shutdown")
|
||||
// possibly mysql is already shutdown, check for a few files first
|
||||
_, socketPathErr := os.Stat(mt.config.SocketPath)
|
||||
_, socketPathErr := os.Stat(mt.config.SocketFile)
|
||||
_, pidPathErr := os.Stat(mt.config.PidFile())
|
||||
if socketPathErr != nil && pidPathErr != nil {
|
||||
relog.Warning("assuming shutdown - no socket, no pid file")
|
||||
|
@ -100,7 +100,7 @@ func Shutdown(mt *Mysqld, waitForMysqld bool) error {
|
|||
dir := os.ExpandEnv("$VTROOT/dist/vt-mysql")
|
||||
name := dir + "/bin/mysqladmin"
|
||||
arg := []string{
|
||||
"-u", "vt_dba", "-S", mt.config.SocketPath,
|
||||
"-u", "vt_dba", "-S", mt.config.SocketFile,
|
||||
"shutdown"}
|
||||
env := []string{
|
||||
os.ExpandEnv("LD_LIBRARY_PATH=$VTROOT/dist/vt-mysql/lib/mysql"),
|
||||
|
@ -114,7 +114,7 @@ func Shutdown(mt *Mysqld, waitForMysqld bool) error {
|
|||
// we can't call wait() in a process we didn't start.
|
||||
if waitForMysqld {
|
||||
for i := 0; i < MysqlWaitTime; i++ {
|
||||
_, statErr := os.Stat(mt.config.SocketPath)
|
||||
_, statErr := os.Stat(mt.config.SocketFile)
|
||||
// NOTE: dreaded PathError :(
|
||||
if statErr != nil && statErr.(*os.PathError).Err == syscall.ENOENT {
|
||||
return nil
|
||||
|
@ -154,10 +154,10 @@ func Init(mt *Mysqld) error {
|
|||
cnfTemplatePath := os.ExpandEnv("$VTROOT/src/code.google.com/p/vitess/config/mycnf")
|
||||
configData, err := MakeMycnfForMysqld(mt, cnfTemplatePath, "tablet uid?")
|
||||
if err == nil {
|
||||
err = ioutil.WriteFile(mt.config.MycnfPath, []byte(configData), 0664)
|
||||
err = ioutil.WriteFile(mt.config.MycnfFile, []byte(configData), 0664)
|
||||
}
|
||||
if err != nil {
|
||||
relog.Error("failed creating %v: %v", mt.config.MycnfPath, err)
|
||||
relog.Error("failed creating %v: %v", mt.config.MycnfFile, err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ type ActionAgent struct {
|
|||
zconn zk.Conn
|
||||
zkTabletPath string // FIXME(msolomon) use tabletInfo
|
||||
zkActionPath string
|
||||
vtActionBinPath string // path to vtaction binary
|
||||
MycnfPath string // path to my.cnf file
|
||||
vtActionBinFile string // path to vtaction binary
|
||||
MycnfFile string // path to my.cnf file
|
||||
|
||||
mutex sync.Mutex
|
||||
_tablet *TabletInfo // must be accessed with lock - TabletInfo objects are not synchronized.
|
||||
|
@ -48,7 +48,7 @@ type ActionAgent struct {
|
|||
// bindAddr: the address for the query service advertised by this agent
|
||||
func NewActionAgent(zconn zk.Conn, zkTabletPath, mycnfPath string) *ActionAgent {
|
||||
actionPath := TabletActionPath(zkTabletPath)
|
||||
return &ActionAgent{zconn: zconn, zkTabletPath: zkTabletPath, zkActionPath: actionPath, MycnfPath: mycnfPath}
|
||||
return &ActionAgent{zconn: zconn, zkTabletPath: zkTabletPath, zkActionPath: actionPath, MycnfFile: mycnfPath}
|
||||
}
|
||||
|
||||
func (agent *ActionAgent) readTablet() error {
|
||||
|
@ -77,24 +77,24 @@ func (agent *ActionAgent) resolvePaths() error {
|
|||
"/usr/local/bin/vtaction"}
|
||||
for _, path := range vtActionBinPaths {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
agent.vtActionBinPath = path
|
||||
agent.vtActionBinFile = path
|
||||
break
|
||||
}
|
||||
}
|
||||
if agent.vtActionBinPath == "" {
|
||||
if agent.vtActionBinFile == "" {
|
||||
return errors.New("no vtaction binary found")
|
||||
}
|
||||
|
||||
/* FIXME: Delete commented out code
|
||||
mycnfPaths := []string{fmt.Sprintf("/vt/vt_%010d/my.cnf", agent.Tablet().Uid),
|
||||
mycnfFile := []string{fmt.Sprintf("/vt/vt_%010d/my.cnf", agent.Tablet().Uid),
|
||||
"/var/lib/mysql/my.cnf", "/etc/my.cnf"}
|
||||
for _, path := range mycnfPaths {
|
||||
for _, path := range mycnfFile {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
agent.MycnfPath = path
|
||||
agent.MycnfFile = path
|
||||
break
|
||||
}
|
||||
}
|
||||
if agent.MycnfPath == "" {
|
||||
if agent.MycnfFile == "" {
|
||||
return errors.New("no my.cnf found")
|
||||
}*/
|
||||
return nil
|
||||
|
@ -119,12 +119,12 @@ func (agent *ActionAgent) dispatchAction(actionPath string) {
|
|||
logfile = path.Join(path.Dir(logfile), "vtaction.log")
|
||||
}
|
||||
cmd := []string{
|
||||
agent.vtActionBinPath,
|
||||
agent.vtActionBinFile,
|
||||
"-action", actionNode.Action,
|
||||
"-action-node", actionPath,
|
||||
"-action-guid", actionNode.ActionGuid,
|
||||
"-mycnf-path", agent.MycnfPath,
|
||||
"-logfile", logfile,
|
||||
"-mycnf-file", agent.MycnfFile,
|
||||
"-logfile", flag.Lookup("logfile").Value.String(),
|
||||
}
|
||||
relog.Info("action launch %v", cmd)
|
||||
vtActionCmd := exec.Command(cmd[0], cmd[1:]...)
|
||||
|
|
Загрузка…
Ссылка в новой задаче