ziggle

Hail Hydra


  • Home

  • Archives

  • Search

dotnetcore

Posted on 2018-01-02

dotent Deployment

self-contained deployment (SCD)

  • 生成是带有运行时
    dotnet publish -c Release –self-contained -r linux-x64
  • 宿主带有运行时
    dotnet publish -c Release

判断属性值是否为null

1
2
3
4
5
6
7
8
static void CheckNull<T>(Expression<Func<T>> expression)
{
var name = ((MemberExpression)expression.Body).Member.Name;
if(expression.Compile()()==null)
{
System.Console.WriteLine($"{name} is null");
}
}

Exception
Q: Unhandled Exception: System.Net.HttpListenerException: Access is denied
A: netsh http add urlacl url=http://+:11221/ user=everyone

serlization

Posted on 2018-01-02

序列化

序列化 (Serialization)将对象的状态信息处理为字节流,以便于存储或传输到内存、数据库或文件的一个过程。在序列化期间,对象将其当前状态写入到临时或持久性存储区,主要目的是保存对象的状态。便于日后从该状态中进行还原,创建新的对象,这个过程又称为反序列化

consul

Posted on 2017-12-31

consul 启动配置

配置

1
2
3
4
5
6
7
8
9
root@ziggle:~# cat  /etc/consul.d/consul.json 
{
"datacenter":"ziggle-dc",
"log_level":"INFO",
"server":true,
"data_dir":"/opt/consul",
"bind_addr":"107.182.183.107",
"ui":true
}

启动命令

1
/usr/local/bin/consul agent -config-file /etc/consul.d/consul.json -client=107.107.107.107

管理页面
每个数据中心DataCenter 的server推荐3到5 ,所有的server都采用raft一致性算法来确保事务的一致性和线性化,事务修改了集群的状态,且集群的状态保存在每一台server上保证可用性
集群配置 一个client 两个server

Read more »

mysql

Posted on 2017-12-25

开启远程连接(raspberry pi ,ubuntu )

  • 第一步

    1
    2
    root@rasp:~# vim /etc/mysql/mariadb.conf.d/50-server.cnf
    # bind-address = 127.0.0.1
  • 第二步
    进入MySQL

    1
    2
    grant all privileges on *.* to root@"%" identified by "password" with grant option;
    flush privileges;

第一行命令解释如下,.:第一个代表数据库名;第二个代表表名。这里的意思是所有数据库里的所有表都授权给用户。root:授予root账号。“%”:表示授权的用户IP可以指定,这里代表任意的IP地址都能访问MySQL数据库。“password”:分配账号对应的密码,这里密码自己替换成你的mysql root帐号密码。
第二行命令是刷新权限信息,也即是让我们所作的设置马上生效。

完全卸载mysql(Ver 15.1 Distrib 10.1.23-MariaDB)

1
2
3
4
sudo apt purge mysql-*
sudo rm -rf /etc/mysql/ /var/lib/mysql
sudo apt autoremove
sudo apt autoclean

修改表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
create table if not exists emp(
name varchar(10),
hiredate date,
sal decimal(10,2),
deptno int(2),
primary key(name)
)
# 创建简单索引
create INDEX index_name on table_name (column_name)

# 创建唯一索引
create unique index index_name on table_name (colum_name)

# 创建复合索引
create index pIndex on persons (lastname, firstname)

#删除索引
drop index index_name on table_name

desc emp

alter table emp add column age int(3);

alter table emp drop column age;

alter table emp change age age1 int(4)

alter table emp modify age int(8);

alter table emp rename empp;

alter table persons alter city set default 'beijing'




--dml

insert into emp(name,hiredate,sal,deptno)values ('ziggle','2000-01-01','100',2);


insert into emp (name ,sal) values('foo',99);

update emp set sal=199 where name='ziggle';

delete from emp where name ='ziggle'

select count(1) from emp

-- 统计各部门的人士
select deptno,count(1) from emp group by deptno;
-- 统计各部门的人数,统计总人数
select deptno ,count(1) from emp group by deptno with roll up;

-- 统计人数大于1的部门
select deptno,count(1) from emp group by deptno having count(1) >1

select sum(sal) ,max(sal),man(sal) from emp;


create table dept (
deptno int(10),
deptname varchar(50)
)

select name ,deptname from emp ,dept where emp.deptno = dep.deptno

-- 左连接 :包含所有左边的记录甚至是右边表中没有和它匹配的几率
-- 右连接
select name ,deptname from dept right join emp on dept.deptno=emp.deptno


--子查询当我们查询的时候,需要的条件是另外一个 select 语句的结果,这个时候,就要用到子查询。用于子查询的关键字主要包括 in、not in、=、!=、exists、not exists 等

select * from emp where deptno in (select deptno from dept)


select * from emp where deptno = (select deptno from dept limit 1)

-- 把子查询转为表连接

select * from emp where deptno in (select deptno from dept)

select emp.* from emp,dept where emp.deptnp =dept.deptno



select * from dept
union all
select * from emp
--去重

select * from dept
union
select * from emp

sql create view

1
2
3
4
create view view_name as 
select column_name (s)
from table_name
where condition

Read more »

auto-deploy

Posted on 2017-12-25

systemd 守护进程

node webhook进程 同步接受GitHub post请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
root@ziggle:~# cat /lib/systemd/system/nsync.service
[Unit]
Description=Sync blog node service

[Service]
ExecStart=-/usr/bin/node /root/wp/www/nsyncblog.js
ExecReload=-/bin/kill -HUP $MAINPID
TimeoutSec=10s
Type=simple
KillMode=process
Restart=on-failure
RestartSec=20s

[Install]
WantedBy=multi-user.target

1…181920…22
ziggle

ziggle

Hail Hydra !

110 posts
45 tags
RSS
GitHub
© 2021 ziggle
Powered by Hexo
|
Hail Hydra—