@@ -177,7 +177,7 @@ func (i *InstallMySQLComp) InitDefaultParam() (err error) {
177177 i .InsPorts = i .Params .Ports
178178 i .MyCnfTpls = make (map [int ]* util.CnfFile )
179179 // 获取系统内存,计算实例内存大小
180- if err : = i .initMySQLInstanceMem (); err != nil {
180+ if err = i .initMySQLInstanceMem (); err != nil {
181181 return err
182182 }
183183 // var findMountPoint func(paths ...string) (string, error)
@@ -239,10 +239,10 @@ func (i *InstallMySQLComp) InitDefaultParam() (err error) {
239239 logger .Error ("反序列%d 化配置失败:%s" , port , err .Error ())
240240 return err
241241 }
242- cnftpl , err := util .NewMyCnfObject (mycnf , "tpl" )
243- if err != nil {
244- logger .Error ("初始化mycnf ini 模版:%s" , err .Error ())
245- return err
242+ cnftpl , ierr := util .NewMyCnfObject (mycnf , "tpl" )
243+ if ierr != nil {
244+ logger .Error ("初始化mycnf ini 模版:%s" , ierr .Error ())
245+ return ierr
246246 }
247247 i .MyCnfTpls [port ] = cnftpl
248248 }
@@ -266,10 +266,6 @@ func (i *InstallMySQLComp) InitDefaultParam() (err error) {
266266 i .Checkfunc = append (i .Checkfunc , i .precheckMysqlPackageBitOS )
267267 i .Checkfunc = append (i .Checkfunc , i .precheckGlibcVersion )
268268 i .Checkfunc = append (i .Checkfunc , i .Params .Medium .Check )
269- i .Params .PartitionYWAccount .AccessHosts = []string {
270- i .Params .Host ,
271- "localhost" ,
272- }
273269 return nil
274270}
275271
@@ -448,11 +444,11 @@ func (i *InstallMySQLComp) getInitDirFromCnf() (err error) {
448444 "socket" : "" ,
449445 }
450446 for _ , port := range i .InsPorts {
451- cnf , err := util .LoadMyCnfForFile (util .GetMyCnfFileName (port ))
452- if err != nil {
453- return err
447+ cnf , ierr := util .LoadMyCnfForFile (util .GetMyCnfFileName (port ))
448+ if ierr != nil {
449+ return ierr
454450 }
455- if err : = cnf .GetInitDirItemTpl (initDirTpls ); err != nil {
451+ if err = cnf .GetInitDirItemTpl (initDirTpls ); err != nil {
456452 return err
457453 }
458454 for key , dir := range initDirTpls {
@@ -514,7 +510,7 @@ func (i *InstallMySQLComp) generateMycnfOnePort(port Port, tmplFileName string)
514510 _ = f .Close ()
515511 }()
516512
517- if err : = tmpl .Execute (f , i .RenderConfigs [port ]); err != nil {
513+ if err = tmpl .Execute (f , i .RenderConfigs [port ]); err != nil {
518514 return err
519515 }
520516 if _ , err = osutil .ExecShellCommand (false , fmt .Sprintf ("chown -R mysql %s" , cnf )); err != nil {
@@ -573,9 +569,9 @@ func (i *InstallMySQLComp) DecompressMysqlPkg() (err error) {
573569 }
574570 }
575571 pkgAbPath := i .Params .Medium .GetAbsolutePath ()
576- if output , err := osutil .ExecShellCommand (false , fmt .Sprintf ("tar -xf %s" , pkgAbPath )); err != nil {
577- logger .Error ("tar -xf %s error:%s,%s" , pkgAbPath , output , err .Error ())
578- return err
572+ if output , ierr := osutil .ExecShellCommand (false , fmt .Sprintf ("tar -xf %s" , pkgAbPath )); ierr != nil {
573+ logger .Error ("tar -xf %s error:%s,%s" , pkgAbPath , output , ierr .Error ())
574+ return ierr
579575 }
580576 mysqlBinaryFile := i .Params .Medium .GePkgBaseName ()
581577 extraCmd := fmt .Sprintf ("ln -sf %s %s && chown -R mysql mysql*" , mysqlBinaryFile , i .MysqlInstallDir )
@@ -710,6 +706,10 @@ func (i *InstallMySQLComp) Startup() (err error) {
710706注意这里修改,考虑可能需要同步改动 generateDefaultSpiderAccount
711707*/
712708func (i * InstallMySQLComp ) generateDefaultMysqlAccount (realVersion string ) (initAccountsql []string ) {
709+ i .Params .PartitionYWAccount .AccessHosts = []string {
710+ i .Params .Host ,
711+ "localhost" ,
712+ }
713713 initAccountsql = append (initAccountsql , i .Params .SuperAccount .GetSuperUserAccount (realVersion )... )
714714 initAccountsql = append (initAccountsql , i .Params .DBHAAccount .GetDBHAAccount (realVersion )... )
715715 initAccountsql = append (initAccountsql , i .Params .WEBCONSOLERSAccount .GetWEBCONSOLERSAccount (realVersion )... )
@@ -748,7 +748,7 @@ VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y
748748 initAccountsql = append (initAccountsql , "delete from mysql.user where user='root' or user='';" )
749749 initAccountsql = append (initAccountsql , "update mysql.db set Insert_priv = 'Y' where db = 'test';" )
750750 initAccountsql = append (initAccountsql , "flush privileges;" )
751- return
751+ return initAccountsql
752752}
753753
754754// AdditionalAccount 额外账户
@@ -808,7 +808,7 @@ func (a *AdditionalAccount) GetPartitionYWAccount(realVersion string) (initAccou
808808 )
809809 }
810810 }
811- return
811+ return initAccountsql
812812}
813813
814814// GetWEBCONSOLERSAccount 获取webconsole账户授权语句
@@ -840,8 +840,7 @@ func (a *AdditionalAccount) GetWEBCONSOLERSAccount(realVersion string) (initAcco
840840 return
841841}
842842
843- // GetDBHAAccount TODO
844- // 获取生成DHBA-GM访问账号的生成语句
843+ // GetDBHAAccount 获取生成DHBA-GM访问账号的生成语句
845844// 统一给%授权
846845func (a * AdditionalAccount ) GetDBHAAccount (realVersion string ) (initAccountsql []string ) {
847846 if cmutil .MySQLVersionParse (realVersion ) >= cmutil .MySQLVersionParse ("5.7.18" ) {
@@ -1052,12 +1051,12 @@ func (i *InstallMySQLComp) DecompressTdbctlPkg() (err error) {
10521051 }
10531052
10541053 pkgAbPath := i .Params .Medium .GetAbsolutePath ()
1055- if output , err := osutil .ExecShellCommand (
1054+ if output , ierr := osutil .ExecShellCommand (
10561055 false ,
10571056 fmt .Sprintf ("mkdir %s && tar -xf %s -C %s --strip-components 1 " , tdbctlBinaryFile , pkgAbPath ,
1058- tdbctlBinaryFile )); err != nil {
1059- logger .Error ("tar -xf %s error:%s,%s" , pkgAbPath , output , err .Error ())
1060- return err
1057+ tdbctlBinaryFile )); ierr != nil {
1058+ logger .Error ("tar -xf %s error:%s,%s" , pkgAbPath , output , ierr .Error ())
1059+ return ierr
10611060 }
10621061
10631062 extraCmd := fmt .Sprintf ("ln -sf %s %s && chown -R mysql mysql*" , tdbctlBinaryFile , i .TdbctlInstallDir )
@@ -1182,8 +1181,7 @@ func (i *InstallMySQLComp) getSuperUserAccountForSpider() (initAccountsql []stri
11821181 ),
11831182 )
11841183 }
1185-
1186- return
1184+ return initAccountsql
11871185}
11881186
11891187func (i * InstallMySQLComp ) createSpiderTable (socket string ) (err error ) {
0 commit comments