MySQL5.5 部署的一个问题
MySQL部署
目前公司部署MySQL是通过平台化操作的,周五的时候,平台暂时出了点儿问题,手上有个需求比较着急,就直接手动的部署了一下,由于好长时间没有部署环境了,竟然有些手生,这里把部署的步骤以及遇到的问题记录下来,希望对大家有所帮助。
1、一般情况下,部署有三种常用的方式,第一种是yum的方式,也就是rpm包,第二种是源码的方式,也就是sourcecode,第三种是二进制包,也就是tar.gz格式的包,解压之后即可,我采用的是第三种方法,部署的MySQL版本是5.5.19版本。
2、首先来看下错误吧:
启动服务的语句: /usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld_safe--defaults=/data/mysql_4310/my.cnf& [Note]InnoDB:Waitingforpurgetostart [Note]InnoDB:PerconaXtraDB(http://www.percona.com)5.7.16-10started;logsequencenumber0 [Note]Plugin'FEDERATED'isdisabled. 20190621_11:25:41mysqld:Table'mysql.plugin'doesn'texist [ERROR]Can'topenthemysql.plugintable.Pleaserunmysql_upgradetocreateit. [ERROR]unknownvariable'thread_concurrency=8' [ERROR]Aborting
可以看到,一共报了两个错误,第一个是不能打开mysql.plugin这个表,第二个错误是参数错误,这个参数thread_concurrency无法识别。
对于第二个问题,可以确认是配置文件里面的参数问题,因为我使用的是常规的5.7的配置文件,改了几个参数,所以这个参数很有可能是漏改了,改掉即可。主要是第一个问题,这个时候,我进行了下面的尝试。
3、解决方式
尝试1:尝试重新启动
使用servicemysqlstart的方法:
[root]#servicemysql_4310start StartingMySQL.....TheserverquitwithoutupdatingPIDfil[FAILED]/mysql_4310/tmp/mysql.pid).
发现服务还是无法启动,错误日志的输出不变。
尝试2:看到了错误后面的提示,运行mysql_upgrade方法
[rootbin]#./mysql_upgrade--protocol=tcp-P4310-p Enterpassword: Lookingfor'mysql'as:./mysql Lookingfor'mysqlcheck'as:./mysqlcheck Running'mysqlcheck'withconnectionarguments:'--protocol=tcp''--port=4310' ./mysqlcheck:Goterror:2003:Can'tconnecttoMySQLserveron'localhost'(111)whentryingtoconnect
看来还是不行,这个时候我严重怀疑是配置文件的问题:。
尝试3:从线上环境中搞来了一个mysql5.5的配置文件,然后重新替换新的配置文件,重新启动:
[root@mysql_4310]#/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld_safe--defaults-file=/data/mysql_4310/my.cnf& [1]63529 [root@mysql_4310]#19062111:51:37mysqld_safeLoggingto'/data/mysql_4310/log/hb30_web_wechat_answers-121_246.err'. 19062111:51:37mysqld_safeStartingmysqlddaemonwithdatabasesfrom/data/mysql_4310/data 19062111:51:40mysqld_safemysqldfrompidfile/data/mysql_4310/tmp/mysql.pidended
查看错误日志:
查看错误日志: [Note]Plugin'FEDERATED'isdisabled. -5.5.19-linux2.6-x86_64/bin/mysqld:Unknownerror1146 [ERROR]Can'topenthemysql.plugintable.Pleaserunmysql_upgradetocreateit. InnoDB:TheInnoDBmemoryheapisdisabled InnoDB:Mutexesandrw_locksuseGCCatomicbuiltins InnoDB:Compressedtablesusezlib1.2.3 InnoDB:UsingLinuxnativeAIO InnoDB:Initializingbufferpool,size=4.0G InnoDB:Completedinitializationofbufferpool tspecifieddatafile/data/mysql_4310/ibdata1didnotexist: tabasetobecreated! InnoDB:Settingfile/data/mysql_4310/ibdata1sizeto1000MB physicallywritesthefilefull:wait... inMB:1002003004005006007008009001000 InnoDB:Datafile/data/mysql_4310/ibdata2didnotexist:newtobecreated InnoDB:Settingfile/data/mysql_4310/ibdata2sizeto100MB physicallywritesthefilefull:wait... inMB:100 ogfile/data/mysql_4310/innodblog/ib_logfile0isofdifferentsize01073741824bytes cifiedinthe.cnffile0134217728bytes! [ERROR]Plugin'InnoDB'initfunctionreturnederror. [ERROR]Plugin'InnoDB'registrationasaSTORAGEENGINEfailed. [ERROR]Aborting
发现最先面出现了新的错误,提示Innodb初始化函数返回了错误,无法使用innodb存储引擎。到这里,我开始怀疑是不是初始化的时候,就有错误,导致服务不可用,于是想着重新初始化一遍数据字典,重新起服务,看看行不行。
尝试4:重新初始化数据字典
尝试使用initialize-insecure方法重新初始化,发现失败了。
[rootmysql_4310]#/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld --initialize-insecure --defaults-file=/data/mysql_4310/my.cnf --datadir=/data/mysql_4310/data --basedir=/usr/local/mysql-5.5.19-linux2.6-x86_64& [1]7045 [1]+Exit2/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld --initialize-insecure --defaults-file=/data/mysql_4310/my.cnf --datadir=/data/mysql_4310/data --basedir=/usr/local/mysql-5.5.19-linux2.6-x86_64
错误日志还是之前的日志,提示mysql.plugin表不存在,除此之外,还多了一行,如下:
[ERROR]/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld:unknownoption'--initialize-insecure'
于是上官方文档上面查看了--initialize-insecure参数,发现这个参数在mysql5.5版本没有,然后5.5版本的是initialize参数,于是换成这个initialize参数,重新初始化,然后报错如下:
[root@]/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld--defaults-file=/data/mysql_4310/my.cnf--datadir=/data/mysql_4310/data--basedir=/usr/local/mysql-5.5.19-linux2.6-x86_64--initialize& [1]+Exit2/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld--defaults-file=/data/mysql_4310/my.cnf--datadir=/data/mysql_4310/data--basedir=/usr/local/mysql-5.5.19-linux2.6-x86_64--initialize
此时,查看官方文档,发现MySQL5.5版本的初始化使用的是mysql_install_db命令而不是mysqld命令,而mysql_install_db这个工具不在/usr/local/mysql-5.5.19-linux2.6-x86_64/bin目录中,而在/usr/local/mysql-5.5.19-linux2.6-x86_64/scripts目录下面,于是通过cp命令将其拷贝到指定目录,然后进行初始化,如下:
[root@mysql_4310]#/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysql_install_db --defaults-file=/data/mysql_4310/my.cnf [root@mysql_4310]#ll|grepinstall [root@mysql_4310]#/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysql_install_db --defaults-file=/data/mysql_4310/my.cnf --datadir=/data/mysql_4310/data --basedir=/usr/local/mysql-5.5.19-linu [1]16365 [root@mysql_4310]# InstallingMySQLsystemtables... OK Fillinghelptables... OK Tostartmysqldatboottimeyouhavetocopy support-files/mysql.servertotherightplaceforyoursystem PLEASEREMEMBERTOSETAPASSWORDFORTHEMySQLrootUSER! Todoso,starttheserver,thenissuethefollowingcommands: /usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqladmin-urootpassword'new-password' /usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqladmin-uroot-htk01-devt-mysql-7-200password'new-password' Alternativelyyoucanrun: /usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysql_secure_installation whichwillalsogiveyoutheoptionofremovingthetest databasesandanonymoususercreatedbydefault.Thisis stronglyrecommendedforproductionservers. Seethemanualformoreinstructions. YoucanstarttheMySQLdaemonwith: cd/usr/local/mysql-5.5.19-linux2.6-x86_64;/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld_safe& YoucantesttheMySQLdaemonwithmysql-test-run.pl cd/usr/local/mysql-5.5.19-linux2.6-x86_64/mysql-test;perlmysql-test-run.pl Pleasereportanyproblemswiththe/usr/local/mysql-5.5.19-linux2.6-x86_64/scripts/mysqlbugscript! [1]+Done/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysql_install_db--defaults-file=/data/mysql_4310/my.cnf--datadir=/data/mysql_4310/data--basedir=/usr/local/mysql-5.5.19-linux2.6-x86_64
结果成功。
总结如下:
1、MySQL5.5版本的初始化使用mysql_install_db工具,而不是mysqld工具
2、MySQL5.5版本的初始化使用--initialize参数
以上就是MySQL5.5部署的一个问题的详细内容,更多关于MySQL部署的资料请关注毛票票其它相关文章!