kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

mysql 查看连接数

查看当前所有连接的详细资料:

1
mysqladmin -uadmin -p processlist

只查看当前连接数(Threads就是连接数.):

1
mysqladmin -uadmin -p status

连接进程

1
2
3
4
5
6
7
8
9
10
11
mysql -uroot -p

mysql> show full processlist 查看所有连接进程,注意查看进程等待时间以及所处状态 是否locked


mysql> show variables like '%_connections';

max_user_connections  这个就是单用户的连接数
max_connections       这个是全局的限制连接数

mysql> set global max_connections = 152;

CI使用cookie

第一种设置cookie的方式:采用php原生态的方法设置的cookie的值

1
2
3
4
setcookie("user_id",$user_info['user_id'],86500);
setcookie("username",$user_info['username'],86500);
setcookie("password",$user_info['password'],86500);
//echo $_COOKIE['username'];

第二种设置cookie的方式:通过CI框架的input类库设置cookie的值

1
2
3
4
5
6
7
$this->input->set_cookie("username",$user_info['username'],60);
$this->input->set_cookie("password",$user_info['password'],60);
$this->input->set_cookie("user_id",$user_info['user_id'],60);
//echo $this->input->cookie("password");//适用于控制器
//echo $this->input->cookie("username");//适用于控制器
//echo $_COOKIE['username'];//在模型类中可以通过这种方式获取cookie值
//echo $_COOKIE['password'];//在模型类中可以通过这种方式获取cookie值

第三种设置cookie的方式:通过CI框架的cookie_helper.php辅助函数库设置cookie的值

1
2
3
4
set_cookie("username",$user_info['username'],60);
set_cookie("password",$user_info['password'],60);
set_cookie("user_id",$user_info['user_id'],60);
//echo get_cookie("username");

删除cookie:通过CI框架的cookie_helper.php辅助函数删除cookie

1
2
3
4
delete_cookie("username");
delete_cookie("password");
delete_cookie("user_id");
header("location:".site_url("common/login"));

ubuntu 18.04增加/etc/rc.local

https://blog.csdn.net/qq_41782149/article/details/89001226

ubuntu18.04不再使用 inited 管理系统,改用 systemd

1.实现原理

systemd 默认会读取 /etc/systemd/system 下的配置文件,该目录下的文件会链接 /lib/systemd/system/ 下的文件。一般系统安装完 /lib/systemd/system/ 下会有 rc-local.service 文件,即我们需要的配置文件。

2.将 /lib/systemd/system/rc-local.service 链接到 /etc/systemd/system/ 目录下面来

1
2
3
4
5
6
7
8
9
10
ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service

修改文件内容

sudo vim /etc/systemd/system/rc-local.service

在文件末尾增加
[Install]
WantedBy=multi-user.target
Alias=rc-local.service

3. 创建/etc/rc.local文件

1
2
3
4
sudo vim /etc/rc.local

#!/bin/bash
...