[root@server1 ~]# ls
phpMyAdmin-5.0.2-all-languages.zip
[root@server1 ~]# du -h phpMyAdmin-5.0.2-all-languages.zip
14M phpMyAdmin-5.0.2-all-languages.zip
[root@server1 ~]# unzip phpMyAdmin-5.0.2-all-languages.zip
[root@server1 ~]# ls
phpMyAdmin-5.0.2-all-languages
phpMyAdmin-5.0.2-all-languages.zip
[root@server1 ~]# mv phpMyAdmin-5.0.2-all-languages /usr/local/lnmp/nginx/html/phpmyadmin
[root@server1 ~]# cd /usr/local/lnmp/nginx/html/phpmyadmin
[root@server1 phpmyadmin]# systemctl start php-fpm.service
[root@server1 phpmyadmin]# cd /usr/local/lnmp/nginx/conf/
[root@server1 conf]# vim nginx.conf
35 server {
36 listen 80;
37 server_name www.westos.org;
38
39 location ~ \.php$ {
40 root html;
41 fastcgi_pass 127.0.0.1:9000;
42 fastcgi_index index.php;
43 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
44 include fastcgi.conf;
45 }
46 #charset koi8-r;
47
48 #access_log logs/host.access.log main;
49
50 location / {
51 root html;
52 index index.php index.html index.htm;
53 }
[root@server1 conf]# nginx -t
nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful
[root@server1 conf]# nginx
[root@server1 conf]# nginx -s reload
[root@server1 conf]# cd /usr/local/php/lib/
[root@server1 lib]# ls
php php.ini
[root@server1 lib]# vim php.ini
1059 pdo_mysql.default_socket=/data/mysql/mysql.sock
1168 mysqli.default_socket = /data/mysql/mysql.sock
[root@server1 ~]# cd /usr/local/lnmp/nginx/
[root@server1 nginx]# ls
client_body_temp fastcgi_temp logs sbin uwsgi_temp
conf html proxy_temp scgi_temp
[root@server1 nginx]# cd html/
[root@server1 html]# ls
123.png download index.html memcache.php test.html
50x.html example.php index.php phpmyadmin
[root@server1 html]# cd phpmyadmin/
[root@server1 phpmyadmin]# cp config.sample.inc.php config.inc.php
[root@server1 phpmyadmin]# vim config.inc.php
18 $cfg['blowfish_secret'] = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
server2
mysql> create user root@'172.25.4.%' identified by 'Westos+123';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on *.* to root@'172.25.4.%';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> create user wwy@'172.25.4.%' identified by 'Westos+123';
Query OK, 0 rows affected (0.01 sec)
mysql> create database westos;
Query OK, 1 row affected (0.01 sec)
mysql> grant all on westos.* to wwy@'172.25.4.%';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
server1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> select * from test.redhat;
+--------------+-----------+
| user | password |
+--------------+-----------+
| 凉生凉意 | 234093456 |
| 柠檬 | 567876543 |
+--------------+-----------+
2 rows in set (0.01 sec)
[root@server1 mysql]# vim /etc/my.cnf
server-id=1
log-bin=mysql-bin
[root@server1 mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@server2 ~]# vim /etc/my.cnf
server-id=2
[root@server2 ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
server2:
mysql> CREATE USER 'repl'@'172.25.4.%' IDENTIFIED BY 'Westos+123';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'172.25.4.%';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@server1 mysql]# vim /etc/my.cnf
server-id=1
log-bin=mysql-bin
[root@server1 mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@server1 mysql]# ls
auto.cnf binlog.index ib_buffer_pool mysql-bin.000001 performance_schema sys
binlog.000001 ca-key.pem ibdata1 mysql-bin.index private_key.pem test
binlog.000002 ca.pem ib_logfile0 mysql.ibd public_key.pem undo_001
binlog.000003 client-cert.pem ib_logfile1 mysql.sock server1.err undo_002
binlog.000004 client-key.pem ibtmp1 mysql.sock.lock server1.pid
binlog.000005 #ib_16384_0.dblwr #innodb_temp mysqlx.sock server-cert.pem
binlog.000006 #ib_16384_1.dblwr mysql mysqlx.sock.lock server-key.pem
[root@server1 mysql]# cat mysql-bin.index
./mysql-bin.000001
server1:
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 156 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
server2:
mysql> show slave status;
Empty set (0.00 sec)
mysql> change master to
-> master_host='172.25.4.1',
-> master_user='repl',
-> master_password='Westos+123',
-> master_log_file='mysql-bin.000001',
-> master_log_pos=156,
-> get_master_public_key=1;
Query OK, 0 rows affected, 2 warnings (0.05 sec)
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
mysql> show slave status\G;
server1:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.01 sec)
mysql> create database kaixin;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| kaixin |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
6 rows in set (0.00 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 347 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
server3:
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.25.4.1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 347
Relay_Log_File: server2-relay-bin.000002
Relay_Log_Pos: 515
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| kaixin |
| mysql |
| performance_schema |
| sys |
| westos |
+--------------------+
6 rows in set (0.00 sec)
server1:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| kaixin |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
6 rows in set (0.00 sec)
mysql> use kaixin;
Database changed
mysql> show tables;
+------------------+
| Tables_in_kaixin |
+------------------+
| user_tb |
+------------------+
1 row in set (0.00 sec)
mysql> desc user_tb;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| name | varchar(25) | NO | | NULL | |
| password | int | NO | | NULL | |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> select * from user_tb;
+-------+----------+
| name | password |
+-------+----------+
| user1 | 123 |
+-------+----------+
1 row in set (0.00 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 924 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql主从复制
最新推荐文章于 2024-07-04 19:28:13 发布