久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Mysql多實例如何安裝配置

144次閱讀
沒有評論

共計 5968 個字符,預計需要花費 15 分鐘才能閱讀完成。

這篇文章主要為大家展示了“Mysql 多實例如何安裝配置”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓丸趣 TV 小編帶領大家一起研究并學習一下“Mysql 多實例如何安裝配置”這篇文章吧。

1.OS 用戶創建 / 軟件解壓 /OS 權限配置

點擊 (此處) 折疊或打開

[root@wbg software]# groupadd mysql

[root@wbg software]# useradd -r -g mysql -s /bin/false mysql

[root@wbg software]# cd /usr/local

[root@wbg local]# tar zxvf ~/software/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

解壓中。。。

[root@wbg local]# ln -s mysql-5.7.18-linux-glibc2.5-x86_64/ mysql

[root@wbg mysql]# mkdir mysql-files

[root@wbg mysql]# chmod 750 mysql-files

[root@wbg mysql]# chown -R mysql .

[root@wbg mysql]# chgrp -R mysql .

2. 編寫 /etc/my.cnf

點擊 (此處) 折疊或打開

[mysqld_multi]

mysqld = /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysqld_safe

mysqladmin = /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysqladmin

user = root

password = gg

log     =/root/multi.log

[mysqld3306]

socket = /tmp/mysql.sock3306

port = 3306

pid-file = /mydata/3306/hostname.pid.3306

datadir = /mydata/3306/

#language = /usr/local/mysql/share/mysql/english

user = mysql

[mysqld3308]

mysqld = /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysqld_safe

#ledir = /path/to/mysqld-binary/

mysqladmin = /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/bin/mysqladmin

socket = /tmp/mysql.sock3308

port = 3308

pid-file = /mydata/3308/hostname.pid.3308

datadir = /mydata/3308/

#language = /usr/local/mysql/share/mysql/swedish

user = mysql

[client]

#port=3306

#socket=/tmp/mysql.sock3306

#port=3308

#socket=/tmp/mysql.sock3308

我用的是官方的模板來做的,用的參數比較的少,而且我還在官方的模板基礎上注釋掉了幾個參數。

3. 為每個實力單獨創建目錄

點擊 (此處) 折疊或打開

[root@wbg mysql]# mkdir /mydata

[root@wbg mysql]# cd /mydata

[root@wbg mydata]# mkdir 3306

[root@wbg mydata]# mkdir 3308

[root@wbg mydata]# chown -R mysql:mysql /mydata/

4. 初始化實例(2 個都要做,這里只貼一個了)(前面 2 個是反面教程,最后一個是對的)

點擊 (此處) 折疊或打開

[root@wbg mysql]# bin/mysqld –initialize –user=mysql defaults-file=/etc/my.cnf

2017-10-23T09:13:53.872808Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).

2017-10-23T09:13:54.385216Z 0 [Warning] InnoDB: New log files created, LSN=45790

2017-10-23T09:13:54.547668Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-10-23T09:13:54.630447Z 0 [ERROR] Too many arguments (first extra is defaults-file=/etc/my.cnf).

2017-10-23T09:13:54.630493Z 0 [ERROR] Aborting

需要添加 –explicit_defaults_for_timestamp 這個配置,要不然有警告。

點擊 (此處) 折疊或打開

[root@wbg mysql]# bin/mysqld –initialize –user=mysql –defaults-file=/etc/my.cnf   –datadir=/mydata/3308/ –explicit_defaults_for_timestamp

2017-10-23T09:45:43.659977Z 0 [Warning] InnoDB: New log files created, LSN=45790

2017-10-23T09:45:43.806836Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-10-23T09:45:43.912638Z 0 [ERROR] unknown variable defaults-file=/etc/my.cnf

2017-10-23T09:45:43.912685Z 0 [ERROR] Aborting

initialize 和 defaults-file 的順序也要注意,我在這里耽誤了很多時間。

點擊 (此處) 折疊或打開

[root@wbg mysql]# bin/mysqld –defaults-file=/etc/my.cnf  –initialize –user=mysql  –datadir=/mydata/3308/ –explicit_defaults_for_timestamp

2017-10-23T09:50:48.217054Z 0 [Warning] InnoDB: New log files created, LSN=45790

2017-10-23T09:50:48.430856Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-10-23T09:50:48.500114Z 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: a5c39a70-b7d7-11e7-a63a-080027736559.

2017-10-23T09:50:48.510651Z 0 [Warning] Gtid table is not ready to be used. Table mysql.gtid_executed cannot be opened.

2017-10-23T09:50:48.513336Z 1 [Note] A temporary password is generated for root@localhost: 6epfT_PyU+EG

最后的這個是正確的。

5. 安裝 SSL

點擊 (此處) 折疊或打開

[root@wbg mysql]# bin/mysql_ssl_rsa_setup

Generating a 2048 bit RSA private key

………………….+++

…………………………………………+++

writing new private key to ca-key.pem

—–

Generating a 2048 bit RSA private key

……………………………………………………………………………+++

……………………………………………………………………………………………………+++

writing new private key to server-key.pem

—–

Generating a 2048 bit RSA private key

…………………………+++

………..+++

writing new private key to client-key.pem

—–

在 MySQL 5.7.6 以上的版本,需要安裝這個,不然會有如下的警告

點擊 (此處) 折疊或打開

2017-10-23T18:15:21.506002Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key

6. 在 profile 中增加一段配置

點擊 (此處) 折疊或打開

PATH=$PATH:/usr/local/mysql/bin

7. 設置每個實例的登陸口令(2 個實例都要做)

設置密碼,利用默認密碼

點擊 (此處) 折疊或打開

[root@wbg ~]# mysql -S /tmp/mysql.sock3308 -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 12

Server version: 5.7.18

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type help; or \h for help. Type \c to clear the current input statement.

mysql alter user user() identified by bb

Query OK, 0 rows affected (0.00 sec)

8. 測試一下

點擊 (此處) 折疊或打開

[root@wbg ~]# mysqld_multi report

Reporting MySQL servers

MySQL server from group: mysqld3306 is not running

MySQL server from group: mysqld3308 is not running

[root@wbg ~]# mysqld_multi start

[root@wbg ~]# mysqld_multi report

Reporting MySQL servers

MySQL server from group: mysqld3306 is running

MySQL server from group: mysqld3308 is running

到這里多實例就配置完成了。

額外說明:

1. 這種配置最后只有一個實例可以用 tcp/ip。在 my.cnf 的 [client] 下,最后只能有一組配置可以生效。所有的實例都可以用 socket 去連接。
2. 我這里演示的,是用 root 作為 administrative account,而且它們的密碼都是一樣的,如果 root 的密碼不一樣,官方文檔也有解決方案。

點擊 (此處) 折疊或打開

Make sure that the MySQL account used for stopping the mysqld servers (with the mysqladmin program) has the same user name and password for each server. Also, make sure that the account has the SHUTDOWN privilege. If the servers that you want to manage have different user names or passwords for the administrative accounts, you might want to create an account on each server that has the same user name and password. For example, you might set up a common multi_admin account by executing the following commands for each server:

點擊 (此處) 折疊或打開

shell mysql -u root -S /tmp/mysql.sock -p

Enter password:

mysql CREATE USER multi_admin @ localhost IDENTIFIED BY multipass

mysql GRANT SHUTDOWN ON *.* TO multi_admin @ localhost

3. 在編輯 my.cnf 的時候,要注意 [mysqld_multi] 下的 user 是 mysqld_multi 的 administrative account,這是 mysql 的用戶。
[mysqldN]下的 user 是 OS 的用戶。這些通過官方文檔的模板可以很快的看出來。

以上是“Mysql 多實例如何安裝配置”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-27發表,共計5968字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 海门市| 南华县| 延寿县| 蛟河市| 临武县| 紫金县| 忻城县| 苏尼特右旗| 依兰县| 道真| 明光市| 东阿县| 营口市| 千阳县| 海兴县| 扶沟县| 南召县| 离岛区| 新丰县| 婺源县| 上思县| 天全县| 仲巴县| 淄博市| 大关县| 阳江市| 新野县| 徐州市| 宝应县| 芦山县| 谷城县| 河西区| 绍兴市| 望奎县| 德格县| 左云县| 常德市| 从化市| 九江市| 罗源县| 纳雍县|