我的站点

一个系统软件工程师的随手涂鸦

Tag: network

CentOS配置静态IP

VirtualBox里安装CentOS,配置静态IP

(1)CentOS 6,修改/etc/sysconfig/network-scripts/ifcfg-eth0文件:

......
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.9
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

(2)CentOS 7,修改/etc/sysconfig/network-scripts/ifcfg-enp0s3文件:

......
BOOTPROTO="static"
ONBOOT="yes"
IPADDR="192.168.1.5"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.1"
DNS1="192.168.1.1"
DNS2="8.8.8.8"

 

Go语言DefaultClient没有设置请求超时

今天看到这篇文章:Don’t use Go’s default HTTP client。总结起来就是直接使用Go语言的http.Posthttp.Get等方法时,底层连接使用的是DefaultClient。而DefaultClient没有设置请求超时:

// DefaultClient is the default Client and is used by Get, Head, and Post.
var DefaultClient = &Client{}

因此,如果服务器端如果一直无响应的话,就会把当前发出请求的goroutine挂死。因此如果要使用DefaultClient,一定要留心这个陷阱。

docker笔记(10)—— “EXPOSE”,“–expose=[]”,“-P”和“-p=[]”

A Brief Primer on Docker Networking Rules: EXPOSE, -p, -P, –link对“EXPOSE”,“--expose=[]”,“-P”和“-p=[]”做了详细介绍:

 

Capture

EXPOSE”和“--expose=[]”会expose container中的端口,但是不会映射到host上的端口,因此这些端口只能在这个host上访问。“-P”把所有expose出来的端口映射到host上的端口,而“-p=[]”则会动态指定containerhost之间的端口映射。

其它参考资料:
Why does a Docker container running a server expose port to the outside world even though said port is blocked by iptables?
Exposing a container port on host

/etc/hosts文件

/etc/hosts文件保存IP地址和hostname之间的映射。格式是:IP地址 canocial_hostname name。举例如下:

127.0.0.1       localhost
192.168.1.10    foo.mydomain.org       foo
192.168.1.13    bar.mydomain.org       bar
146.82.138.7    master.debian.org      master
209.237.226.90  www.opensource.org

尽管现在host table已经被DNS取代了,但是有时在bootstrappingNIS和隔离节点的环境下仍然会用到/etc/hosts
修改/etc/hosts文件可以马上生效,但有时需要清空程序的缓存。

参考资料:
hosts

 

Oracle笔记(5)——连接数据库

Oracle的网络协议称之为Oracle NetSQL*NetNet8

连接数据库的两种方式:

(1)本地连接(Local

这种方式client和数据库位于同一台服务器上,数据通信不需要经过listener进程,而是通过Unix pipe方式进行通信。比如以SYS用户连接数据库:

sqlplus as / sysdba

或是利用ORACLE_SID环境变量指定本地数据库,然后使用用户名和密码进行连接:

sqlplus username/password

需要注意的是还有一个TWO_TASK环境变量指定远端数据库,而当这两个变量同时指定时,TWO_TASK优先级更高。

(2)远端连接(remote

这种方式client和数据库位于不同服务器上,连接时需要指定连接的数据库TNS名字:

sqlplus username/password@orcl

这种方式需要利用tnsnames.ora文件来解析数据库主机和端口,此外数据通信也要经过listener进程。

区分“本地连接”和“远端连接”的一个方法就是看连接数据库时是否指定数据库TNS名字:@tns_alia

(3)

Oracle client和数据库之间通信使用TNS(Transparent Network Substrate)协议,可以用wireshark解析:

Capture

 

参考资料:

research oracle tns protocol

Oracle Database Communication Protocol

Oracle 12c For Dummies ;

http://ora-exp.blogspot.com/2007/06/oraclesid-and-twotask-environment_21.html

Re: sqlplus connection from unix with and without the oracle sid

In Oracle, how do you change the ‘default’ database?

Should we consider “sqlplus” as an Oracle client?

SYSDBA password in Oracle DB

 

*NIX & Hacking —— 第9期

做一本我感兴趣的杂志,就这么简单!

Assembler

Assembler relaxation

GDB

GDB dashboard

Go

Best practices for a new Go developer
On Go, Portability, and System Interfaces

Kernel

A Toure of Bootloading
GRUB 2 bootloader – Full tutorial
How I ended up writing new real-time kernel
Kernel bypass
Linux Kernel Crash Book

Network

TCP in 30 instructions

RMS

Interviews: RMS Answers Your Questions

Rust

Why Rust?

Tracing

Dynamic Tracing with DTrace & SystemTap

*NIX & Hacking —— 第8期

做一本我感兴趣的杂志,就这么简单!

C

C Programming Substance Guidelines
The International Obfuscated C Code Contest

Docker

A Beginners Guide to Docker and Containers

Gcc

About GCC printf optimization

Git

Git Cheat Sheet
Git Tips

Hardware

Interfacing the Serial / RS232 Port

Kernel

Porting Linux to a new processor architecture, part 1: The basics
The newbie’s guide to hacking the Linux kernel
Writing a Linux Kernel Module — Part 1: Introduction

Lua

Embedding LuaJIT in 30 minutes (or so)

Network

Mobile TCP optimization – lessons learned in production

Unix

The First Port Of Unix

*NIX & Hacking —— 第5期

做一本我感兴趣的杂志,就这么简单!

C

Integer Overflow

Golang

breaking out of a select statement when all channels are closed

Kernel

Feature: High Memory In The Linux Kernel
What’s Next for Containers? User Namespaces

Network

Recent advancements in Linux TCP congestion control
SO_REUSEPORT – Scaling Techniques for Servers with High Connection Rates

Rust

Rust in Detail: Writing Scalable Chat Service from Scratch

Shell

fish shell

Easter egg

Announcing the first Art of Computer Programming eBooks
Goodbye Moto
Intel DDIO, LLC cache, buffer alignment, prefetching, shared locks and packet rates
Jokes
List of freely available Programming Books
Mandelbrot Set with SIMD Intrinsics

*NIX & Hacking —— 第4期

做一本我感兴趣的杂志,就这么简单!

Compiler

Notes on How Parsers and Compilers Work

Golang

GopherCon 2015 live blog
Testing in Go
Why does adding parentheses in if condition results in compile error?

Kernel

Choosing a Linux Tracer (2015)
Debugging by printing
Learning Kernel Programming
LTTng Packages now Available for Red Hat Enterprise Linux 7

Lua

Cloning a function in Lua

Network

Unit testing a TCP stack

Unix

Where the Unix philosophy breaks down

Easter egg

Starting from scratch: How do you build a world-class research lab?
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Powered by WordPress & Theme by Anders Norén