如何在一台服务器上安装两个mysql或者更多

如何在一台服务器上安装两个mysql或者更多,第1张

这种架构一般用在以下三类场景

1 备份多台 Server 的数据到一台如果按照数据切分方向来讲,那就是垂直切分。比如图 2,业务 A、B、C、D 是之前拆分好的业务,现在需要把这些拆分好的业务汇总起来备份,那这种需求也很适用于多源复制架构。实现方法我大概描述下:业务 A、B、C、D 分别位于 4 台 Server,每台 Server 分别有一个数据库来隔离前端的业务数据,那这样,在从库就能把四台业务的数据全部汇总起来,而不需要做额外的操作。那没有多源复制之前,要实现这类需求,只能在汇总机器上搭建多个 MySQL 实例,那这样势必会涉及到跨库关联的问题,不但性能急剧下降,管理多个实例也没有单台来的容易。

2 用来聚合前端多个 Server 的分片数据。

同样,按照数据切分方向来讲,属于水平切分。比如图 3,按照年份拆分好的数据,要做一个汇总数据展现,那这种架构也非常合适。实现方法稍微复杂些:比如所有 Server 共享同一数据库和表,一般为了开发极端透明,前端配置有分库分表的中间件,比如爱可生的 DBLE。

3 汇总并合并多个 Server 的数据

第三类和第一种场景类似。不一样的是不仅仅是数据需要汇总到目标端,还得合并这些数据,这就比第一种来的相对复杂些。比如图 4,那这样的需求,是不是也适合多源复制呢?答案是 YES。那具体怎么做呢?

解压版当然没有服务需要把服务加到系统服务

参考下面:

[root@dbtest3 ~]# scripts/mysql_install_db --user=mysql --datadir=/opt/mysql/data

[root@dbtest3 ~]# chown -R mysql:mysql /opt/mysql

[root@dbtest3 ~]# cp support-files/mysqlserver /etc/initd/mysql

[root@dbtest3 ~]# chmod 755 /etc/initd/mysql

[root@dbtest3 ~]# chkconfig --add mysql

[root@dbtest3 ~]# chkconfig --level 2345 mysql on

[root@dbtest3 ~]# PATH=/opt/mysql/bin:$PATH

[root@dbtest3 ~]# echo "PATH=/opt/mysql/bin:$PATH" >> /etc/profile

[root@dbtest3 ~]# PATH=/opt/mysql/bin:$PATH

[root@dbtest3 ~]# export PATH

1、首先下载MySQL的安装文件,我这里安装的是MySQL517版本的,

2、安装MySQL数据库服务器

进入安装包所在文件夹,执行命令 rpm -ivh MySQL-server-517-0i386rpm 安装MySQL服务器。

如果报了与原先版本冲突的话,就执行rpm -qa|grep -i mysql命令,会显示已安装的Mysql版本,我的显示mysql-libs-5161-4el6i686

   这时如果有的话就强制删除:rpm -e --nodeps mysql-libs-5161-4el6i686(因为有包依赖,所以要强制删除)

我的报错提示如下:

复制代码

   

代码如下:

MySQL-server-517-0i386rpm

   Preparing ########################################### [100%]

   file /usr/share/mysql/charsets/README from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/Indexxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/armscii8xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/asciixml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/cp1250xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/cp1251xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/cp1256xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/cp1257xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/cp850xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/cp852xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/cp866xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/dec8xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/geostd8xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/greekxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/hebrewxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/hp8xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/keybcs2xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/koi8rxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/koi8uxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/latin1xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/latin2xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/latin5xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/latin7xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/maccexml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/macromanxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/charsets/swe7xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/czech/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/danish/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/dutch/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/english/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/estonian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/french/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/german/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/greek/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/hungarian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/italian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/japanese/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/korean/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/norwegian-ny/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/norwegian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/polish/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/portuguese/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/romanian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/russian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/serbian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/slovak/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/spanish/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/swedish/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

   file /usr/share/mysql/ukrainian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686

这时候再执行rpm -ivh MySQL-server-517-0i386rpm安装即可安装成功。

   我这里安装成功了,但是mysql服务无法启动,总是启动失败,后来百度了一下,是因为selinux的原因,只要将selinux关闭就OK了。

   关闭selinux:vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled 然后重启

   关闭selinux之后还是无法启动mysql服务,因为安装的mysql所有者是root,在安装mysql的时候会创建一个用户mysql,只要将/var/lib/mysql

   的所有者改为mysql就OK了,执行命令chown -R mysql:mysql /var/lib/mysql

   现在执行service mysql start终于可以启动mysql服务了。

3安装MySQL客户端

   执行命令rpm -ivh MySQL-client-517-0i386rpm进行安装。

4安装成功

成功安装MySQL后将sql文件导入到数据库,步骤如下:

进入MYSQL Command Line Client

   1、先创建数据库:create database test 注:test是创建数据库的名称

   2、再切换到当前数据库:use test

   3、再输入:/ /root/testsql 或 souce /root/testsql

按照以上步骤就可以将备份的sql脚本导入到linux中的数据库中去。

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » 如何在一台服务器上安装两个mysql或者更多

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情