In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
I. installation of mysql database
Install mysql database in source code on master and slave respectively
1.1 install related packages
1.1.1 cmake software
Cd / home/oldboy/tools/
Tar xf cmake-2.8.8.tar.gz
Cd cmake-2.8.8
. / configure
# CMake has bootstrapped. Now run gmake.
Gmake
Gmake install
Cd.. /
1.1.2 dependency package
Yum install ncurses-devel-y
1.2 start installing mysql
1.2.1 create users and groups
Groupadd mysql
Useradd mysql-s / sbin/nologin-M-g mysql
1.2.2 decompress and compile MySQL
Tar zxf mysql-5.5.32.tar.gz
Cd mysql-5.5.32
Cmake. -DCMAKE_INSTALL_PREFIX=/application/mysql/mysql-5.5.40\
-DMYSQL_DATADIR=/application/mysql/mysql-5.5.40/data\
-DMYSQL_UNIX_ADDR=/application/mysql/mysql-5.5.40/tmp/mysql.sock\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii\
-DENABLED_LOCAL_INFILE=ON\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_FEDERATED_STORAGE_ENGINE=1\
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1\
-DWITHOUT_PARTITION_STORAGE_ENGINE=1\
-DWITH_FAST_MUTEXES=1\
-DWITH_ZLIB=bundled\
-DENABLED_LOCAL_INFILE=1\
-DWITH_READLINE=1\
-DWITH_EMBEDDED_SERVER=1\
-DWITH_DEBUG=0
#-Build files have been written to: / home/oldboy/tools/mysql-5.5.32
Note that there are many options that can be configured at compile time. For more information, please see the appendix at the end or the official documentation:
Make
# [100%] Built target my_safe_process
Make install
Ln-s / application/mysql-5.5.32/ / application/mysql
If there is no error in the above operation, the installation of the MySQL5.5.32 software in cmake mode is considered successful.
1.3 after successful installation of the database
1.3.1 modify the permissions of the mysql installation directory, all to mysql
Chown-R mysql:mysql / application/mysql
1.3.2 initialize the database
Cd / application/mysql/scripts
[root@localhost scripts] # / mysql_install_db-- basedir=/application/mysql-- datadir=/data/mysql-- user=mysql
1.3.3 replace the configuration file and database startup file under / etc/
/ application/mysql/support-files
Cp-r my-small.cnf / etc/my.cnf
Cp-r mysql.server / etc/init.d/mysql
1.4 start the database
/ etc/init.d/mysql start
/ etc/init.d/mysql stop
/ etc/init.d/mysql restart
2. Synchronization of sub-database and sub-table in mysql database
2.1master profile
Log-bin=mysql-bin
Binlog_format=row
Server-id = 15
Binlog-do-db=sales
/ etc/init.d/mysql restart (restart the database)
2.2slave profile
Server-id = 25
Relay-log=relay-bin
Read-only = 1
Replicate-do-db = sales
Replicate-do-db = user_info
Replicate-ignore-db = information_schema
Replicate-ignore-db = mysql
Replicate-ignore-db = user_info
Replicate-do-table = sales.story / / single table of the database to be synchronized
/ etc/init.d/mysql restart (restart the database)
2.3 create synchronized users on master
Grant replication client,replication slave on *. * to rep@'172.27.1.%' identified by 'password'
Mysql > show master status\ G
* * 1. Row *
File: mysql-bin.000003
Position: 150
Binlog_Do_DB: sales,user_info
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
ERROR:
No query specified
2.4 execute the following statement on slave to synchronize to master
Change master to master_host='172.27.1.12' (IP address of main library), master_user='rep',master_password='financial',master_log_file='mysql-bin.000003',master_log_pos=150
Start slave (launch slave library)
Stop slave (stop slave library)
Reset slave (reset slave library)
After starting the database, check the status of slave as follows:
Mysql > show slave status\ G
* * 1. Row *
Slave_IO_State: Waiting for master to send event
Master_Host: 172.27.1.12
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 150
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 269
Relay_Master_Log_File: mysql-bin.001603
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: sales
Replicate_Ignore_DB: information_schema,mysql,user_info
Replicate_Do_Table: sales.story
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 150
Relay_Log_Space: 419
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 15
1 row in set (0.00 sec)
ERROR:
No query specified
The above indicates that the database master and slave has been configured and can be configured with a single table in the same database.
Test:
1. Create the database sales in master and slave respectively (you need to create the database manually in row mode).
Under the 2.use sales library, create a table on master
CREATE TABLE user_info (
PersonID int
LastName varchar (255)
FirstName varchar (255)
Address varchar (255)
City varchar (255)
);
3. Create a table on master
CREATE TABLE story (
PersonID int
LastName varchar (255)
FirstName varchar (255)
Address varchar (255)
City varchar (255)
);
View slave synchronization status:
A. story table synchronization succeeded
B. User_info table synchronization is not successful
Then the mysql database has a single database and a single table is synchronized successfully.
If you are only synchronizing a single library, remove it from the configuration file of slave:
Replicate-do-table = sales.story / / single table of the database to be synchronized
During the installation process, it is found that there is no problem with synchronization from low version to high version, and there is always a problem with synchronization from high version to low version.
Database 5.7 binary version
Download link:
Https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
Direct decompression use, authorization, initialization commands are as follows:
Bin/mysqld-initialize-user=mysql-basedir=/application/mysql-5.7.18-datadir=/application/mysql-5.7.18/data
Note: initialization generates the initial password for logging into the database, so remember to save it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.