MySQL部署

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

1、一般情况下,部署有三种常用的方式,第一种是yum的方式,也就是rpm包,第二种是源码的方式,也就是source code,第三种是二进制包,也就是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: 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的方法:

[root]# service mysql_4310 start
Starting MySQL.....The server quit without updating PID fil[FAILED]/mysql_4310/tmp/mysql.pid).

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

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

[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的配置文件,然后重新替换新的配置文件,重新启动:

[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

查看错误日志:

查看错误日志:
[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方法重新初始化,发现失败了。

[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表不存在,除此之外,还多了一行,如下:

[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参数,重新初始化,然后报错如下:

[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命令将其拷贝到指定目录,然后进行初始化,如下:

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

以上就是MySQL5.5 部署的一个问题的详细内容,更多关于MySQL 部署的资料请关注其它相关文章!

标签:
MySQL5.5,部署,mysql,部署

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com

评论“MySQL5.5 部署的一个问题”

暂无“MySQL5.5 部署的一个问题”评论...

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。