ITPub博客

首页 > Linux操作系统 > Linux操作系统 > solaris 10 下安装MySQL过程记录

solaris 10 下安装MySQL过程记录

原创 Linux操作系统 作者:adrain_001 时间:2012-04-01 22:13:14 0 删除 编辑

1.  下载mysql安装包,示例:

wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gz

2.  安装依赖库(依赖包见E:\软件工具\mysql\mysql_pkg

gcc的安装方法:

(1)    建立系统文件

#cp /etc/skel/local.profile /.profile

(2)    .profile中添加如下内容:

PATH=/usr/bin:/usr/local/bin:/usr/ucb:/etc:/usr/sbin:/usr/bin:/usr/sfw/bin:/usr/ccs/bin:/opt/csw/bin:.

export PATH

export PS1='\u:\w#'

(3)    solaris 10安装光盘中安装如下工具包:

# pkgadd –d /cdrom/Solaris_10/Product SUNWwgetr
# pkgadd –d /cdrom/Solaris_10/Product SUNWwgetu
# pkgadd –d /cdrom/Solaris_10/Product SUNWwgetS
# pkgadd –d /cdrom/Solaris_10/Product SUNWgcmn

(4)    下载gcc文件

# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/gcc-3.4.6-sol10-x86-local.gz

# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/libiconv-1.11-sol10-x86-local.gz

# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/libgcc-3.4.6-sol10-x86-local.gz

# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/libintl-3.4.0-sol10-x86-local.gz

(5)    解压安装

# gunzip gcc-3.4.6-sol10-x86-local.gz

# gunzip libiconv-1.11-sol10-x86-local.gz

# gunzip libgcc-3.4.6-sol10-x86-local.gz

# gunzip libintl-3.4.0-sol10-x86-local.gz

#pkgadd -d gcc-3.4.6-sol10-x86-local

#pkgadd -d libiconv-1.11-sol10-x86-local.gz

#pkgadd -d libgcc-3.4.6-sol10-x86-local.gz

#pkgadd -d libintl-3.4.0-sol10-x86-local.gz

(6)    修改.profile文件

.profile文件中增加如下内容

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH

      (7) libstdc++.so.6libg2c.so.0libgcc_s.so.1/usr/local/lib拷到/usr/lib(根据情况,后面的过程出现相关ERROR信息时才执行此步。)

3.  安装MySQL-5.5.3-m3

//创建mysql用户组

#groupadd mysql

//创建用户mysql和相关目录。

# mkdir -p /data/mysqldata
# mkdir -p /data/mysqldata/database
# mkdir -p /data/mysqldata/log
# mkdir -p /data/mysqldata/pid

#mkdir –p /data/mysqldata/innodbdata //要检查是否创建成功

# useradd -g mysql -d /data/mysqldata/mysql -s /usr/bin/sh mysql

 

//解压安装包

#gunzip mysql-5.5.3-m3.tar.gz

#tar xvf mysql-5.5.3-m3.tar

//建立链接,进入解压后的文件目录

#cd mysql-5.5.3-m3

//配置

#./configure --prefix=/usr/local/mysql \

--enable-assembler \

--enable-thread-safe-client \

--enable-local-infile \

--with-big-tables \

--with-readline \

--with-ssl \

--with-embedded-server \

--with-plugins=partition,innobase,myisammrg \  #必须有此行否则不能用后面的存储引擎。

--with-extra-charsets=complex

,优先使用

#CFLAGS="-O3 -march=pentiumpro" CXX=gcc CXXFLAGS="-O3 -march=pentiumpro \

-felide-constructors" \

./configure --prefix=/usr/local/mysql \

--enable-assembler \

--with-extra-charsets=complex \

--enable-thread-safe-client \

--with-big-tables \

--with-readline \

--with-ssl \

--with-embedded-server \

--enable-local-infile \

--with-plugins=innobase \

--with-mysqld-ldflags=-all-static

#如果需要安装federated存储引擎,则用下面选项。

--with-federated-storage-engine

 

 //编译

#make

//安装

#make install

//设置配置文件,使MySQL程序可以从中读取启动选项。

#cp support-files/my-medium.cnf /etc/my.cnf

//如果想要配置为支持InnoDB表,应当编辑/etc/my.cnf文件,去掉innodb_...开始选项行前面的#符,并将选项值改为你想要的。

//vi /etc/my.cnf

 

# Example MySQL config file for medium systems.

#

# This is for a system with little memory (32M - 64M) where MySQL plays

# an important part, or systems up to 128M where MySQL is used together with

# other programs (such as a web server)

#

# You can copy this file to

# /etc/my.cnf to set global options,

# mysql-data-dir/my.cnf to set server-specific options (in this

# installation this directory is /usr/local/mysql/var) or

# ~/.my.cnf to set user-specific options.

#

# 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          = /tmp/mysql.sock

 

# Here follows entries for some specific programs

 

# The MySQL server

[mysqld]

port            = 3306

socket          = /tmp/mysql.sock

basedir         = /usr/local/mysql

datadir         = /data/mysqldata/database

log-error       = /data/mysqldata/log/mysql_error.log

pid-file        = /data/mysqldata/pid/mysql.pid

#避免MySQL的外部锁定,减少出错几率,增强稳定性。

#skip-locking

skip-external-locking

#键值缓冲区,一般用来缓冲MyISAM表的索引块,key_buffer_size的最大允许值为4GB,通常为机器内存的25%

key_buffer_size = 16M

#服务所能处理的请求包的最大大小,以及服务所能处理的最大请求大小。包消息缓冲区初始化为net_buffer_length字节,但需要时可以增长到max_allowed_packet字节。该值默认很小,以捕获大的(可能是错误的)数据包。

#如果使用大的BLOB列或长字符串,则必须增加该值,应同想要使用的最大的BLOB一样大。Max_allow_packet的协议的限制值为1GB

max_allowed_packet = 1M

#排序缓冲用来处理类似ORDER BYGROUP BY队列所引起的排序操作,在排序发生时由每个线程分配。

sort_buffer_size = 512K

#在查询之间将通信缓冲区重设为该值。一般不需改变,如果内存很小,可将其设置为期望的客户端发送的SQL语句的长度,如果语句超出该长度,缓冲区自动扩大,知道max_allow_pocket字节。

net_buffer_length = 8K

#用来做MyISAM表全表扫描的缓冲大小。每个线程连续扫描时为扫描的每个表分配的缓冲区的大小(字节),如果进行多次连续扫描,可能需要增加该值。默认值为131072

read_buffer_size = 256K

#在排序之后,从一个已经排序号的序列中读取行时,行数据将从这个缓冲区中来读取以防止磁盘寻道,避免搜索硬盘。将该变量设置为较大的值可以大大改进ORDER BY的性能,当需要时由每个线程分配。但是这个为每个客户端分配的缓冲区,因此不应将全局变量设置为较大的值,只为需要运行大查询的客户端更改会话变量。

read_rnd_buffer_size = 512K

#MySQL需要在REPAIR,OPTIMIZE,ALTER以及LOAD DATA INFILE到一个空表中引起重建索引时分配的缓冲区。这在每个线程中被分配,所以在设置大值时需要小心。

myisam_sort_buffer_size = 8M

 

# 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不帧听TCP/IP连接。

#skip-networking

 

# Replication Master Server (default)

# binary logging is required for replication

#二进制日志文件。将更改数据的所有查询记入该文件,用于备份和复制。

#建议指定一个文件名,否则MySQL使用host_name-bin作为日志文件基本名。

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

#唯一的服务辨识号,此值在masterslave上都需要设置。忽略此项,MySQL不会作为master生效。

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=, MASTER_PORT=,

#    MASTER_USER=, MASTER_PASSWORD= ;

#

#    where you replace , , by quoted strings and

#    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     =  

#

# The username the slave will use for authentication when connecting

# to the master - required

#master-user     =  

#

# The password the slave will authenticate with when connecting to

# the master - required

#master-password =  

#

# The port the master is listening on.

# optional - defaults to 3306

#master-port     = 

#

# binary logging - not required for slaves, but recommended

#log-bin=mysql-bin

 

# Point the following paths to different dedicated disks

#tmpdir         = /tmp/

#log-update     = /path-to-dedicated-directory/hostname

 

# Uncomment the following if you are using InnoDB tables

innodb_data_home_dir = /data/mysqldata/innodbdata

innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend

innodb_log_group_home_dir =/data/mysqldata/innodbdata

# innodb_log_arch_dir = /data/mysqldata/innodbdata 此行去掉。

#加上时抛错:120331 11:12:08 [ERROR] /usr/local/mysql/libexec/mysqld: unknown variable

# 'innodb_log_arch_dir=/data/mysqldata/innodbdata'

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

innodb_buffer_pool_size = 386M

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 = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

 

[mysqlhotcopy]

interactive-timeout

//将程序二进制的所有权改为root,数据目录的所有权改为mysql,将组属性改为mysql组。

///usr/local/mysql/.所属的组改为mysql

# chgrp -R mysql .

///usr/local/mysql/*中所有的文件的所有者改为root,组改为mysql
# chown -R root .

//将数据目录data/mysqldata/*的所有者改为mysql,组改为mysql
# chown -R mysql /data/mysqldata/*

初始化mysql数据库
# /usr/local/mysql/bin/mysql_install_db \
--basedir=/usr/local/mysql \
--datadir=/data/mysqldata/database \
--user=mysql

//libgcc_s.so.1/usr/local/lib拷到/usr/lib

启动和关闭mysql服务器

//启动服务
# /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

//

//root设置密码

#mysql

#update user set password=password('你的密码') where user='root';

#flush privileges;

//停止服务
# /usr/local/mysql/bin/mysqladmin -u root -p shutdown

 

//设置服务器启动时自动启动MySQL

cp /support-files/mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql

 

//root登录MySQL服务器

//因为root用户未设置密码,远程连接不上,需要本地登录

//mysql –u root -p

//建立启动脚本

vi /opt/mysql/run.sh

mysqld_safe --ledir=/usr/local/mysql/libexec --user=mysql &

//建立停止脚本

vi /opt/mysql/stop.sh

mysqladmin shutdown

  

安装完毕。

安装总结:
之所以耗费这么长时间才安装成功,原因在于以下几点,以后需注意:
1.solaris系统不熟。
2.出现错误急于去网络上寻找答案,没有认真读懂error log。

需改正的地方:
1.加强solaris、linux系统的学习,掌握内部原理。
2.出现问题及时查看错误日志,思考揣摩错误日志中的记录,然后自己试着调试,或者在网上查找相关解释。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26690043/viewspace-720204/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-02-13

  • 博文量
    113
  • 访问量
    259856