虚拟化容器,大数据,DBA,中间件,监控。

源码编译安装 MySQL 5.6.10最佳实践

22 10月
作者:admin|分类:DBA运维
源码编译安装 MySQL 5.6.10最佳实践



经过与cmake的参数对照之后,去除掉已经被取消的参数(大多数是因为新版本已经默认启用),cmake的参数配置如下:

cmake -DCMAKE_INSTALL_PREFIX=/usr/mysql \

 -DSYSCONFDIR=/usr/mysql/etc \

-DMYSQL_DATADIR=/usr/mysql/data \ -DMYSQL_TCP_PORT=3306 \

-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \

 -DMYSQL_USER=mysql \

-DEXTRA_CHARSETS=all \

-DWITH_READLINE=1 \

-DWITH_SSL=system \

-DWITH_EMBEDDED_SERVER=1 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITHOUT_PARTITION_STORAGE_ENGINE=1




4.1参数:
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 
在64位机器上编译不过,会出现如下错误:(64位机器的浮点数运算上出错,导致找不着相应的函数)
libsql.a(handler.cc.o): In function `get_ha_partition(partition_info*)’:
/data/mysql-5.5.14/sql/handler.cc:269: undefined reference to `ha_partition::ha_partition(handlerton*, partition_info*)’
/data/mysql-5.5.14/sql/handler.cc:271: undefined reference to `ha_partition::initialize_partition(st_mem_root*)’
libsql.a(sql_partition_admin.cc.o): In function
`Alter_table_truncate_partition_statement::execute(THD*)’:
/data/mysql-5.5.14/sql/sql_partition_admin.cc:165: undefined reference to `ha_partition::truncate_partition(Alter_info*, bool*)’ collect2: ld returned 1 exit status make[2]: *** [sql/mysqld] Error 1




make[1]: *** [sql/CMakeFiles/mysqld.dir/all] Error 2 make: *** [all] Error 2
4.2参数: -DWITH_SSL=bundled  
自mysql5.6.*及以后的版本都要默认带上此参数,

否则编译不过 ,相关贴子: https://github.com/santisaez/powerstack/issues/49 Use bundled SSL on CentOS-5
4.3安装执行
# tar xvf mysql-5.5.10.tar.gz 

# cd mysql-5.5.10
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5
-DSYSCONFDIR=/usr/local/mysql5.5/etc -DMYSQL_DATADIR=/usr/local/mysql5.5/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/usr/local/mysql5.5/mysqld.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_READLINE=1

-DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_SSL=bundled #make #make install 


5 设置
#cd support-files/  
拷贝配置文件:
#cp my-default.cnf /etc/my.cnf  
设置开机自动启动
#cp mysql.server /etc/rc.d/init.d/mysqld 
5.1
初始化数据库 


#/usr/local/mysql5.5/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql5.5 --datadir=/usr/local/mysql5.5data --user=mysql


5.2设置
#vi /etc/init.d/mysqld(编辑此文件,查找并修改以下变量内容:) basedir=/usr/local/mysql5.5 datadir=/var/mysql5.5/data 
加入启动项:
#chkconfig --add mysqld
#chkconfig --level 345 mysqld on 
5.3启动服务
#service mysqld start
如果文件夹:/usr/local/mysql5.5 是只读的,会报错: … …
2013-04-08 11:12:45 7886 [Note] IPv6 is not available.
2013-04-08 11:12:45 7886 [Note]   - '0.0.0.0' resolves to '0.0.0.0'; 2013-04-08 11:12:45 7886 [Note] Server socket created on IP: '0.0.0.0'.
2013-04-08 11:12:45 7886 [ERROR] Can't start server : Bind on unix socket: Permission denied 2013-04-08 11:12:45 7886 [ERROR] Do you already have another mysqld server running on socket: /usr/local/mysql5.5/mysqld.sock ?
2013-04-08 11:12:45 7886 [ERROR] Aborting …
2013-04-08 11:12:45 7886 [Note] InnoDB: Starting shutdown...
2013-04-08 11:12:47 7886 [Note] InnoDB: Shutdown completed; log sequence number 1626077 2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'BLACKHOLE'
2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' 2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'ARCHIVE' 2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'CSV'
2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'MRG_MYISAM' 2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'MyISAM' 2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'MEMORY'
2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'sha256_password' 2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'mysql_old_password' 2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'mysql_native_password' 2013-04-08 11:12:47 7886 [Note] Shutting down plugin 'binlog'
2013-04-08 11:12:47 7886 [Note] /usr/local/mysql5.5/bin/mysqld: Shutdown complete 
130408 11:12:47 mysqld_safe mysqld from pid file /usr/local/mysql5.5/data/zskw2.pid ended 
解决办法:将/usr/local/mysql5.5设为读写即可 …


5.4 设置密码
#/usr/local/mysql/bin/mysqladmin password [new-password]  
6
数据库初始化
如果想让数据库可远程访问,必须在库中mysql下的user里存在如下用户 Host  
user  password

root 
xxx
7
附录
7.1参考网址
http://www.centos.bz/2011/09/linux-compile-install-mysql-5-5-15-from-source/
http://blog.csdn.net/sunjingzhi/article/details/6671668 https://github.com/santisaez/powerstack/issues/49 http://heylinux.com/archives/993.html
http://www.mysqlops.com/2011/03/06/mysql_compile_reference.html http://who0168.blog.51cto.com/253401/469898 
7.2
所用my.cnf
# Example MySQL config file for large systems. #
# This is for a large system with memory = 512M where the system runs mainly # MySQL. #
# MySQL programs look for option files in a set of # locations which depend on the deployment platform. # You can copy this option file to one of those
# locations. For information about these locations, see: # http://dev.mysql.com/doc/mysql/en/option-files.html #
# In this file, you can use all long options that a program supports. # If you want to know which options a program supports, run the program # with the "--help" option. 
# The following options will be passed to all MySQL clients





 
[client] #password = your_password
port  = 3306
#socket 
= /var/lib/mysql/mysql.sock socket 
= /usr/local/mysql5.5/mysqld.sock #character-set-server = utf8
# Here follows entries for some specific programs 
# The MySQL server [mysqld] port  = 3306
#socket  = /var/lib/mysql/mysql.sock socket 
= /usr/local/mysql5.5/mysqld.sock user=mysql
 
skip-external-locking key_buffer_size = 256M max_allowed_packet = 1M table_open_cache = 256 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency thread_concurrency = 8 #character-set-server = utf8 max_connections = 1000
# Don't listen on a TCP/IP port at all. This can be a security enhancement, # if all processes that need to connect to mysqld run on the same host. # All interaction with mysqld must be made via Unix sockets or named pipes. # Note that using this option without enabling named pipes on Windows # (via the "enable-named-pipe" option) will render mysqld useless! # 
#skip-networking 
# Replication Master Server (default) # binary logging is required for replication log-bin=mysql-bin 
# binary logging format - mixed recommended binlog_format=mixed 
# required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted server-id = 1





 
 
# Replication Slave (comment out master section to use this) #
# To configure this host as a replication slave, you can choose between # two methods : #
# 1) Use the CHANGE MASTER TO command (fully described in our manual) - #    the syntax is: #
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, #    MASTER_USER=<user>, MASTER_PASSWORD=<password>  #
#    where you replace <host>, <user>, <password> by quoted strings and #    <port> by the master's port number (3306 by default). #
#    Example: #
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, #    MASTER_USER='joe', MASTER_PASSWORD='secret'; # # OR #
# 2) Set the variables below. However, in case you choose this method, then #    start replication for the first time (even unsuccessfully, for example #    if you mistyped the password in master-password and the slave fails to #    connect), the slave will create a master.info file, and any later #    change in this file to the variables' values below will be ignored and #    overridden by the content of the master.info file, unless you shutdown #    the slave server, delete master.info and restart the slaver server. #    For that reason, you may want to leave the lines below untouched #    (commented) and instead use CHANGE MASTER TO (see above) #
# required unique id between 2 and 2^32 - 1 # (and different from the master) # defaults to 2 if master-host is set # but will not function as a slave if omitted #server-id       = 2 #
# The replication master for this slave - required #master-host     =   <hostname> #
# The username the slave will use for authentication when connecting # to the master - required
#master-user     =   <username> #
# The password the slave will authenticate with when connecting to # the master - required





 
#master-password =   <password> #
# The port the master is listening on. # optional - defaults to 3306 #master-port     =  <port> #
# binary logging - not required for slaves, but recommended #log-bin=mysql-bin 
# Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /var/lib/mysql # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 256M
#innodb_additional_mem_pool_size = 20M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 64M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 
[mysqldump] quick
max_allowed_packet = 16M  [mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL #safe-updates 
[myisamchk]
key_buffer_size = 128M sort_buffer_size = 128M read_buffer = 2M write_buffer = 2M 
[mysqlhotcopy] interactive-timeout




浏览2621 评论0
返回
目录
返回
首页
双网卡双IP电信网通 配置图解 mysql5.6源代码编译安装