percona mysql5.5源码安装过程

author:skate
time:2012/06/27

 

percona mysql5.5源码安装过程

 

安装步骤:

 

方法一: source RPM安装

shell> rpmbuild --rebuild --clean MySQL-VERSION.src.rpm

然后找到编译的rpm包,执行即可

 

方法二:源码编译安装


# 创建用户/用户组
shell> groupadd mysql
shell> useradd -r -g mysql mysql


# 开始编译
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .  //In MySQL 5.5, CMake is used as the build framework on all platforms
shell> make
shell> make install DESTDIR=“/data/mysql”  //默认路径是“/usr/local/mysql”

# 开始配置安装
shell> cd /data/mysql/usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data

# 制作my.cnf配置文件
shell> cp support-files/my-medium.cnf /etc/my.cnf

#启动mysqld服务
shell> bin/mysqld_safe --user=mysql &


# 配置mysqld的service服务
shell> cp support-files/mysql.server /etc/init.d/mysql.server
shell> chmod a+x /etc/init.d/mysql.server
shell> chkconfig --add mysql.server
shell> service mysql.server status


案例:

下载:
Percona-Server-5.5.19-rel24.0.tar.gz:
http://www.percona.com/redir/downloads/Percona-Server-5.5/Percona-Server-5.5.19-24.0/source/Percona-Server-5.5.19-rel24.0.tar.gz

Percona-Server-55-5.5.19-rel24.0.204.rhel5.src.rpm:
http://www.percona.com/redir/downloads/Percona-Server-5.5/Percona-Server-5.5.19-24.0/source/Percona-Server-55-5.5.19-rel24.0.204.rhel5.src.rpm

 

方法一: 这个方法比较简单, 这里掠过



方法二:源码编译安装
解压:
[root@localhost data]# tar -zxvf Percona-Server-5.5.24-rel26.0.tar.gz
[root@localhost data]# cd /data/Percona-Server-5.5.24-rel26.0
[root@localhost Percona-Server-5.5.24-rel26.0]# cmake .
[root@localhost Percona-Server-5.5.24-rel26.0]# make
[root@localhost Percona-Server-5.5.24-rel26.0]# make install DESTDIR="/data/mysql"

至此mysql已经被编译安装到“/data/mysql”下

[root@localhost Percona-Server-5.5.24-rel26.0]# cd /data/mysql/usr/local/mysql/

[root@localhost mysql]# ll
total 72
drwxr-xr-x  2 root root  4096 Jun 27 10:10 bin
-rw-r--r--  1 root root 17987 May 30 01:42 COPYING
drwxr-xr-x  4 root root  4096 Jun 27 10:09 data
drwxr-xr-x  2 root root  4096 Jun 27 10:09 docs
drwxr-xr-x  3 root root  4096 Jun 27 10:09 include
-rw-r--r--  1 root root   316 May 30 01:42 INSTALL-BINARY
drwxr-xr-x  3 root root  4096 Jun 27 10:09 lib
drwxr-xr-x  4 root root  4096 Jun 27 10:10 man
drwxr-xr-x 10 root root  4096 Jun 27 10:10 mysql-test
-rw-r--r--  1 root root  2552 May 30 01:42 README
drwxr-xr-x  2 root root  4096 Jun 27 10:10 scripts
drwxr-xr-x 27 root root  4096 Jun 27 10:10 share
drwxr-xr-x  4 root root  4096 Jun 27 10:10 sql-bench
drwxr-xr-x  2 root root  4096 Jun 27 10:10 support-files


[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .


[root@localhost mysql]# ll
total 72
drwxr-xr-x  2 mysql mysql  4096 Jun 27 10:10 bin
-rw-r--r--  1 mysql mysql 17987 May 30 01:42 COPYING
drwxr-xr-x  4 mysql mysql  4096 Jun 27 10:09 data
drwxr-xr-x  2 mysql mysql  4096 Jun 27 10:09 docs
drwxr-xr-x  3 mysql mysql  4096 Jun 27 10:09 include
-rw-r--r--  1 mysql mysql   316 May 30 01:42 INSTALL-BINARY
drwxr-xr-x  3 mysql mysql  4096 Jun 27 10:09 lib
drwxr-xr-x  4 mysql mysql  4096 Jun 27 10:10 man
drwxr-xr-x 10 mysql mysql  4096 Jun 27 10:10 mysql-test
-rw-r--r--  1 mysql mysql  2552 May 30 01:42 README
drwxr-xr-x  2 mysql mysql  4096 Jun 27 10:10 scripts
drwxr-xr-x 27 mysql mysql  4096 Jun 27 10:10 share
drwxr-xr-x  4 mysql mysql  4096 Jun 27 10:10 sql-bench
drwxr-xr-x  2 mysql mysql  4096 Jun 27 10:10 support-files
[root@localhost mysql]#

安装mysql系统表
[root@localhost mysql]# scripts/mysql_install_db  --user=mysql
Installing MySQL system tables...
120627 10:24:00 [Note] Flashcache bypass: disabled
120627 10:24:00 [Note] Flashcache setup error is : ioctl failed

OK
Filling help tables...
120627 10:24:01 [Note] Flashcache bypass: disabled
120627 10:24:01 [Note] Flashcache setup error is : ioctl failed

OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

Percona recommends that all production deployments be protected with a support
contract (http://www.percona.com/mysql-suppport/) to ensure the highest uptime,
be eligible for hot fixes, and boost your team's productivity.
[root@localhost mysql]#


[root@localhost mysql]# chown -R root .
[root@localhost mysql]# ll
total 72
drwxr-xr-x  2 root mysql  4096 Jun 27 10:10 bin
-rw-r--r--  1 root mysql 17987 May 30 01:42 COPYING
drwxr-xr-x  5 root mysql  4096 Jun 27 10:24 data
drwxr-xr-x  2 root mysql  4096 Jun 27 10:09 docs
drwxr-xr-x  3 root mysql  4096 Jun 27 10:09 include
-rw-r--r--  1 root mysql   316 May 30 01:42 INSTALL-BINARY
drwxr-xr-x  3 root mysql  4096 Jun 27 10:09 lib
drwxr-xr-x  4 root mysql  4096 Jun 27 10:10 man
drwxr-xr-x 10 root mysql  4096 Jun 27 10:10 mysql-test
-rw-r--r--  1 root mysql  2552 May 30 01:42 README
drwxr-xr-x  2 root mysql  4096 Jun 27 10:10 scripts
drwxr-xr-x 27 root mysql  4096 Jun 27 10:10 share
drwxr-xr-x  4 root mysql  4096 Jun 27 10:10 sql-bench
drwxr-xr-x  2 root mysql  4096 Jun 27 10:10 support-files

[root@localhost mysql]# chown -R mysql data
[root@localhost mysql]# ll
total 72
drwxr-xr-x  2 root  mysql  4096 Jun 27 10:10 bin
-rw-r--r--  1 root  mysql 17987 May 30 01:42 COPYING
drwxr-xr-x  5 mysql mysql  4096 Jun 27 10:24 data
drwxr-xr-x  2 root  mysql  4096 Jun 27 10:09 docs
drwxr-xr-x  3 root  mysql  4096 Jun 27 10:09 include
-rw-r--r--  1 root  mysql   316 May 30 01:42 INSTALL-BINARY
drwxr-xr-x  3 root  mysql  4096 Jun 27 10:09 lib
drwxr-xr-x  4 root  mysql  4096 Jun 27 10:10 man
drwxr-xr-x 10 root  mysql  4096 Jun 27 10:10 mysql-test
-rw-r--r--  1 root  mysql  2552 May 30 01:42 README
drwxr-xr-x  2 root  mysql  4096 Jun 27 10:10 scripts
drwxr-xr-x 27 root  mysql  4096 Jun 27 10:10 share
drwxr-xr-x  4 root  mysql  4096 Jun 27 10:10 sql-bench
drwxr-xr-x  2 root  mysql  4096 Jun 27 10:10 support-files

配置my.cnf配置文件
[root@localhost mysql]# cp support-files/my-medium.cnf  /etc/my.cnf
[root@localhost mysql]# bin/mysqld_safe --user=mysql &
[1] 11934
[root@localhost mysql]# 120627 10:27:18 mysqld_safe Logging to '/data/mysql/usr/local/mysql/data/localhost.err'.
120627 10:27:18 mysqld_safe Starting mysqld daemon with databases from /data/mysql/usr/local/mysql/data

在另外一个窗口配置mysql的service服务

[root@localhost Percona-Server-5.5.24-rel26.0]# cp support-files/mysql.server /etc/init.d/mysql.server

[root@localhost Percona-Server-5.5.24-rel26.0]# chmod a+x /etc/init.d/mysql.server
[root@localhost Percona-Server-5.5.24-rel26.0]# chkconfig --add mysql.server
[root@localhost Percona-Server-5.5.24-rel26.0]# service mysql.server status
MySQL (Percona Server) is not running[FAILED]
[root@localhost Percona-Server-5.5.24-rel26.0]# service mysql.server restart
MySQL (Percona Server) PID file could not be found![FAILED]
Starting MySQL (Percona Server)..The server quit without updating PID file (/usr/local/mysql/data/localhost.pid).[FAILED]
我安装的路径是在”/data/mysql“下,说明路径不对,需要修改脚本“mysql.server”中变量“basedir”和”bindir“,然后在restart即可。

[root@localhost Percona-Server-5.5.24-rel26.0]# service mysql.server restart
Shutting down MySQL (Percona Server)...[  OK  ]
Starting MySQL (Percona Server)...[  OK  ]


服务已经启动了,用mysql客户端登录验证下
root@localhost Percona-Server-5.5.24-rel26.0]# cd /data/mysql/usr/local/mysql/
[root@localhost mysql]# ll
total 72
drwxr-xr-x  2 root  mysql  4096 Jun 27 10:10 bin
-rw-r--r--  1 root  mysql 17987 May 30 01:42 COPYING
drwxr-xr-x  5 mysql mysql  4096 Jun 27 10:37 data
drwxr-xr-x  2 root  mysql  4096 Jun 27 10:09 docs
drwxr-xr-x  3 root  mysql  4096 Jun 27 10:09 include
-rw-r--r--  1 root  mysql   316 May 30 01:42 INSTALL-BINARY
drwxr-xr-x  3 root  mysql  4096 Jun 27 10:09 lib
drwxr-xr-x  4 root  mysql  4096 Jun 27 10:10 man
drwxr-xr-x 10 root  mysql  4096 Jun 27 10:10 mysql-test
-rw-r--r--  1 root  mysql  2552 May 30 01:42 README
drwxr-xr-x  2 root  mysql  4096 Jun 27 10:10 scripts
drwxr-xr-x 27 root  mysql  4096 Jun 27 10:10 share
drwxr-xr-x  4 root  mysql  4096 Jun 27 10:10 sql-bench
drwxr-xr-x  2 root  mysql  4096 Jun 27 10:10 support-files
[root@localhost mysql]# bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.24-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select version();
+------------+
| version()  |
+------------+
| 5.5.24-log |
+------------+
1 row in set (0.00 sec)


mysql> select @@innodb_version;
+------------------+
| @@innodb_version |
+------------------+
| 1.1.8-20.1       |
+------------------+
1 row in set (0.00 sec)

mysql> show plugins;
+--------------------------------+--------+--------------------+---------+---------+
| Name                           | Status | Type               | Library | License |
+--------------------------------+--------+--------------------+---------+---------+
| binlog                         | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
| mysql_native_password          | ACTIVE | AUTHENTICATION     | NULL    | GPL     |
| mysql_old_password             | ACTIVE | AUTHENTICATION     | NULL    | GPL     |
| MEMORY                         | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
| MyISAM                         | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
| CSV                            | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
| MRG_MYISAM                     | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
| PERFORMANCE_SCHEMA             | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
| InnoDB                         | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
| INNODB_RSEG                    | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_TRX                     | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_LOCKS                   | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_LOCK_WAITS              | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP                     | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_RESET               | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMPMEM                  | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMPMEM_RESET            | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLES              | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLESTATS          | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_INDEXES             | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_COLUMNS             | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FIELDS              | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FOREIGN             | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FOREIGN_COLS        | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_STATS               | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_TABLE_STATS             | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_INDEX_STATS             | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_POOL_PAGES       | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_POOL_PAGES_INDEX | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_POOL_PAGES_BLOB  | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| XTRADB_ADMIN_COMMAND           | ACTIVE | INFORMATION SCHEMA | NULL    | GPL     |
| partition                      | ACTIVE | STORAGE ENGINE     | NULL    | GPL     |
+--------------------------------+--------+--------------------+---------+---------+
32 rows in set (0.01 sec)

mysql>

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                                    | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                                         | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| MyISAM             | YES     | MyISAM storage engine                                                      | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                                         | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                                      | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables                  | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
6 rows in set (0.00 sec)

 

更改环境变量
[root@localhost Percona-Server-5.5.24-rel26.0]# vi /root/.bash_profile
PATH=/data/mysql/usr/local/mysql/bin:$PATH:$HOME/bin


[root@localhost ~]# mysqladmin -uroot -p status
Enter password:
Uptime: 4567  Threads: 2  Questions: 13  Slow queries: 0  Opens: 33  Flush tables: 1  Open tables: 26  Queries per second avg: 0.002
[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.24-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

 

 

----end----

 

 

 

参考:http://dev.mysql.com/doc/refman/5.5/en/installing-source-distribution.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值