前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >MySQL5.5版本部署的一个问题

MySQL5.5版本部署的一个问题

作者头像
AsiaYe
发布2019-11-06 11:55:54
1.2K0
发布2019-11-06 11:55:54
举报
文章被收录于专栏:DBA随笔DBA随笔

MySQL5.5版本部署的一个问题

01

MySQL部署

目前公司部署MySQL是通过平台化操作的,周五的时候,平台暂时出了点儿问题,手上有个需求比较着急,就直接手动的部署了一下,由于好长时间没有部署环境了,竟然有些手生,这里把部署的步骤以及遇到的问题记录下来,希望对大家有所帮助。

1、一般情况下,部署有三种常用的方式,第一种是yum的方式,也就是rpm包,第二种是源码的方式,也就是source code,第三种是二进制包,也就是tar.gz格式的包,解压之后即可,我采用的是第三种方法,部署的MySQL版本是5.5.19版本。

2、首先来看下错误吧:

代码语言:javascript
复制
启动服务的语句:
/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld_safe --defaults=/data/mysql_4310/my.cnf &

 [Note] InnoDB: Waiting for purge to start
 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.7.16-10 started; log sequence number 0
 [Note] Plugin 'FEDERATED' is disabled.
20190621_11:25:41mysqld: Table 'mysql.plugin' doesn't exist
 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
 [ERROR] unknown variable 'thread_concurrency=8'
 [ERROR] Aborting

可以看到,一共报了两个错误,第一个是不能打开mysql.plugin这个表,第二个错误是参数错误,这个参数thread_concurrency无法识别。

对于第二个问题,可以确认是配置文件里面的参数问题,因为我使用的是常规的5.7的配置文件,改了几个参数,所以这个参数很有可能是漏改了,改掉即可。主要是第一个问题,这个时候,我进行了下面的尝试。

3、解决方式

尝试1:尝试重新启动

使用service mysql start的方法:

代码语言:javascript
复制
[root]# service mysql_4310 start
Starting MySQL.....The server quit without updating PID fil[FAILED]/mysql_4310/tmp/mysql.pid).

发现服务还是无法启动,错误日志的输出不变。

尝试2:看到了错误后面的提示,运行mysql_upgrade方法

代码语言:javascript
复制
[root bin]# ./mysql_upgrade --protocol=tcp -P4310 -p
Enter password: 
Looking for 'mysql' as: ./mysql
Looking for 'mysqlcheck' as: ./mysqlcheck
Running 'mysqlcheck' with connection arguments: '--protocol=tcp' '--port=4310' 
./mysqlcheck: Got error: 2003: Can't connect to MySQL server on 'localhost' (111) when trying to connect

看来还是不行,这个时候我严重怀疑是配置文件的问题:。

尝试3:从线上环境中搞来了一个mysql5.5的配置文件,然后重新替换新的配置文件,重新启动:

代码语言:javascript
复制
[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]# 190621 11:51:37 mysqld_safe Logging to '/data/mysql_4310/log/hb30_web_wechat_answers-121_246.err'.
190621 11:51:37 mysqld_safe Starting mysqld daemon with databases from /data/mysql_4310/data
190621 11:51:40 mysqld_safe mysqld from pid file /data/mysql_4310/tmp/mysql.pid ended

查看错误日志:

代码语言:javascript
复制
 查看错误日志:
[Note] Plugin 'FEDERATED' is disabled.
-5.5.19-linux2.6-x86_64/bin/mysqld: Unknown error 1146
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
InnoDB: Compressed tables use zlib 1.2.3
InnoDB: Using Linux native AIO
InnoDB: Initializing buffer pool, size = 4.0G
InnoDB: Completed initialization of buffer pool
t specified data file /data/mysql_4310/ibdata1 did not exist:
tabase to be created!
 InnoDB: Setting file /data/mysql_4310/ibdata1 size to 1000 MB
 physically writes the file full: wait...
 in MB: 100 200 300 400 500 600 700 800 900 1000
 InnoDB: Data file /data/mysql_4310/ibdata2 did not exist: new to be created
 InnoDB: Setting file /data/mysql_4310/ibdata2 size to 100 MB
 physically writes the file full: wait...
 in MB: 100
og file /data/mysql_4310/innodblog/ib_logfile0 is of different size 0 1073741824 bytes
cified in the .cnf file 0 134217728 bytes!
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[ERROR] Aborting

发现最先面出现了新的错误,提示Innodb 初始化函数返回了错误,无法使用innodb存储引擎。到这里,我开始怀疑是不是初始化的时候,就有错误,导致服务不可用,于是想着重新初始化一遍数据字典,重新起服务,看看行不行。

尝试4:重新初始化数据字典

尝试使用initialize-insecure方法重新初始化,发现失败了。

代码语言:javascript
复制
[root mysql_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]+  Exit 2      /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表不存在,除此之外,还多了一行,如下:

代码语言:javascript
复制
[ERROR] /usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld: unknown option '--initialize-insecure'

于是上官方文档上面查看了--initialize-insecure参数,发现这个参数在mysql5.5版本没有,然后5.5版本的是initialize参数,于是换成这个initialize参数,重新初始化,然后报错如下:

代码语言:javascript
复制
[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]+  Exit 2                  /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命令将其拷贝到指定目录,然后进行初始化,如下:

代码语言:javascript
复制
[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 | grep install
[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]# 
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqladmin -u root -h tk01-devt-mysql-7-200 password 'new-password'

Alternatively you can run:
/usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql-5.5.19-linux2.6-x86_64 ; /usr/local/mysql-5.5.19-linux2.6-x86_64/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql-5.5.19-linux2.6-x86_64/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql-5.5.19-linux2.6-x86_64/scripts/mysqlbug script!


[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参数

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-06-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 DBA随笔 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档