设为首页 收藏本站
查看: 1955|回复: 0

[经验分享] linux 安装MySQL多实例

[复制链接]

尚未签到

发表于 2018-9-29 07:46:32 | 显示全部楼层 |阅读模式
  环境: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,>  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 &
  本文借鉴:


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-603491-1-1.html 上篇帖子: 【简单!!!】MySQL用户管理与事务 下篇帖子: MySQL Workbench中文教程
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表