CentOS 6.4编译安装Percona 5.6.16
Percona 下载地址:
http://www.percona.com
一、卸载原有MySQL
检查是否安装有MySQL Server:
rpm -qa | grep mysql
删除方法:
rpm -e mysql #普通删除模式
rpm -e --nodeps mysql #强行删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其强行删除。
二、安装编译环境
yum -y install gcc gcc-c++ make cmake automake autoconf libxml2 libxml2-devel zlib zlib-devel ncurses ncurses-devel
三、安装MySQL
1,设置权限
groupadd mysql
useradd mysql -g mysql
2,设置安装环境
#为保证数据安全,将数据单独存盘于/data目录下
mkdir /usr/local/mysql
mkdir /data/mysql
cd /data/mysql
mkdir run data tmp logs
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /data/mysql
3,安装Percona 5.6.16
tar zxvf Percona-Server-5.6.16-64.2.tar.gz
cd Percona-Server-5.6.16.64.2
cmake . -LH #查看有哪些编绎参数
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ #设置程序安装路径
-DMYSQL_DATADIR=/data/mysql/data \ #设置数据存放路径
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \ #启用MYISAM存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \ #启用MySQL快捷键
-DMYSQL_UNIX_ADDR=/data/mysql/run/mysqld.sock \ #设置套接字存放位置
-DMYSQL_TCP_PORT=3306 \ #设置开放端口
-DENABLED_LOCAL_INFILE=1 \ #设置读取本地文件
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 \ #默认字符串
-DDEFAULT_COLLATION=utf8_general_ci #默认检验规则
#以上代码为方便查看,若直接执行,可使用下面代码
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/data/mysql/run/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install
4,安装完成Percona 5.6.16后,开始建立配置文件。
chown mysql:mysql /etc/my.cnf
vim /etc/my.cnf
[client]
#password = your_password
port = 3306
socket = /data/mysql/run/mysql.sock
default-character-set=utf8
[mysqld]
port = 3306
socket = /data/mysql/run/mysql.sock
baserdir = /usr/local/mysql
datadir = /data/mysql/data
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
default-storage-engine = InnoDB
character_set_server = utf8
tmpdir = /data/mysql/tmp/
log-bin=/data/mysql/logs/mysql-bin
expire_logs_days= 14
binlog_format=mixed
log-error = /data/mysql/logs/error.log
slow-query-log = 1
long_query_time= 3
slow_query_log_file = /data/mysql/logs/slow.log
server-id = 1
innodb_data_home_dir = /data/mysql/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql/logs
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
innodb_file_per_table = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
5,初始MySQL配置表(用户权限表等)
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql
6,设置开机启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
chkconfig --level 345 mysql on
7,修改Path变量
echo ’export PATH=/app/mysql/bin:$PATH’ >> /etc/profile
启用PATH
. /etc/profile
#or
source /etc/profile
8,启动MySQL,并设置密码
service mysql start
mysqladmin -uroot password '******'
至此,成功安装Percona 5.6.16。