The following discussion covers these topics:

Overview of systemd

Configuring MySQL Using systemd

Configuring Multiple MySQL Instances Using systemd

Migrating from mysqld_safe to systemd

Overview of systemd

systemd provides automatic server startup and shutdown. It also enables manual server management using the systemctl command. For example:

systemctl {start|stop|restart|status} mysqld
Alternatively, use the service command (with the arguments reversed), which is compatible with System V systems:

service mysqld {start|stop|restart|status}
For the systemctl or service commands, if the MySQL service name is not mysqld, use the appropriate name (for example, mysql on SLES systems).

Support for systemd includes these files:

mysqld.service: systemd service unit configuration, with details about the mysqld service.

mysqld@.service: Like mysqld.service, but used for managing multiple MySQL instances.

mysqld.tmpfiles.d: File containing information to support the tmpfiles feature. This file is installed under the name mysql.conf.

mysqld_pre_systemd: Support script for the unit file. This script assists in creating the error log file only if its location matches the pattern /var/log/mysql*.log. In other cases, the error log directory must be writable or the error log must be present and writable for the user running the mysqld process.

On platforms for which systemd support is installed, scripts such as mysqld_safe and the System V initialization script are not installed because they are unnecessary. For example, mysqld_safe can handle server restarts, but systemd provides the same capability, and does so in a manner consistent with management of other services rather than using an application-specific program.

As of MySQL 5.7.13, on platforms for which systemd support is installed, systemd has the capability of managing multiple MySQL instances. For details, see Configuring Multiple MySQL Instances Using systemd. Consequently, mysqld_multi and mysqld_multi.server are not installed because they are unnecessary.

Configuring MySQL Using systemd

To add or change systemd options for MySQL, these methods are available:

Use a localized systemd configuration file.

Arrange for systemd to set environment variables for the MySQL server process.

Set the MYSQLD_OPTS systemd variable.

To use a localized systemd configuration file, create the /etc/systemd/system/mysqld.service.d directory if it does not exist. In that directory, create a file that contains a [Service] section listing the desired settings. For example:

[Service]
LimitNOFILE=max_open_files
PIDFile=/path/to/pid/file
Nice=nice_level
LimitCore=core_file_limit
Environment=”LD_PRELOAD=/path/to/malloc/library”
Environment=”TZ=time_zone_setting”
The discussion here uses override.conf as the name of this file. Newer versions of systemd support the following command, which opens an editor and permits you to edit the file:

systemctl edit mysqld
Whenever you create or change override.conf, reload the systemd configuration, then tell systemd to restart the MySQL service:

systemctl daemon-reload
systemctl restart mysqld
Support for configuration using override.conf was added in MySQL 5.7.7.

With systemd, the override.conf configuration method must be used for certain parameters, rather than settings in a [mysqld_safe] or [mysqld] group in a MySQL option file:

For some parameters, override.conf must be used because systemd itself must know their values and it cannot read MySQL option files to get them.

Parameters that specify values otherwise settable only using options known to mysqld_safe must be specified using systemd because there is no corresponding mysqld parameter.

For additional information about using systemd rather than mysqld_safe, see Migrating from mysqld_safe to systemd.

You can set the following parameters in override.conf:

To specify the process ID file:

As of MySQL 5.7.10: Use override.conf and change both PIDFile and ExecStart to name the PID file path name. Any setting of the process ID file in MySQL option files will be ignored.

Before MySQL 5.7.10: Use PIDFile in override.conf rather than the –pid-file option for mysqld_safe or mysqld. systemd must know the PID file location so that it can restart or stop the server. If the PID file value is specified in a MySQL option file, the value must match the PIDFile value or MySQL startup may fail.

To set the number of file descriptors available to the MySQL server, use LimitNOFILE in override.conf rather than the –open-files-limit option for mysqld_safe or mysqld.

To set the maximum core file size, use LimitCore in override.conf rather than the –core-file-size option for mysqld_safe.

To set the scheduling priority for the MySQL server, use Nice in override.conf rather than the –nice option for mysqld_safe.

Some MySQL parameters are configured using environment variables:

LD_PRELOAD: Set this variable if the MySQL server should use a specific memory-allocation library.

TZ: Set this variable to specify the default time zone for the server.

There are multiple ways to specify the value of environment values that should be in effect for the MySQL server process managed by systemd:

Use Environment lines in the override.conf file. For the syntax, see the example in the preceding discussion that describes how to use this file.

Specify the values in the /etc/sysconfig/mysql file (create the file if it does not exist). Assign values using the following syntax:

LD_PRELOAD=/path/to/malloc/library
TZ=time_zone_setting
After modifying /etc/sysconfig/mysql, restart the server to make the changes effective:

systemctl restart mysqld
To specify options for mysqld without modifying systemd configuration files directly, set or unset the MYSQLD_OPTS systemd variable. For example:

systemctl set-environment MYSQLD_OPTS=”–general_log=1″
systemctl unset-environment MYSQLD_OPTS
After modifying the systemd environment, restart the server to make the changes effective:

systemctl restart mysqld
MYSQLD_OPTS can also be set in the /etc/sysconfig/mysql file.

Configuring Multiple MySQL Instances Using systemd

As of MySQL 5.7.13, on platforms for which systemd support is installed, systemd has the capability of managing multiple MySQL instances. Consequently, mysqld_multi and mysqld_multi.server are not installed because they are unnecessary.

To use multiple-instance capability, modify my.cnf to include configuration of key options for each instance. For example, to manage two instances named replica01 and replica02, add something like this to the file:

[mysqld@replica01]
datadir=/var/lib/mysql-replica01
socket=/var/lib/mysql-replica01/mysql.sock
port=3307
log-error=/var/log/mysqld-replica01.log

[mysqld@replica02]
datadir=/var/lib/mysql-replica02
socket=/var/lib/mysql-replica02/mysql.sock
port=3308
log-error=/var/log/mysqld-replica02.log
The replica names shown here use @ as the delimiter because that is the only delimiter supported by systemd.

Instances then are managed by normal systemd commands, such as:

systemctl start mysqld@replica01
systemctl start mysqld@replica02
To enable instances to run at boot time, do this:

systemctl enable mysqld@replica01
systemctl enable mysqld@replica02
Use of wildcards is also supported. For example, this command displays the status of all replica instances:

systemctl status ‘mysqld@replica*’
For management of multiple MySQL instances on the same machine, systemd automatically uses a different unit file (mysqld@.service rather than mysqld.service). In that unit file, %I and %i reference the parameter passed in after the @ marker and are used to manage the specific instance. For a command such as this:

systemctl start mysqld@mysql1
systemd starts the server using a command such as this:

mysqld –defaults-group-suffix=@%I …
The result is that the [server], [mysqld], and [mysqld@mysql1] option groups are read and used for that instance of the service.

Migrating from mysqld_safe to systemd

Because mysqld_safe is not installed when systemd is used, options previously specified for that program (for example, in an [mysqld_safe] option group) must be specified another way:

Some mysqld_safe options are also understood by mysqld and can be moved from the [mysqld_safe] option group to the [mysqld] group. This does not include –pid-file or –open-files-limit. To specify those options, use the override.conf systemd file, described previously.

For some mysqld_safe options, there are similar mysqld options. For example, the mysqld_safe option for enabling syslog logging is –syslog. For mysqld, enable the log_syslog system variable instead. For details, see Section 6.4.2, “The Error Log”.

mysqld_safe options not understood by mysqld can be specified in override.conf or environment variables. For example, with mysqld_safe, if the server should use a specific memory allocation library, this is specified using the –malloc-lib option. For installations that manage the server with systemd, arrange to set the LD_PRELOAD environment variable instead, as described previously.

发表于鸡鸡哥的聪明伶俐的儿子和如花似玉的老婆 | 留下评论

/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol ‘ber_strdup@@OPENLDAP_2.4_2’
/usr/lib/x86_64-linux-gnu/liblber-2.4.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

make: *** [sapi/cli/php] Error 1

解决办法:

遇到这种类似的情况,说明「./configure 」沒抓好一些环境变数值。解决方法,来自老外的一篇文章:
在PHP源码目录下 vi Makefile 找到 EXTRA_LIBS 行,在行末添加 ‘ -llber ‘ 保存退出再次make即可。

发表于鸡鸡哥的聪明伶俐的儿子和如花似玉的老婆 | 留下评论

驼峰命名

驼峰命名法就是当变量名或函式名是由一个或多个单字连结在一起,而构成的唯一识别字时,第一个单字以小写字母开始;第二个单字的首字母大写或每一个单字的首字母都采用大写字母,例如:myFirstName、myLastName,这样的变量名看上去就像骆驼峰一样此起彼伏,故得名。

发表在 PHP | 留下评论

ubuntu16.04 任务栏不显示,桌面菜单右键无反应,无响应

linux系统的包依赖导致的副作用就是无意卸载一些小软件,这里是常用的gnmoe的软件

这次搜狗输入法出问题,折腾的过程中卸载了一些gnome的一些包,导致任务栏不显示,桌面右键菜单无法显示,总结如下
1、任务栏不显示,metacity gnome的窗口管理器
apt install metacity
metacity –replace #运行一下就OK
没窗口管理器:
开个程序
第一,在左上角
第二,没有边框
第三,不可挪动
第四,不可变形
第五,盖而无返
第六,……
2、gnome-tweak-tool Gnome Tweak Tool 是 Gnome 出品的配置工具,方便用户对 Gnome Shell 进行一些调整。
主要功能有:
安装,更改 Gnome-shell 主题
继续阅读

发表在 一些经验 | 标签为 , , , | 留下评论

ubuntu搜狗拼音输入法升级后忽然不能用了,解决

其实很多都是配置文件导致的,一般都是~/.config/xxxx目录,xxx是应用名字,有可能大小写,搜索时注意

出错现象就是无法输入中文,有浮窗,出不来汉字,右上角输入法图标有时候也不能用,动不动不能启动。
日志中有:
viMar 16 14:26:11 yanjin-Lenovo-G500 kernel: [ 922.570008] sogou-qimpanel[4689]: segfault at 361500 ip 00000000004fbedb sp 00007ffde42edc70 error 4 in sogou-qimpanel[400000+1c5000]
Mar 16 14:26:15 yanjin-Lenovo-G500 kernel: [ 927.290693] sogou-qimpanel[4910]: segfault at 3613c0 ip 00000000004fbedb sp 00007ffdb6b09510 error 4 in sogou-qimpanel[400000+1c5000]
Mar 16 14:26:23 yanjin-Lenovo-G500 kernel: [ 935.102633] sogou-qimpanel[5015]: segfault at 36c9b0 ip 00000000004fbedb sp 00007ffdd57b3e40 error 4 in sogou-qimpanel[400000+1c5000]

解决Ubuntu 16.04 搜狗输入法 只有悬浮窗中文不能自动联想的问题
一直用得好好的,不知道下载了什么更新导致搜狗输入法,在输入中文的时候,只显示一个悬浮窗。打字的时候什么反应都没有。中文也联想不出来。
找了半天,重新安装fcitx/搜狗输入法N次无果,在网上论坛找到了答案,修复了这个问题,记录一下。
直接删除其配置文件:
rm -rf ~/.config/SogouPY* ~/.config/sogou*
然后直接在右上角点fcitx图标,下拉列表里面重启fcitx输入法

转:http://fiture.me/share/linux-ubuntu/1246.html

发表在 一些经验 | 留下评论

thinkphp5的crud基本操作理解

thinkphp的参数绑定:
Db::execute(‘insert into think_data (id, name ,status) values (?, ?, ?)’, [8, ‘thinkphp’, 1]);

thinkphp的占位符绑定:
Db::execute(‘insert into think_data (id, name , status) values (:id, :name, :status)’, [‘id’ => 10, ‘name’ => ‘thinkphp’, ‘status’ => 1]);

$result = Db::query(‘select * from think_data where id=:id’, [‘id’ => 10]);
dump($result);

thinkphp的查询构造器:
Db::table()和Db::name(),一个是完整的表名,一个是表前缀
$list = Db::name(‘data’)->where(‘id’,5)->select();

db助手函数默认会每次重新连接数据库,因此应当尽量避免多次调用。
$db = db(‘data’);
$db->insert([‘id’ => 3, ‘name’ => ‘thinkphp’]);
$list = $db->where(‘id’,20)->select();

链式操作做复杂查询:
$list = Db::name(‘data’)->where(‘status’,1)->field(‘id,name’)->order(‘id’,’desc’)->limit(10)->select();
dump($list);

发表在 PHP | 标签为 , | 留下评论

全新途胜carlife的音乐格式

不想使用mp3,音质差
不支持其他无损格式,只能用wav

网上下载了一些ape格式的无损音乐文件,需要转化为wav,使用ffmpeg即可
ffmpeg -i music.ape music.wav

有些wav文件无法播放,全是电流声,但是用别的播放器是可以的,查看可能是声道问题,重新使用ffmpeg混音就可以
/usr/bin/ffmpeg -i /home/yanjin/music/wav/music.wav -af “pan=stereo|c0

搞定.

发表在 其它 | 标签为 , , | 留下评论

cacti,当udp不能用时,使用tcp的snmp监控服务器

国内网络环境复杂,udp往往不能用,可代用tcp,注意如下

添加设备的地方:
hostname tcp:ip 不是写ip,这里写tcp:192.168.0.xxx

snmp协议,通过修改/etc/sysconfig/snmpd文件,加入监听tcp端口
如:
# snmpd command line options
OPTIONS="tcp:1161 -LS0-6d -Lf /dev/null -p /var/run/snmpd.pid"

就可以了

发表在 一些经验 | 一条评论

thinkphp5中的pathinfo解析,nginx说明

nginx用正则拆分uri,官方的说明,很清楚!!!
thinkphp5必备!!!

Syntax: fastcgi_split_path_info regex;
Default: —
Context: location
Defines a regular expression that captures a value for the $fastcgi_path_info variable. The regular expression should have two captures: the first becomes a value of the $fastcgi_script_name variable, the second becomes a value of the $fastcgi_path_info variable. For example, with these settings

location ~ ^(.+\.php)(.*)$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;

and the “/show.php/article/0001” request, the SCRIPT_FILENAME parameter will be equal to “/path/to/php/show.php”, and the PATH_INFO parameter will be equal to “/article/0001”.

发表在 PHP | 留下评论

模板文件中用的多,如page.tpl.php

流程控制的替代语法

(PHP 4, PHP 5, PHP 7)

PHP 提供了一些流程控制的替代语法,包括 ifwhileforforeachswitch。替代语法的基本形式是把左花括号({)换成冒号(:),把右花括号(})分别换成 endif;endwhile;endfor;endforeach; 以及 endswitch;

<?php if ($a == 5): ?>
A is equal to 5
<?php endif; ?>

在上面的例子中,HTML 内容“A is equal to 5”用替代语法嵌套在 if 语句中。该 HTML 的内容仅在 $a 等于 5 时显示。

发表在 PHP | 留下评论