Linux MySQL compilation and installation commands

Source: Internet
Author: User

Do you want to know the truth about Linux MySQL? Do you want to know the inherent meanings hidden in Linux MySQL? I only want to give you a full introduction to Linux MySQL nearly a year ago, I wrote an article about ing Linux MySQL Data to Memcached. At that time, both Linux MySQL and Memcached Functions for MySQL were not mature enough. One year later, Memcached Functions for MySQL was upgraded to version 0.8, mySQL has also released the GA version, and many friends have responded that the implementation in the previous article has failed due to various reasons. Therefore, this article should be an upgraded version of the previous article.

The test environment is run in Linux MySQL. The version system is CentOS5. the following are the related software, including the version and:

 
 
  1. Download mysql-5.1.30
  2. Download memcached-1.2.6
  3. Download libevent-1.4.7-stable
  4. Download memcached_functions_mysql-0.8
  5. Download libmemcached-0.26

Compile and install Linux MySQL. The installation depends on your individual requirements. Many compilation details and parameters irrelevant to the test are omitted.

 
 
  1. [root@localhost ~]#tar xzf mysql-5.1.30.tar_001.gz  
  2. [root@localhost ~]#cd mysql-5.1.30  
  3. [root@localhost ~]#./configure --prefix=/usr/local/mysql51  
  4. [root@localhost ~]#make  
  5. [root@localhost ~]#make install  
  6. [root@localhost ~]#./scripts/mysql_install_db --user=mysql --skip-name-resolve  
  7. [root@localhost ~]#/usr/local/mysql51/bin/mysqld_safe 

The commands for installing memcached and libevent are omitted. Install libevent by default and install memcached in the/usr/local/memcached directory.
Start memcached.

/Usr/local/memcached/bin/memcached-d-m 50-u root-p 11211 compile and install libmemcache.

 
 
  1. [root@localhost ~]#tar xzf libmemcached-0.26.tar.gz  
  2. [root@localhost ~]#cd libmemcached-0.26  
  3. [root@localhost ~]#./configure --with-memcached=/usr/local/memcached/bin/memcached  
  4. [root@localhost ~]# make && make install 

Compile and install Memcache UDFs for MySQL.

 
 
  1. [root@localhost ~]# tar xzf memcached_functions_mysql-0.8.tar.gz  
  2. [root@localhost ~]# cd memcached_functions_mysql-0.8  
  3. [root@localhost ~]# ./configure --with-mysql-config=/usr/local/mysql51/bin/mysql_config  
  4. [root@localhost ~]# make && make install 

After compilation, copy the compiled library file to the mysql plug-in directory to facilitate loading and usage. Cp/usr/local/lib/libmemcached_functions_mysql */usr/local/mysql51/lib/mysql/plugin/enter the source code directory of memcached_functions_mysql, there is an SQL file in the directory for UDF initialization. [Root @ localhost ~] # Mysql <SQL/install_functions. SQL Note: if you are not familiar with or do not understand these UDFs, refer to README in the source code directory and provide relevant instructions.

So far, the compilation and installation of related software are complete for testing. The purpose is to insert a new MySQL record to Memcached at the same time, when the record is updated, records in Memcached are synchronously updated. When the record is deleted, Memcached related records are also deleted. Therefore, Three triggers are created for this purpose, if you are not familiar with the MySQL trigger program, refer to Chapter 21st of the MySQL manual. In the following SQL statement, memcached is the name of the table to be operated. The SQL statement is as follows:

 
 
  1. # Insert Memcached when inserting data
  2. Create trigger mysqlmmci after insert on memcached for each row set @Tmp=Memc_set(NEW. key, NEW. value );
  3. # Update Memcached when updating records
  4. Create trigger mysqlmmcu after update on memcached for each row set @Tmp=Memc_set(NEW. key, NEW. value );
  5. # Deleting a Memcached record
  6. Create trigger mysqlmmcd before delete on memcached for each row set @Tmp=Memc_delete(OLD. key );

The following is a test record. You can operate Memcached while operating Linux MySQL. Of course, you can also use the-vv parameter when starting Memcached to view related information.

Linux MySQL operation records:

 
 
  1. [Root @ localhost ~] # Mysql-S/tmp/mysql51.sock
  2. Welcome to the MySQL monitor. Commands end with; or \ g.
  3. Your MySQL connection id is 6
  4. Server version: 5.1.30 Source distribution
  5. Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
  6. Mysql>Use test;
  7. Database changed
  8. Mysql>Create table 'memcached' ('key' varchar (10), 'value' varchar (100 ));
  9. Query OK, 0 rows affected (0.00 sec)
  10. Mysql>Create trigger mysqlmmci after insert on memcached for each row set @Tmp=Memc_set(NEW. key, NEW. value );
  11. Query OK, 0 rows affected (0.00 sec)
  12. Mysql>Create trigger mysqlmmcu after update on memcached for each row set @Tmp=Memc_set(NEW. key, NEW. value );
  13. Query OK, 0 rows affected (0.00 sec)
  14. Mysql>Create trigger mysqlmmcd before delete on memcached for each row set @Tmp=Memc_delete(OLD. key );
  15. Query OK, 0 rows affected (0.00 sec)
  16. Mysql>Insert into memcached values ("keyi", "valuei"), ("keyu", "valueu"), ("keyd", "valued ");
  17. Query OK, 3 rows affected (0.00 sec)
  18. Records: 3 Duplicates: 0 Warnings: 0
  19. Mysql>Update memcached set 'value' = "update" where 'key' = "keyu ";
  20. Query OK, 1 row affected (0.00 sec)
  21. Rows matched: 1 Changed: 1 Warnings: 0
  22. Mysql>Delete from memcached where 'key' = "keyd ";
  23. Query OK, 1 row affected (0.00 sec)
  24. Mysql>Quit
  25. Bye
  26. Memcache viewing records:
 
 
  1. [root@localhost ~]#telnet 127.0.0.1 11211  
  2. Trying 127.0.0.1...  
  3. Connected to 127.0.0.1.  
  4. Escape character is '^]'.  
  5. get keyi  
  6. VALUE keyi 0 6  
  7. valuei  
  8. END  
  9. get keyu  
  10. VALUE keyu 0 6  
  11. valueu  
  12. END  
  13. get keyd  
  14. VALUE keyd 0 6  
  15. valued  
  16. END  
  17. get keyu  
  18. VALUE keyu 0 6  
  19. update  
  20. END  
  21. get keyd  
  22. END  
  23. quit  
  24. Connection closed by foreign host. 

So far, we have basically implemented synchronizing data from Linux MySQL to Memcached, and the performance has not yet been tested. Of course, the above is just a simple data ing function, if the implementation of the production environment, you need to consider the namespace, high reliability issues, these are all through the database name-table name-keywords to achieve the unique purpose of KEY, high reliability is a big problem.

  1. Linux mysql Command installation allows remote connection
  2. Linux MYSQL command to modify the method of various connections
  3. Linux MySQL program service built-in security mechanism
  4. Install and modify the root password service in Linux mysql
  5. Use the source code to compile and install the Linux Mysql Server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.