Cmake installation and Sphinx integration for MySQL 5.5 in centos

Source: Internet
Author: User

Add a mysql user group and a mysql user
Groupadd mysql
Useradd-g mysql
Passwd-u mysql

1. Install the required software package
Yum install gcc-c ++ libtool autoconf automake imake libxml2-devel expat-devel
Yum install ncurses-devel make
Yum install make
Yum install cmake bison

2. Download the mysql source package and decompress it to the specified directory.
Mkdir/data/
Cd/data/# Put the installation package into this folder
Tar-zxvf mysql-5.5.17.tar.gz

3. Enter the decompressed source code package
Cd mysql-5.5.17

4. Compile cmake (create a data folder and install the folder first, if the path does not exist)
Cmake .\
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_DATADIR =/var/tmp/mysql /\
-DMYSQL_UNIX_ADDR =/var/tmp/mysql/mysqld. sock \
-DDEFAULT_CHARSET = utf8 \
-DEXTRA_CHARSETS = all \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_SPHINX_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_USER = mysql

5. make

6. make install

7. Configuration File
Cp support-files/my-medium.cnf/etc/my. cnf
Cp support-files/mysql. server/etc/init. d/mysqld
Chmod 755/etc/init. d/mysqld

8. initialize the database
If this ERROR occurs, [error] Fatal ERROR: Can't open and lock privilege tables: Table 'mysql. host' doesn' t exist
Because no data file location is specified.
./Scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql/-- datadir =/var/tmp/mysql /&

9. Authorization
Chown-R mysql: mysql/usr/local/mysql/
Chown-R mysql: mysql/var/tmp/mysql/

10. Start the database
Service mysqld start

11. Set to Environment Variables
Vi/etc/profile
Export PATH = "$ PATH:/usr/local/mysql/bin"

/Usr/local/mysql/bin/mysqladmin-u root password 'new-password'
/Usr/local/mysql/bin/mysqladmin-u root-h namenode password 'new-password'


12. mysql has come to an end. Thank you!

1.

Decompress the sphinx source code package:

$ Tar xzvf sphinx-0.9.9.tar.gz
$ Cd sphinx

2.

Run the configure configuration program:

$./Configure [options]

Some parameters can be specified during configuration, mainly as follows:
*-Prefix: Specifies the location where the sphfix is installed on the system. For example,-prefix =/usr/local/sphinx
*-With-mysql: the installation directory of mysql. It specifies the directory to which mysql files fail to be detected automatically.
*-With-pgsql, same as above, only used for pgsql
The complete configuration command is as follows:./configure -- prefix =/usr/local/sphinx-with-mysql =/usr/local/mysql
3. Compile:

$ Make

In this step, a problem may occur, that is, the sphsf-undefined reference to 'libiconv' error is reported, the solution is to modify/src/MakeFile (The Makefile under src is not the Makefile under csft), and add-liconv after LIBS =-lm-lexpat, that is, this row is:
LIBS =-lm-lexpat-liconv-L/usr/local/lib

4. Installation

$ Make install

If no errors are generated during compilation, this step will not encounter any problems. If the installation is not correct after completion, you need to go back to the errors encountered during the make process.

5. Run the test

$ Cd/usr/local/sphinx/etc
$ Cp sphinx. conf. dist sphinx. conf
$ Vi sphinx. conf

Here, sphinx provides a simple example. The basic step is to first set the sphinx in/sphinx/etc. conf. rename dist to sphexample. conf, and then modify the sphexample. the configuration in conf mainly involves modifying the mysql user name, password, and database on your server. The modified location is the lines below source src1 of sphsf-. conf.

$ Mysql-u test </usr/local/sphple/etc/example. SQL

Here we import the test data prepared by sphinx. We import the data to the test database of mysql. Of course, the database here should be the same as the SQL _db value specified in the configuration file above (sphsf-. conf. Note: To run this command, if your mysql command is not added to the environment variable, you must use the complete path and enter the password. For example, if your mysql is installed in the/usr/local/mysql directory and the root account password is xxxxxx, the command should be adjusted:
$/Usr/local/mysql/bin/mysql-uroot-pxxxxxx test </usr/local/sphple/etc/example. SQL

$ Cd/usr/local/sphinx/etc

$/Usr/local/sphinx/bin/indexer -- all

Error:
/Usr/local/sphinx/bin/indexer: error while loading shared libraries: libmysqlclient. so.18: cannot open shared object file: No such file or directory
Echo "/usr/local/mysql/lib/">/etc/ld. so. conf
Ldconfig

This command is used to create an index. Of course, the data base is the just-imported example. if an error occurs in SQL data, the biggest possible cause is your sphworkflow. the database configuration in conf is incorrect. You need to go back and check and correct it. However, the library files required by sphenders may fail to be found. For example, the following two errors may occur:
/Usr/local/sphinx/bin/indexer: error while loading shared libraries: libmysqlclient. so.15: cannot open shared object file: No such file or directory
/Usr/local/sphinx/bin/indexer: error while loading shared libraries: libiconv. so.2: cannot open shared object file: No such file or directory
This is mainly because you have not been able to configure the corresponding environment variables after installing some libraries. You can fix this issue by establishing a connection and run the following command:
Ln-s/usr/local/mysql/lib/libmysqlclient. so.15/usr/lib/libmysqlclient. so.15
Ln-s/usr/local/lib/libiconv. so.2/usr/lib/libiconv. so.2
Here, we assume that your software package is installed in the/usr/local/xxx directory. If you are not installed in the directory, you need to use your own path. If you have not installed the libiconv package, you need to install it. This installation is simple and I will not talk about it.
If a similar error occurs, correct it according to the above method.

$ Cd/usr/local/sphinx/etc
$/Usr/local/sphinx/bin/search test



The above command is a search test, and the keyword of the test is test. If the test succeeds, you should see the search result. The string "index 'test1': query 'test' appears ': returned 3 matches of 3 total in 0.000 sec ", followed by the result indicating that the operation was successful.

$ Cd/usr/local/sphinx/etc
$/Usr/local/sphinx/bin/searchd

Run the preceding command to start the sphinx process. If there is no error, you can find the sphinx process through ps-aux | grep '000000. Haha, you're done!

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.