我在服务器上运行了一个mysql import mysql dummyctrad <dumpfile.sql,它需要很长时间才能完成.转储文件大约是5G.服务器是Centos 6,内存= 16G和8核处理器,mysql v 5.7 x64-
这些正常的消息/状态是"等待表刷新"和消息 InnoDB: page_cleaner: 1000ms intended loop took 4013ms. The settings might not be optimal
mysql日志内容
2016-12-13T10:51:39.909382Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4013ms. The settings might not be optimal. (flushed=1438 and evicted=0, during the time.)
2016-12-13T10:53:01.170388Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4055ms. The settings might not be optimal. (flushed=1412 and evicted=0, during the time.)
2016-12-13T11:07:11.728812Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4008ms. The …
Run Code Online (Sandbox Code Playgroud) 如何显示所有会话变量?我知道可以使用变量访问request.session['variable']
但我想知道是否有其他变量由其他人设置或在用户登录或类似的其他事件期间自动设置.
我在ubuntu 14.04 LTS上新安装了jenkins v 2.36.在安装过程中,jenkins安装了除管道之外的所有插件,并且在安装过程中卡住了.之后我重新启动了jenkins,
service jenkins restart
并且能够创建新的管理用户,这是jenkins仪表板上的错误屏幕截图,正确的按钮不能解决此错误.我该怎么做才能解决这个错误?
错误是
There are dependency errors loading some plugins:
Pipeline: Stage View Plugin v2.4
pipeline-rest-api v2.4 is missing. To fix, install v2.4 or later.
Pipeline v2.4
Pipeline: Stage View Plugin v2.4 failed to load. Fix this plugin first.
Run Code Online (Sandbox Code Playgroud) 我是YAML和ansible的新手,我很困惑哪一行是关键,哪一行是列表.例如,在下面的剧本中,似乎" - "代表一个列表项.
---
- hosts: all
gather_facts: no
sudo: yes
tasks:
- name: Ensure NTP is installed.
yum: name=ntp state=present
- name: ensure ntp is running
service: name=ntpd state=started enabled=yes
Run Code Online (Sandbox Code Playgroud)
所以host
是列表键,all
是它的价值,但是gather_facts: no
,sudo:
yes
并且task: ...
也与密钥列表的字典- hosts
?
当将上述playbook运行到yamllint.com时,我得到以下输出:
---
-
gather_facts: false
hosts: all
sudo: true
tasks:
-
name: "Ensure NTP is installed."
yum: "name=ntp state=present"
-
name: "ensure ntp is running"
service: "name=ntpd state=started enabled=yes"
Run Code Online (Sandbox Code Playgroud) OS=centos 6.7 [Dedicated server]
memory=15G
cpu=Intel(R) Xeon(R) CPU E5-2403
mysql= V 5.1.73
Run Code Online (Sandbox Code Playgroud)
这是一个MyISAM表,包含大约500万行数据.在每5-6分钟插入大约3000个用户的数据(例如上传和下载速率,会话状态等).
表信息:描述"radacct"
从mysql慢查询日志中获取大部分时间的查询之一如下
Query_time: 7.941773 Lock_time: 0.155912 Rows_sent: 1 Rows_examined: 5377
use freeradius;
SET timestamp=1461582118;
SELECT sum(acctinputoctets) as upload,
sum(acctoutputoctets) as download
FROM radacct a
INNER JOIN (SELECT acctuniqueid, MIN( radacctid ) radacctid
FROM radacct
WHERE username='batman215'
and acctstarttime between '2016-02-03 12:10:47'
and '2016-04-25 16:46:01'
GROUP BY acctuniqueid) b
ON a.acctuniqueid = b.acctuniqueid
AND a.radacctid = b.radacctid;
Run Code Online (Sandbox Code Playgroud)
当有许多用户试图查看其消耗的带宽时,由于高负载和IO,服务器无法满足请求.我有什么办法可以进一步优化数据库吗?
表"radacct"的索引
谢谢
下面是不使用最近创建的复合索引的更新查询/查询计划。解释表明,它不使用命名的复合索引radacctupdate
,我认为这将使更新查询更快。表上还有其他索引,这些索引可供其他查询使用。
EXPLAIN UPDATE radacct SET acctstoptime = '2017-01-08 11:52:24',
acctsessiontime = unix_timestamp('2017-01-08 11:52:24') - unix_timestamp(acctstarttime),
acctterminatecause = '', acctstopdelay = 14855646
WHERE acctstoptime IS NULL AND
nasipaddress = '102.34.56.234' AND acctstarttime <= '2017-01-08 11:52:24';
************* 1. row ***********
id: 1
select_type: SIMPLE
table: radacct
type: range
possible_keys: acctstarttime,acctstoptime,nasipaddress,radacctupdate
key: nasipaddress
key_len: 17
ref: const
rows: 94
Extra: Using where; Using MRR
Run Code Online (Sandbox Code Playgroud)
下面是show index from <table>
输出
+---------+------------+-----------------+--------------+-----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name …
Run Code Online (Sandbox Code Playgroud) Jan 23 00:46:24 portal postfix/smtp[31481]: 1B1653FEA1: to=<wanted1918_ke@yahoo.com>, relay=mta5.am0.yahoodns.net[98.138.112.35]:25, delay=5.4, delays=0.02/3.2/0.97/1.1, dsn=5.0.0, status=bounced (host mta5.am0.yahoodns.net[98.138.112.35] said: 554 delivery error: dd This user doesn't have a yahoo.com account (wanted1918_ke@yahoo.com) [0] - mta1321.mail.ne1.yahoo.com (in reply to end of DATA command))
Jan 23 00:46:24 portal postfix/smtp[31539]: AF40C3FE99: to=<devi_joshi@yahoo.com>, relay=mta7.am0.yahoodns.net[98.136.217.202]:25, delay=5.9, delays=0.01/3.1/0.99/1.8, dsn=5.0.0, status=bounced (host mta7.am0.yahoodns.net[98.136.217.202] said: 554 delivery error: dd This user doesn't have a yahoo.com account (devi_joshi@yahoo.com) [0] - mta1397.mail.gq1.yahoo.com (in reply to end of DATA command))
Run Code Online (Sandbox Code Playgroud)
从上面的maillog我想提取括在角括号之间的电子邮件地址,< ... >
例如.to=<wanted1918_ke@yahoo.com> …
我想打印/回显或重定向下面的行到一些文件
phone: "3434343"
name: "jack"
phone: "9876735"
name: "john"
phone: "3434343"
name: "Mack"
...multiple emptylines ...
phone: "9876735"
name: "doe"
phone: "3434343"
name: "tack"
Run Code Online (Sandbox Code Playgroud)
所需的输出线是: -
phone: "3434343" name: "jack"
phone: "9876735" name: "john"
...
Run Code Online (Sandbox Code Playgroud)
以下是我写的内容
cat /tmp/sip_summary2.log | while read LINE;
do
echo $LINE | grep '^$' > /dev/null
if [ $? -eq 0 ]
then
echo " " >> /tmp/tempsip.log
else
printf "%s " "$LINE" >> /tmp/tempsip.log
fi
done
Run Code Online (Sandbox Code Playgroud)
这有更好或更清洁的替代品吗?
下面是文件的一部分,其中列出了以空白换行符分隔的zimbra帐户(500+)
cn: Jack
displayName: Jack Johnson
givenName: Jack
sn: johnson
zimbraMailDeliveryAddress: Jack@example.com
cn: james ryan
displayName: James Ryan
givenName: James
sn: Ryan
zimbraMailDeliveryAddress: James@example.com
....
Run Code Online (Sandbox Code Playgroud)
我想让文件包含如下内容,以便我可以使用它将它们导入新服务器 zmprove
cn: Jack displayName: Jack Johnson givenName: Jack sn: johnson zimbraMailDeliveryAddress: Jack@example.com
cn: james ryan displayName: James Ryan givenName: James sn: Ryan zimbraMailDeliveryAddress: James@example.com
Run Code Online (Sandbox Code Playgroud)
我尝试编写脚本而不删除新行,但到目前为止无法提取
for line in `cat /tmp/account3.txt`;
do
echo $line | grep "zimbraMailDeliveryAddress:" > /dev/null
RESULT=$?
if [ $RESULT -eq 0 ]; then
email=`echo $line | cut -d' ' -f2` > …
Run Code Online (Sandbox Code Playgroud) 我正在关注 trydjango: coding for enterpreneurs 的 django 教程系列,并且对 django 形式的“模型”和“字段”的作用感到困惑。
模型.py
from django.db import models
# Create your models here.
class SignUp(models.Model):
email=models.EmailField()
full_name=models.CharField(max_length=55, blank=True, null=True)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated=models.DateTimeField(auto_now_add=False, auto_now=True)
def __unicode__(self):
return self.email
Run Code Online (Sandbox Code Playgroud)
表格.py
from django import forms
from .models import SignUp
class SignUpForm(forms.ModelForm):
class Meta:
model=SignUp # ?
fields=['full_name','email'] # ?
def clean_email(self):
email=self.cleaned_data.get('email')
email_base,provider=email.split("@")
domain,extension=provider.split(".")
if not domain == 'USC':
raise forms.ValidationError("Please make sure you use your USC email")
if not extension == "edu":
raise …
Run Code Online (Sandbox Code Playgroud) Django 版本=1.8,IDE=pycharm,python 2.7
我有一个搜索表单,我想根据与产品标题或产品描述或产品价格匹配的字符串在模型中搜索和列出项目(“产品”)。
下面是我在 views.py 中的“searchitems”部分。我也很困惑下面的行在 get_queryset 函数中做了什么。干杯
qs = super(ProductListView, self).get_queryset(*args,**kwargs)
Run Code Online (Sandbox Code Playgroud)
#
# Search inside model function
def get_queryset(self, *args, **kwargs):
qs = super(ProductListView, self).get_queryset(*args,**kwargs)
query = self.request.GET.get("q")
if query:
qs = self.model.objects.filter(
Q(title__icontains=query) |
Q(description__icontains=query) |
Q(price=query)
)
return qs
class ProductListView(ListView):
model = Product
queryset=Product.objects.all() #no need to define this as it is a default
def get_context_data(self, *args, **kwargs):
context = super(ProductListView, self).get_context_data(*args, **kwargs)
return context
Run Code Online (Sandbox Code Playgroud)
下面是models.py
from django.db import models
from django.core.urlresolvers import reverse
from …
Run Code Online (Sandbox Code Playgroud)