免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
1234下一页
最近访问板块 发新帖
查看: 27120 | 回复: 30
打印 上一主题 下一主题

线上连载讨论:数据库运维之MySQL初级应用(有奖) [复制链接]

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
1 [报告]
发表于 2011-09-20 15:48 |显示全部楼层
沙发...

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
2 [报告]
发表于 2011-09-20 15:51 |显示全部楼层
沙发不白抢,抛砖引玉...mysql 5.1版,编译参数

DIR_MYSQL=/usr/local/mysql
设置一个环境变量,修改目录时,可少改两次

./configure \
--prefix=$DIR_MYSQL \
--datadir=$DIR_MYSQL/data \
--with-unix-socket-path=$DIR_MYSQL/data/mysql.sock \
--with-tcp-port=3306 \
--with-mysqld-user=mysql \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--with-innodb \
--without-bench \
--without-debug \
--enable-assembler \
--with-pthread \
--enable-thread-safe-client \
--with-plugins=innodb_plugin \

编译参数解释:
--with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static
    Extra linking arguments for client/mysqld
--without-bench
    Skip building of the benchmark suite
--without-debug
    Build a production version without debugging code
--enable-assembler
    Use assembler versions of some string functions if available
--with-pthread
    Force use of pthread library
--enable-thread-safe-client
    如果客户端程序使用线程,则使用该配置选项来编译线程安全版的MySQL客户端库。
    将创建一个libmysqlclient_r库,可以用来连接应用程序线程。
    参考<如何生成线程客户端>http://dev.mysql.com/doc/refman/5.1/zh/apis.html#threaded-clients
--with-plugins=innodb_plugin
    加载innodb_plugin插件

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
3 [报告]
发表于 2011-09-20 16:06 |显示全部楼层
回复 5# leo_ss_pku_cu


      对想做运维DBA的人来说,是非常好的建议,感谢
{:3_189:}

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
4 [报告]
发表于 2011-09-20 16:14 |显示全部楼层
本帖最后由 ning_lianjie 于 2011-09-20 18:32 编辑

回复 4# yahoon


    对于cmake,暂时还没研究,5.5改用它来编译了...听说效率很高,以后去研究一下,先把干活的学会再说,哈哈

1,cmake安装
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
tar -xzf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure
make
make install

2,mysql 5.5安装

DIR_MYSQL='/usr/local/mysql'
设置一个环境变量,MySQL安装路径

/usr/local/bin/cmake .  \
-DMYSQL_DATADIR=$DIR_MYSQL/data\
-DMYSQL_UNIX_ADDR=$DIR_MYSQL/data/mysql.sock\
-DINSTALL_LAYOUT=STANDALONE\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DEXTRA_CHARSETS=all\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_READLINE=1\
-DENABLED_LOCAL_INFILE=1\
-DMYSQL_TCP_PORT=3306\
-DWITH_DEBUG=0

编译参数解释:
 -DCMAKE_INSTALL_PREFIX= 指定安装路径
 -DMYSQL_DATADIR= 指定数据存放目录
 -DINSTALL_LAYOUT=STANDALONE 指定安装布局,tar.gz包安装,默认为STANDALONE
 -DDEFAULT_CHARSET=utf8 指定默认字符集
 -DDEFAULT_COLLATION=utf8_general_ci 指定字符集编码
 -DEXTRA_CHARSETS=all 全字符集支持
 -DWITH_INNOBASE_STORAGE_ENGINE=1 安装InnoDB引擎(The MyISAM, MERGE, MEMORY, and CSV engines are mandatory (always compiled into the server) and need not be installed explicitly.)
 -DWITH_READLINE=1 使用readline库,与捆绑分布。Whether to use the readline library bundled with the distribution.
 -DENABLED_LOCAL_INFILE=1 允许从文件中加载数据
 -DMYSQL_UNIX_ADDR=指定socket路径,默认在/tmp/mysql.socket
 -DMYSQL_TCP_PORT=3306
 -DWITH_DEBUG=0 关闭Debug

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
5 [报告]
发表于 2011-09-20 17:13 |显示全部楼层
回复 8# chenyx


    线上环境一般是不允许是其他客户端的,只能用程序,或者mysql client

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
6 [报告]
发表于 2011-09-20 18:18 |显示全部楼层
回复 11# chenyx


很好的规范,晒出个命令,供参考:
创建一个名字为test_user的用户,允许从任何地方登录,拥有test下的所有权限

mysql> GRANT ALL PRIVILEGES ON test.* TO 'test_user'@'%' IDENTIFIED BY PASSWORD '123456'

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
7 [报告]
发表于 2011-09-21 22:58 |显示全部楼层
回复 18# yahoon


    一个帮助设置系统的脚本

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
8 [报告]
发表于 2011-09-21 23:01 |显示全部楼层
回复 14# kns1024wh


    强

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
9 [报告]
发表于 2011-09-22 08:41 |显示全部楼层
回复 14# kns1024wh


    设置mysql.server启动脚本时,可以把如下参数设置完整,为单机多实例打下基础

编辑/etc/init.d/mysql_1.server 启动文件,修改如下参数
46行 ,basedir=/home/q/mysql_1
47行 ,datadir=/home/q/mysql_1/data
60行 ,server_pid_file=/home/q/mysql_1/data/mysql.pid
330行, $bindir/mysqld_safe --defaults-file=/etc/my_1.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
10 [报告]
发表于 2011-09-23 10:05 |显示全部楼层
回复 23# chenyx


    socket连接要比IP地址效率高
参考
http://dev.mysql.com/doc/refman/ ... nect-to-server.html
"A Unix socket file connection is faster than TCP/IP, but can be used only when connecting to a server on the same computer. A Unix socket file is used if you don't specify a host name or if you specify the special host name localhost"
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP