[root@node1 local]# mv /root/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz /usr/local/
[root@hadoop1 local]# tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
[root@hadoop1 local]# mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql
[root@hadoop1 local]# cd mysql
[root@hadoop1 mysql]# mkdir arch tmp relay_log
[root@hadoop1 local]# groupadd -g 101 dba
[root@hadoop1 mysql]# cat /etc/group | tail -n 3
postfix:x:89:
ntp:x:38:
dba:x:101:
/usr/local/mysql/
[root@hadoop1 local]# useradd -g dba -d /usr/local/mysql/ mysql
[root@hadoop1 local]# cp /etc/skel/.bash_profile /usr/local/mysql/
[root@hadoop1 local]# cp /etc/skel/.bash_logout /usr/local/mysql/
[root@hadoop1 local]# cp /etc/skel/.bashrc /usr/local/mysql/
[mysql@hadoop1 ~]$ vi /usr/local/mysql/.bash_profile
#mysql
export MYSQL=/usr/local/mysql
export PATH=$PATH:$MYSQL/bin
上傳my.cnf
[root@hadoop1 ~]# mv my.cnf /etc/
[root@hadoop1 ~]# chown mysql:dba /etc/my.cnf
[root@hadoop1 ~]# chmod 640 /etc/my.cnf
[root@hadoop1 ~]# chown -R mysql:dba /usr/local/mysql/
[root@hadoop1 ~]# chmod -R 755 /usr/local/mysql/
[root@hadoop1 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
[root@hadoop1 ~]# chmod +x /etc/rc.d/init.d/mysql
[root@hadoop1 ~]# chkconfig --add mysql
[root@hadoop1 ~]# chkconfig mysql on
[root@hadoop1 ~]# yum -y install libaio
[root@hadoop1 ~]# su - mysql
# data是mysql數據庫存放數據的目錄
[mysql@hadoop1 ~]$ mkdir data
#初始化mysql
[mysql@hadoop1 mysql]$ bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
[mysql@hadoop1 data]$ cat /usr/local/mysql/data/hostname.err | grep password
[mysql@hadoop1 data]$ /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
[mysql@hadoop1 data]$ service mysql status
#也可以去看一下mysql的進程在不在
[mysql@hadoop1 data]$ ps -elf | grep mysql (會發現mysql進程正在啟動)
需要進入mysql
mysql -uroot -p
mysql> alter user root@localhost identified by 123456;
mysql> grant all privileges on *.* to root@% identified by 123456;
mysql> flush privileges;
[mysql@hadoop1 mysql]$ ps -elf | grep mysql
[mysql@hadoop1 mysql]$ kill -9 [PID]
檢查你的密碼對不對;
檢查你的mysql有沒有啟動,需要重新啟動,而且需要再添加開機自動啟動。
[mysql@hadoop1 ~]$ service mysql status
SUCCESS! MySQL running (7661)
如果是success沒有問題。
[mysql@hadoop1 ~]$ ps -elf | grep mysql
看一下有沒有這個進程。
mysqldump -uroot -p123456 test user > user.sql
[mysql@hadoop1 mysql]$ mysql -uroot -p123456 -s -e "show databases;" | grep -v Database
mysql: [Warning] Using a password on the command line interface can be insecure.
information_schema
mysql
performance_schema
sys
test
test2
[mysql@hadoop1 mysql]$ mysql -uroot -p123456 -s -e "use test;show tables;" | grep -v Tables_in
mysql: [Warning] Using a password on the command line interface can be insecure.
user
開啟binlog日志需要在配置文件中添加:
查看binlog日志文件的命令:
[mysql@hadoop1 arch]$ mysqlbinlog --no-defaults --base64-output=decode-rows -vvv mysql-bin.000003
[mysql@hadoop2 relay_log]$ exit
logout
[root@hadoop2 ~]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
創建用戶:
mysql> create user reproduce@localhost identified by 123456;
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
驗證:
遠程訪問:
加權限(在主庫使用root用戶):
mysql> grant replication slave on *.* to reproduce@% identified by 123456;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
驗證:
change master to
master_host=192.168.174.10,
master_port=3306,
master_user=reproduce,
master_password=123456,
master_log_file=mysql-bin.000002,
master_log_pos=1680;
IO_thread
SQL_thread
mysql> start slave;
Query OK, 0 rows affected (0.02 sec)
mysql> show slave statusG
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
[mysql@hadoop2 relay_log]$ mysqlbinlog --no-defaults --base64-output=decode-rows -vvv relay-log.000002
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/129632.html
摘要:環境主機從機環境目標實現主機到從機基于的主從復制目前提供兩種方式主從復制基于我們此篇就是基于的主從復制基于第步下載并分別安裝到主機和從機,網上有很多例子。第步在主機和從機上分別拷貝配置文件到下。可以創建庫或者表查看同步情況。 環境 主機:172.17.0.2從機:172.17.0.3環境:CentOS7MySQL:5.6.38目標:實現主機172.17.0.2到從機172.17.0.3...
摘要:環境主機從機環境目標實現主機到從機基于的主從復制目前提供兩種方式主從復制基于我們此篇就是基于的主從復制基于第步下載并分別安裝到主機和從機,網上有很多例子。第步在主機和從機上分別拷貝配置文件到下。可以創建庫或者表查看同步情況。 環境 主機:172.17.0.2從機:172.17.0.3環境:CentOS7MySQL:5.6.38目標:實現主機172.17.0.2到從機172.17.0.3...
閱讀 1346·2023-01-11 13:20
閱讀 1684·2023-01-11 13:20
閱讀 1132·2023-01-11 13:20
閱讀 1858·2023-01-11 13:20
閱讀 4099·2023-01-11 13:20
閱讀 2704·2023-01-11 13:20
閱讀 1385·2023-01-11 13:20
閱讀 3594·2023-01-11 13:20