Mysql 参数优化

一、Mysql 源码编译参数 shell > yum -y install gcc gcc-c++ make cmake ncurses-devel zlib-devel bison shell > cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DTMPDIR=/usr/local/mysql/data \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \ -DSYSCONFDIR=/etc/my.cnf \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DDEFAULT_CHARSET=utf8 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_COLLATION=utf8_general_ci ## -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 指定 Mysql 安装路径 ## -DMYSQL_DATADIR=/usr/local/mysql/data 指定 Mysql 数据目录 ## -DTMPDIR=/usr/local/mysql/data 指定 Mysql 临时目录 ## -DMYSQL_UNIX_ADDR 指定 Mysql socket ## -DSYSCONFDIR=/etc/my.cnf 指定 Mysql 配置文件 ## -DWITH_MYISAM_STORAGE_ENGINE=1 安装 MyISAM 存储引擎 ## -DWITH_INNOBASE_STORAGE_ENGINE=1 安装 Innodb 存储引擎 ## -DWITH_FEDERATED_STORAGE_ENGINE=1 安装 Federated 存储引擎 ## -DDEFAULT_CHARSET=utf8 指定默认字符集为 utf8 ## -DEXTRA_CHARSETS=all 安装扩展字符集 ## -DDEFAULT_COLLATION=utf8_general_ci 默认排序规则 utf8_general_ci Cmake 参数:http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html --------------------------------------------------------------------------------------------- 二、my.cnf 配置文件 ## global_buffers 在内存中缓存从数据文件中检索出来的数据块,可以大大提高查询和更新数据的性能 ## 计算公式:Innodb_buffer_pool_size +...
阅读全文

使用C/C++扩展Python

翻译: by gashero 如果你会用C,实现Python嵌入模块很简单。利用扩展模块可做很多Python不方便做的事情,他们可以直接调用C库和系统调用。 为了支持扩展,Python API定义了一系列函数、宏和变量,提供了对Python运行时系统的访问支持。Python的C API由C源码组成,并包含 “Python.h” 头文件。 编写扩展模块与你的系统相关,下面会详解。 1 一个简单的例子 下面的例子创建一个叫做 “spam” 的扩展模块,调用C库函数 system() 。这个函数输入一个NULL结尾的字符串并返回整数,可供Python调用方式如下: >>> import spam >>> status=spam.system("ls -l") 一个C扩展模块的文件名可以直接是 模块名.c 或者是 模块名module.c 。第一行应该导入头文件: #include <Python.h> 这会导入Python API。 Warning 因为Python含有一些预处理定义,所以你必须在所有非标准头文件导入之前导入Python.h 。 Python.h中所有用户可见的符号都有 Py 或 PY 的前缀,除非定义在标准头文件中。为了方便 “Python.h” 也包含了一些常用的标准头文件,包括<stdio.h>,<string.h>,<errno.h>,<stdlib.h>。如果你的系统没有后面的头文件,则会直接定义函数 malloc() 、 free() 和 realloc() 。 下面添加C代码到扩展模块,当调用 “spam.system(string)” 时会做出响应: static PyObject* spam_system(PyObject* self, PyObject* args) { const char* command; int sts; if (!PyArg_ParseTuple(args,"s",&command)) return NULL; sts=system(command); return Py_BuildValue("i",sts); } 调用方的Python只有一个命令参数字符串传递到C函数。C函数总是有两个参数,按照惯例分别叫做 self 和 args 。 self 参数仅用于用C实现内置方法而不是函数。本例中, self 总是为NULL,因为我们定义的是个函数,不是方法。这一切都是相同的,所以解释器也就不需要刻意区分两种不同的C函数。 args 参数是一个指向Python的tuple对象的指针,包含参数。每个tuple子项对应一个调用参数。这些参数也全都是Python对象,所以需要先转换成C值。函数 PyArg_ParseTuple() 检查参数类型并转换成C值。它使用模板字符串检测需要的参数类型。 PyArg_ParseTuple() 正常返回非零,并已经按照提供的地址存入了各个变量值。如果出错(零)则应该让函数返回NULL以通知解释器出错。 2 关于错误和异常 一个常见惯例是,函数发生错误时,应该设置一个异常环境并返回错误值(NULL)。异常存储在解释器静态全局变量中,如果为NULL,则没有发生异常。异常的第一个参数也需要保存在静态全局变量中,也就是raise的第二个参数。第三个变量包含栈回溯信息。这三个变量等同于Python变量 sys.exc_type 、 sys.exc_value 、 sys.exc_traceback 。这对找到错误是很必要的。 Python API中定义了一些函数来设置这些变量。 最常用的就是 PyErr_SetString() 。参数是异常对象和C字符串。异常对象一般由像...
阅读全文
C/C++

How exactly to Compose the Evaluation Element Of Our Research Paper

Many of all, bear in mind that exercise is as critical as composing the true article. The illustrations offered here can assist you to develop a superb autobiographical essay. Only be sure your composition WOn't sound purely factual. Authorship an appropriate protect for an essay you've composed is not an incredibly demanding task whatsoever, nevertheless it really is the most discounted. They are able to be normally used verbs typically article writings. Writing this type of article isn't a easy job. The secret to creating an excellent autobiographical article is actually to let your thoughts flow instead of set them...
阅读全文
C/C++

How to Produce a Synopsis, Research, and Answer Essay Document with Illustrations

Obtaining great producing support isn't an easy point. You'll get quite a few benefits when you choose to obtain essays from Aussiessaywriting. GradeMiners.co.uk is really a custom dissertation services which offers instructional pro assist with individuals. By way pay for service writing essay of free write you can definitely be sure of the grade of pro services given by Essayacademia and you will have the capacity to fix all of them to write your paper by knowing the caliber of the professional solutions. EssayThinker buy essays buy essays buy essays is truly an expert composition writing company available on the...
阅读全文
C/C++

Why Is Faculty Excelled in by Asians

Pick of the topic for investigation essay might function as initial but yet the most vital point on how better to compose an evaluation essay. Only How to generate a literary analysis essay, write a effective poems can be a literary criticism. That's the cause why they're recommended to assess for analysis essay examples. Obviously, this is writing of the literary evaluation essay. Construal that will not align with your investigation may soon be invalid. The heart of your own this service discussion is only a thesis. Since your analysis should constitute the bulk of your own article, approach it...
阅读全文