linux 安装MySQL多实例

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

环境:centos6.5

MySQL:mysql-5.5.57-winx64.zip 二进制安装包  可以直接进mysql官网下载即可

https://cdn.mysql.com//Downloads/MySQL-5.5/mysql-5.5.58-winx64.zip



mysql_install_db说明

当MySQL的系统库(mysql系统库)发生故障或需要新加一个mysql实例时,需要初始化mysql数据库。

需要使用的命令:/usr/local/mysql/bin/mysql_install_db

#/usr/local/mysql/bin/mysql_install_db --help 可以查看帮助信息如下

Usage: /usr/local/mysql/bin/mysql_install_db [OPTIONS]

  --basedir=path       The path to the MySQL installation directory.

  --cross-bootstrap    For internal use.  Used when building the MySQL system

                       tables on a different host than the target.

  --datadir=path       The path to the MySQL data directory.

  --force              Causes mysql_install_db to run even if DNS does not

                       work.  In that case, grant table entries that normally

                       use hostnames will use IP addresses.

  --ldata=path         The path to the MySQL data directory.

  --rpm                For internal use.  This option is used by RPM files

                       during the MySQL installation process.

  --skip-name-resolve  Use IP addresses rather than hostnames when creating

                       grant table entries.  This option can be useful if

                       your DNS does not work.

  --srcdir=path        For internal use.  The directory under which

                       mysql_install_db looks for support files such as the

                       error message file and the file for popoulating the

                       help tables.

  --user=user_name     The login username to use for running mysqld.  Files

                       and directories created by mysqld will be owned by this

                       user.  You must be root to use this option.  By default

                       mysqld runs using your current login name and files and

                       directories that it creates will be owned by you.

All other options are passed to the mysqld program

除了支持以上的参数,还支持mysqld的参数。

二、举例:

   本文以新加一个mysql实例为例。例如服务器上已经安装了3306端口的mysql服务,需要再启一个3308端口的mysql服务。

   假设mysql安装在/usr/local/mysql路径下,找一个磁盘空间剩余比较大的盘,如/data,把3308端口的mysql的数据保存在/data1下

#mkdir /data/mysql_3308

#mkdir /data/mysql_3308/data

#chown -R mysql:mysql /data/mysql_3308

 

   复制一个mysql配置文件my.cnf到/data1/mysql_3308目录下

#vi /data1/mysql_3308/my.cnf

修改配置文件,将端口和相关目录的都改为新的设置,如下:

[client]

character-set-server = utf8

port    = 3308

socket  = /tmp/mysql_3308.sock

[mysqld]

user    = mysql

port    = 3308

socket  = /tmp/mysql_3308.sock

basedir = /usr

datadir = /data/mysql_3308/data

log-error = /data/mysql_3308/mysql_error.log

pid-file = /data/mysql_3308/mysql.pid

......其他略

  确保配置文件无误。

运行下面命令进行数据库的初始化:

#/usr/bin/mysql_install_db --defaults-file=/data/mysql_3308/my.cnf --datadir=/data/mysql_3308/data

完成后新的3308数据库就初始化好了,如果有报错,则按照报错的提示查看报错日志,一般情况下都是my.cnf配置文件的问题,修正后即可。

三、启动新mysql

启动3308端口的mysql服务

#/usr/bin/mysqld_safe --defaults-file=/data/mysql_3308/my.cnf &

检查是否启动

[root@Test2 data]# /usr/bin/mysqld_safe --defaults-file=/data/mysql_3308/my.cnf &

[1] 7221

[root@Test2 data]# 171031 16:49:56 mysqld_safe Logging to '/data/mysql_3308/mysql_error.log'.

171031 16:49:56 mysqld_safe Starting mysqld daemon with databases from /data/mysql_3308/data

171031 16:49:56 mysqld_safe WSREP: Running position recovery with --log_error='/data/mysql_3308/data/wsrep_recovery.z7ccsq' --pid-file='/data/mysql_3308/data/Test2-recover.pid'

171031 16:49:56 mysqld_safe WSREP: Failed to recover position: '171031 16:49:56 [Note] InnoDB: Using mutexes to ref count buffer pool pages

171031 16:49:56 [Note] InnoDB: The InnoDB memory heap is disabled

171031 16:49:56 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

171031 16:49:56 [Note] InnoDB: Memory barrier is not used

171031 16:49:56 [Note] InnoDB: Compressed tables use zlib 1.2.3

171031 16:49:56 [Note] InnoDB: Using Linux native AIO

171031 16:49:56 [Note] InnoDB: Using CPU crc32 instructions

171031 16:49:56 [Note] InnoDB: Initializing buffer pool, size = 6.0G

171031 16:49:56 [Note] InnoDB: Completed initialization of buffer pool

171031 16:49:56 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode

171031 16:49:56 [ERROR] InnoDB: The system tablespace must be writable!

171031 16:49:56 [ERROR] Plugin 'InnoDB' init function returned error.

171031 16:49:56 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

171031 16:49:56 [ERROR] mysqld: File '/data/mysql_3308/data/aria_log_control' not found (Errcode: 13 "Permission denied")

171031 16:49:56 [ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/data/mysql_3308/data/aria_log_control'

171031 16:49:56 [ERROR] Plugin 'Aria' init function returned error.

171031 16:49:56 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.

171031 16:49:56 [Note] Plugin 'FEEDBACK' is disabled.

171031 16:49:56 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

171031 16:49:56 [ERROR] Unknown/unsupported storage engine: InnoDB

171031 16:49:56 [ERROR] Aborting

171031 16:49:56 [Note] /usr/sbin/mysqld: Shutdown complete'

[1]+  Exit 1                  /usr/bin/mysqld_safe --defaults-file=/data/mysql_3308/my.cnf

解决方法:

[root@Test2 /]# chown -R mysql.mysql /data/

[root@Test2 /]# /usr/bin/mysqld_safe --defaults-file=/data/mysql_3308/my.cnf &

[1] 7371

[root@Test2 /]# 171031 16:52:06 mysqld_safe Logging to '/data/mysql_3308/mysql_error.log'.

171031 16:52:06 mysqld_safe Starting mysqld daemon with databases from /data/mysql_3308/data

171031 16:52:06 mysqld_safe WSREP: Running position recovery with --log_error='/data/mysql_3308/data/wsrep_recovery.EwYBM2' --pid-file='/data/mysql_3308/data/Test2-recover.pid'

171031 16:52:10 mysqld_safe WSREP: Recovered position 00000000-0000-0000-0000-000000000000:-1

#ps aux|grep mysql

如果有3308字样说明已经启动成功

可将启动命令加入/etc/rc.local随服务器启动

新加的mysql没有设置root密码,可以通过下面命令设置root密码:

#/usr/bin/mysqladmin -S /tmp/mysql_3308.sock -u root password 'root'

关闭多实例数据库:

[root@localhost mysql_3308]# mysqladmin  -uroot -p -S /tmp/mysql_3308.sock shutdown

Enter password:

启动多实例数据库:

/usr/bin/mysqld_safe --defaults-file=/data/mysql_3308/my.cnf &



本文转自 Barron1 51CTO博客,原文链接:http://blog.51cto.com/13172370/1981883,如需转载请自行联系原作者

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
265
分享
相关文章
零基础保姆级教程!手把手教你免费玩转Linux CentOS安装+学习环境搭建(附避坑指南)
本文详细介绍了在VMware虚拟机中安装CentOS 6.8的全过程。首先,需确保已安装VMware并开启V-CPU虚拟化功能,可通过BIOS设置或使用LeoMoon CPU-V工具检测。接着,下载CentOS镜像文件,并在VMware中新建虚拟机,配置CPU、内存、硬盘等参数。最后,加载ISO镜像启动虚拟机,按照提示完成CentOS的安装,包括语言、键盘、存储方式、地区、密码设置及硬盘分区等步骤。安装完成后,以root用户登录即可进入系统桌面,开始学习Linux命令和操作。
57 12
零基础保姆级教程!手把手教你免费玩转Linux CentOS安装+学习环境搭建(附避坑指南)
Linux 手动安装快速部署 LNMP 环境实战
本文详细记录了在阿里云ECS上手动搭建LNMP环境的过程,系统选用Ubuntu 24.04。主要内容包括:1) 使用`apt`安装Nginx和MySQL,并更新软件源;2) 编译安装PHP 8.4.5,配置PHP-FPM及环境路径;3) 配置MySQL root用户密码;4) 调整Nginx支持PHP解析并测试整体环境。通过此过程,重现手动配置服务器的细节,帮助熟悉各组件的安装与协同工作。
|
22天前
|
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
116 25
Docker Compose V2 安装常用数据库MySQL+Mongo
以上内容涵盖了使用 Docker Compose 安装和管理 MySQL 和 MongoDB 的详细步骤,希望对您有所帮助。
176 42
|
1月前
|
Linux 安装 Qualcomm ® SnapdragonTM Profiler
通过本文的详细介绍,您应该已经成功在 Linux 系统上安装并配置了 Qualcomm® Snapdragon™ Profiler,并能够连接 Android 设备进行性能分析。Snapdragon Profiler 提供了丰富的工具和功能,可以帮助开发者深入了解应用程序的性能瓶颈,从而进行优化。希望本文能对您有所帮助,让您在开发过程中更高效地使用 Snapdragon Profiler 进行性能分析和优化。
80 10
|
1月前
|
Linux安装svn并启动
Linux安装svn并启动
60 10
linux8安装oracle 11g遇到的问题记录
Oracle 11g在Linux 8上安装时会遇到link编译环节的问题。官方建议忽略安装中的链接错误,安装完成后应用DBPSU 11.2.0.4.240716补丁及一次性补丁33991024,再重新编译二进制文件,并配置监听器和数据库。但因11g已退出服务期,这些补丁需付费获取。网上信息显示22年1月的PSU补丁也可解决问题,找到该补丁后按常规方式打补丁即可。如有需求或疑问可咨询我。
103 20
CentOS7仅安装部署MySQL80客户端
通过上述步骤,你可以在CentOS 7上成功安装并配置MySQL 8.0客户端。这个过程确保你能够使用MySQL客户端工具连接和管理远程的MySQL数据库,而不需要在本地安装MySQL服务器。定期更新MySQL客户端可以确保你使用的是最新的功能和安全修复。
284 16
os-copilot在Alibaba Cloud Linux镜像下的安装与功能测试
我顺利使用了OS Copilot的 -t -f 功能,我的疑惑是在换行的时候就直接进行提问了,每次只能写一个问题,没法连续换行更有逻辑的输入问题。 我认为 -t 管道 功能有用 ,能解决环境问题的连续性操作。 我认为 -f 管道 功能有用 ,可以单独创建可连续性提问的task问题。 我认为 | 对文件直接理解在新的服务器理解有很大的帮助。 此外,我还有建议 可以在非 co 的环境下也能进行连续性的提问。
89 7
|
9月前
|
linux 安装 neo4j简介
Neo4j是高性能NoSQL图形数据库,利用图结构存储数据。推荐使用JDK 11配合Neo4j 3.x版本。下载3.5.9版,通过`curl`命令在Linux上获取tar.gz文件,然后解压。配置`neo4j.conf`,调整内存设置,开启远程访问。执行`./bin/neo4j start`启动,通过`http://服务器IP:7474`访问,默认凭据是username: neo4j, password: neo4j,登录后应更改密码。
690 1