Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

181.4. Example

181.4.1. E-R

			
$ cat erd.gv
digraph g {
graph [
rankdir = "LR"
];
node [
fontsize = "16"
shape = "ellipse"
];
edge [
];

"user" [
        label = "User| <id> id|username|password|last|status"
        shape = "record"
];

"profile" [
        label = "Profile| <id> id | name | sex | age | address | icq | msn"
        shape = "record"
];

user:id->profile:id [label="1:1"];

"category" [
        label = "Category| <id> id | <pid> pid | name | status"
        shape = "record"
];

category:pid->category:id [label="1:n"];

"article" [
        label = "Article| <id> id| <user_id> user_id | <cid> category_id | title | content | datetime | status"
        shape = "record"
];

article:user_id->user:id [label="1:n"];
article:cid->category:id [label="1:n"];

"feedback" [
        label = "Feedback| <id> id| <user_id> user_id | <article_id> article_id | title | content | datetime | status"
        shape = "record"
];

feedback:user_id->user:id [label="1:n"];
feedback:article_id->article:id [label="1:n"];

}
			
			
			
$ dot -Tpng erd.gv > erd.png
			
			

181.4.2. Network

			
neo@neo-OptiPlex-380:~/Test/Graphviz$ cat network.gv
digraph network {

ranksep=5;
ratio=auto;

graph [
rankdir = "LR"
];

node [color=lightblue, style=filled];
"idc";
subgraph firewall {
        rank = same;
        node[shape=box,color=green];
        "ASA5550-Master" [ label="ASA5550-A|SSM-4GE-INC",shape="record",style="filled",color="green" ];
        "ASA5550-Slave" [ label="ASA5550-B",shape="hexagon",style="filled",color="green" ];
        "ASA5550-Master"->"ASA5550-Slave" [label="Failover"];
        "ASA5550-Master"->idc
        "ASA5550-Slave"->idc
}

subgraph switch {
        rank = same;

        "SW4507RA" [label="Cisco Catalyst 4507R|WS-X4648-RJ45V+E|WS-X4606-X2-E|WS-X45-SUP7-E|WS-X4712-SFP+E" shape = "record"];
        "SW4507RB" [label="Cisco Catalyst 4507R" shape = "record"];
        "SW4507RA"->"SW4507RB" [label="HSRP"];
        "ASA5550-Master"->"SW4507RA" [label="1GB"];
        "ASA5550-Slave"->"SW4507RB" [label="1GB"];

        "SW4507RA"->O8
        "SW4507RB"->O8

        "O8"->O4
        "O8"->O7
        "O8"->O9

        "SW4507RA"->J9 [ label = "SFP+ 10G" ];
        "SW4507RA"->J10;
        "SW4507RA"->J11;
        "SW4507RA"->J12;
        "SW4507RA"->J13;
        "SW4507RA"->J14;
        "SW4507RA"->J15;
        "SW4507RA"->M12;

        "SW4507RB"->J9;
        "SW4507RB"->J10;
        "SW4507RB"->J11;
        "SW4507RB"->J12;
        "SW4507RB"->J13;
        "SW4507RB"->J14;
        "SW4507RB"->J15;
        "SW4507RB"->M12;
}

subgraph slb {
        rank = 2;
        slb1 [label="F5-Master",shape=circle];
        slb2 [label="F5-Backup",shape=circle];
        slb1->"SW4507RA";
        slb2->"SW4507RB";
        slb1->slb2 [label="VRRP"];
"10.10.0.3"    [label="cms.example.com preview.example.com publish.example.com"];
"10.10.0.4"    [label="media.example.com"];
"10.10.0.5"    [label="portal.example.com my.example.com login.example.com"];
"10.10.0.6"    [label="sso.example.com"];

slb1->"10.10.0.3"
slb1->"10.10.0.4"
slb1->"10.10.0.5"
slb1->"10.10.0.6"
slb1->"10.10.0.7"
slb1->"10.10.0.8"
slb1->"10.10.0.9"

}
subgraph service {
        nfs [label="NFSv4 NAS"];
        server->nfs;
}

subgraph server {
        rank = same;
        "10.10.10.2" [label="Monitor"];
        "10.10.10.3" [label="Backup"];
}

subgraph lvs {
        "10.10.10.6";

}


"O9"->"10.10.10.2" [label="Monitor"];
"O9"->"10.10.10.3" [label="Backup"];
"O9"->"10.10.10.5";
"O9"->"10.10.10.7";
"O9"->"10.10.10.14";
"O9"->"10.10.10.15";
"O9"->"10.10.10.11";
"O9"->"10.10.10.12";
"O9"->"10.10.10.27";
"O9"->"10.10.10.28";
"O9"->"10.10.10.71";
"O9"->"10.10.10.72";

"O8"->"10.10.10.20";
"O8"->"10.10.10.23";
"O8"->"10.10.10.19";
"O8"->"10.10.10.10";
"O8"->"10.10.10.74";
"O8"->"10.10.10.74";
"O8"->"10.10.10.75";
"O8"->"10.10.10.76";
"O8"->"10.10.10.216";

"O7"->"10.10.10.16";
"O7"->"10.10.10.46";
"O7"->"10.10.10.47";
"O7"->"10.10.10.48";

"O4"->"10.10.10.41";
"O4"->"10.10.10.42";
"O4"->"10.10.10.54";


"J9"->"10.10.0.21";
"J9"->"10.10.0.22";
"J9"->"10.10.0.23";
"J9"->"10.10.0.24";
"J9"->"10.10.0.25";
"J9"->"10.10.0.26";
"J9"->"10.10.0.27";
"J9"->"10.10.0.28";
"J9"->"10.10.0.29";
"J9"->"10.10.0.30";
"J9"->"10.10.0.31";
"J9"->"10.10.0.32";

"J10"->"10.10.0.41";
"J10"->"10.10.0.42";
"J10"->"10.10.0.43";
"J10"->"10.10.0.44";
"J10"->"10.10.0.45";
"J10"->"10.10.0.46";
"J10"->"10.10.0.47";
"J10"->"10.10.0.48";
"J10"->"10.10.0.49";
"J10"->"10.10.0.50";
"J10"->"10.10.0.51";
"J10"->"10.10.0.52";

"J11"->"10.10.0.61";
"J11"->"10.10.0.62";
"J11"->"10.10.0.63";
"J11"->"10.10.0.64";

"J12"->"10.10.0.254";
"J12"->"10.10.0.250";

"J13"->"10.10.0.81";
"J13"->"10.10.0.82";
"J13"->"10.10.0.83";
"J13"->"10.10.0.84";
"J13"->"10.10.0.85";
"J13"->"10.10.0.86";
"J13"->"10.10.0.87";
"J13"->"10.10.0.88";
"J13"->"10.10.0.89";
"J13"->"10.10.0.90";
"J13"->"10.10.0.91";
"J13"->"10.10.0.92";
"J13"->"10.10.0.93";

"J14"->"10.10.0.101";
"J14"->"10.10.0.102";
"J14"->"10.10.0.103";
"J14"->"10.10.0.104";
"J14"->"10.10.0.105";
"J14"->"10.10.0.106";
"J14"->"10.10.0.107";
"J14"->"10.10.0.108";
"J14"->"10.10.0.53";
"J14"->"10.10.0.54";

"J15"->"10.10.5.10";
"J15"->"10.10.5.11";
"J15"->"10.10.5.12";
"J15"->"10.10.5.13";
"J15"->"10.10.5.14";
"J15"->"10.10.5.15";
"J15"->"10.10.5.16";
"J15"->"10.10.5.17";
"J15"->"10.10.5.18";
"J15"->"10.10.5.19";

"M12"->"10.10.0.121";
"M12"->"10.10.0.122";
"M12"->"10.10.0.123";
"M12"->"10.10.0.124";
"M12"->"10.10.0.125";
"M12"->"10.10.0.126";
"M12"->"10.10.0.127";
"M12"->"10.10.0.128";
"M12"->"10.10.0.129";
"M12"->"10.10.0.130";
"M12"->"10.10.0.131";
"M12"->"10.10.0.132";
"M12"->"10.10.0.133";
}

			
			
$ twopi network.gv -Tpng > network.png
			

181.4.3. workflow

			
/*
dot -Tpng workflow.gv -o workflow.png
*/
digraph workflow {
	graph
	[
	 ratio="auto"
	 label="User Login & Create Article Workflow"
	 labelloc=t
	 fontname="simyou.ttf"
	];
	node[shape=box,width=2];
	subgraph cluster_0 {
			style=filled;
			node [style=filled,color=white,fontcolor=blue];
			label="Login";
			color=lightgray;
			User -> Password -> "Sign in" [color=red];
	}
	subgraph cluster_1 {
			label="Article";
			color=black;
			Title -> Text -> Author -> Data -> Submit;
	}
	subgraph cluster_2 {
			style=filled;
			label="Auth";
			"Query db" [shape=parallelogram];
			"set cookie & session" [shape=parallelogram];
			"redirect" [shape=parallelogram];
			"Query db" -> "set cookie & session" -> "redirect";
	}
	Start -> Login;
	Login->User [label="N"];
	"Sign in"->"Query db";
	redirect->Title [style=dotted];
	Login->Title [label="Y"];

	User -> Author [style=dotted];

	Submit->End;

	Login [shape=diamond];
	Start [shape=circle,width=1];
	End	[shape=circle,width=1];
}