mysql 建立多个实例

举报
snowofsummer 发表于 2021/04/23 15:05:38 2021/04/23
【摘要】 #cp -r /data/home/tdsql/tdsqlinstall/percona-5.7.17 /home/1,配置my.cnfuseradd mysql mkdir /3333mkdir /3333/datamkdir /3333/logmkdir /3333/runtouch /3333/log/db.logchown -R mysql:mysql /3333cat >> /3...
#cp -r  /data/home/tdsql/tdsqlinstall/percona-5.7.17 /home/


1,配置my.cnf
useradd mysql 
mkdir /3333
mkdir /3333/data
mkdir /3333/log
mkdir /3333/run
touch /3333/log/db.log
chown -R mysql:mysql /3333

cat >> /3333/data/my.cnf<<EOF
[mysqld]
port=3333
datadir=/3333/data
socket=/3333/mysql.sock
[mysqld_safe]
log-error=/3333/log/db.log
pid-file=/3333/run/db.pid
EOF


2,初始化数据库
# 生产随机初始化密码
/home/percona-5.7.17/bin/mysqld --defaults-file=/3306/my.cnf   --initialize  --user=mysql

2021-02-05T02:06:41.561705Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-02-05T02:06:41.561899Z 0 [ERROR] Can't find error-message file '/data/home/jenkins/jobs/626/workspace/dev/percona-5.7.17/mysql_install/percona-server-5.7.17/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2021-02-05T02:06:41.803872Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-02-05T02:06:41.837373Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-02-05T02:06:41.895651Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ca02b854-6756-11eb-806a-000c29a91aed.
2021-02-05T02:06:41.896297Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-02-05T02:06:41.897039Z 1 [Note] A temporary password is generated for root@localhost: !79VH4Er2R3.《===随机密码

#默认没有密码
/home/percona-5.7.17/bin/mysqld --defaults-file=/3306/my.cnf  --user=mysql --initialize-insecure

2021-02-05T02:21:41.078948Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-02-05T02:21:41.079132Z 0 [ERROR] Can't find error-message file '/data/home/jenkins/jobs/626/workspace/dev/percona-5.7.17/mysql_install/percona-server-5.7.17/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2021-02-05T02:21:41.272836Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-02-05T02:21:41.305158Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-02-05T02:21:41.313561Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e21b0076-6758-11eb-b9a1-000c29a91aed.
2021-02-05T02:21:41.314075Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-02-05T02:21:41.314521Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.




3,启动数据库
启动失败?
[root@db01 percona-5.7.17]# /home/percona-5.7.17/bin/mysqld_safe --defaults-file=/3306/my.cnf&
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
grep: write error: Broken pipe
2021-02-05T02:08:08.137834Z mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
2021-02-05T02:08:08.141162Z mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
2021-02-05T02:08:08.144423Z mysqld_safe The file /data/home/jenkins/jobs/626/workspace/dev/percona-5.7.17/mysql_install/percona-server-5.7.17/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more informatio


解决方法?
1,建立软连接?
ln -s /home/percona-5.7.17/bin/mysqld /data/home/jenkins/jobs/626/workspace/dev/percona-5.7.17/mysql_install/percona-server-5.7.17/bin/mysqld
#成功启动。
[root@db01 percona-5.7.17]# /home/percona-5.7.17/bin/mysqld_safe --defaults-file=/3306/my.cnf&

2021-02-05T02:38:16.937782Z mysqld_safe Logging to '/3306/log/db.log'.
2021-02-05T02:38:16.970741Z mysqld_safe Starting mysqld daemon with databases from /3306/data

2,进入percona-5.7.17/bin 上级目录里执行就可以成功启动?
cd /home/percona-5.7.17
pwd
/home/percona-5.7.17
./bin/mysqld_safe  --defaults-file=/3306/my.cnf&

2021-02-05T02:38:16.937782Z mysqld_safe Logging to '/3306/log/db.log'.
2021-02-05T02:38:16.970741Z mysqld_safe Starting mysqld daemon with databases from /3306/data



4,测试数据库
[root@db01 percona-5.7.17]# mysql -uroot  -S /3306/mysql.sock -e "show databases;"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+



support-files 文件设置开机启动脚本:
1,datadir=/3307/data
2,lockdir='/3307'
3,启动参数文件my.cnf,放到datadir目录
#extra_args="-e $datadir/my.cnf"







【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。