鱼C论坛

 找回密码
 立即注册
查看: 4105|回复: 11

[技术交流] 运维笔记(一)

[复制链接]
发表于 2015-12-7 11:19:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 小云子墨 于 2015-12-7 11:22 编辑

做linux运维快一年 给大家分享下一年来的学习心得!
也给想入行的小伙伴一点参考资料,

其实才进公司大部分小伙伴和网管差不多,后来就好多了!有服务器环境需要搭建!慢慢就有的忙了!搭建web环境,优化并发.测试什么的。第一弄我也手忙脚乱不知道从何入手。
天将降大任于是人也,必先苦其心志,劳其筋骨,饿其体肤,空伐其身行,行弗乱其所为,所以动心忍性,曾益其所不能!

废话不多说 我们开始进入正题
正题第一步当然是选择系统版本了  我用的比较主流Centos 6.5 内核版本 2.6.32-431.el6.x86_64
第一个搭建的环境是给服务器装系统 这个比较容易  !

长期分区规划参考这里:
http://jingyan.baidu.com/article/60ccbceb0c364864cab1973e.html

这是一般的分区方案做参考:
方案1
/ :建议大小在5GB以上。
swap:即交换分区,建议大小是物理内存的1~2倍。

方案2 /boot:用来存放与Linux系统启动有关的程序,比如启动引导装载程序等,建议大小为100MB。
/ :Linux系统的根目录,所有的目录都挂在这个目录下面,建议大小为5GB以上。
/home:存放普通用户的数据,是普通用户的宿主目录,建议大小为剩下的空间。
swap:实现虚拟内存,建议大小是物理内存的1~2倍。
方案3 /boot:用来存放与Linux系统启动有关的程序,比如启动引导装载程序等,建议大小为100MB。
/usr :用来存放Linux系统中的应用程序,其相关数据较多,建议大于3GB以上。
/var :用来存放Linux系统中经常变化的数据以及日志文件,建议大于1GB以上。
/home:存放普通用户的数据,是普通用户的宿主目录,建议大小为剩下的空间。
/ :Linux系统的根目录,所有的目录都挂在这个目录下面,建议大小为5GB以上。
/tmp:将临时盘在独立的分区,可避免在文件系统被塞满时影响到系统的稳定性。建议大小为500MB以上。
swap:实现虚拟内存,建议大小是物理内存的1~2倍
新手选择默认 系统会替你分区设置挂载根的逻辑卷
例如:

~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/vg_linux-LogVol00   19G  3.5G   15G  20% /
tmpfs                          259M     0  259M   0% /dev/shm
/dev/sda1                      194M   29M  155M  16% /boot

注:以上为虚拟机!
因为大多小型企业的机器部署在云端,云端主机的系统盘 附带20G  数据盘自行购买!

centos 安装步骤参考百度经验:
http://jingyan.baidu.com/article/25648fc1a235c99191fd0008.html


写的很好!我就不重复浪费时间!遇到问题多百度!度娘异常强大,我们今天的终点不再这里!
废话不多说 系统装完开始干活,领导嗦 今天要你装这个装那个,还要跑那个 架构要拆分 巴拉巴拉~好烦
我们先一步一步来。

装完系统 很多小伙伴会卡在配置网络的阶段! 这个我也遇到过。
虚拟机的话 要首先设置咱们的虚拟机设置 将网络调节为桥接物理网卡!用笔记本的小伙伴需要注意桥接你正在使用的网卡
比如这样:
clipboard.png

我用的虚拟机是 Oracle VirtualBox 这个比较轻量级 而且安装操作比较简便比VM轻量!200M安装包大小!大家不用担心功能不全!之少我觉得完全够用。
网络设置配置配置文件:vim /etc/sysconfig/network-scripts/ifcfg-eth0
或者 :
用$system-config-network
进入网卡配置工具修改
clipboard.png
-------------------------------------------------------------
选择
网卡eth0

这里静态地址自行设置 母体机器网段! 母体机器自动获取 就给它把星打上 让它自动或许!看个人需求
然后  OK 保存 ! 保存并退出!
ifup eth0
启动你的网卡!

查看网络信息
~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:3f:83:e7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.118/24 brd 192.168.2.255 scope global eth0      <------这一行 inet后  看地址
    inet6 fe80::a00:27ff:fe3f:83e7/64 scope link
       valid_lft forever preferred_lft forever




~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=5 ttl=41 time=69.3 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=41 time=68.7 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=41 time=69.5 ms
64 bytes from 8.8.8.8: icmp_seq=8 ttl=41 time=69.9 ms
^Z
[1]+  Stopped                 ping 8.8.8.8

然后我们可以开始安装我们的系统了 !


评分

参与人数 1荣誉 +5 鱼币 +5 贡献 +5 收起 理由
小人 + 5 + 5 + 5 热爱鱼C^_^

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2015-12-7 11:34:24 | 显示全部楼层
二楼还是我的!
想了想 反正建站! 咱们不如直接上个静态web 应用好了!
调试好网络后! 我们来安装我们的软件源,也就是yum源,
我们先来ping百度  
]#ping www.baidu.com
ping: unknown host www.baidu.com

bash告诉我们找不到这个小婊砸
嗯想想 我们刚刚网络是通的 应该是解析问题!  
所以在终端输入:
]#echo -e "search localdomain\nnameserver 202.98.96.68\nnameserver 61.139.2.69" > /etc/resolv.conf
将运营商DNS 地址写入 resolv.conf文件!
然后我们来测试
# ping www.baidu.com
PING www.a.shifen.com (180.97.33.108) 56(84) bytes of data.
64 bytes from 180.97.33.108: icmp_seq=1 ttl=52 time=8.89 ms
64 bytes from 180.97.33.108: icmp_seq=2 ttl=52 time=9.24 ms

soga  解决掉一个问题!  我们来看看自己的yum 应该都是系统默认的yum源
我们来把他指向163 :
首先我们来安装 wget 这个软件!
命令:
# yum -y install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.skyshe.cn
我们指向yum
1,进入yum源配置目录
cd /etc/yum.repos.d
2,备份系统自带的yum源
mv CentOS-Base.repo CentOS-Base.repo.bk
下载163网易的yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
3,更新玩yum源后,执行下边命令更新yum配置,使操作立即生效
yum makecache


OK 好了! 接下来我们安装第一个  正式的服务!   httpd  


很容易!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-12-7 11:46:35 | 显示全部楼层
~]# yum -y install httpd
Loaded plugins: fastestmirror, security
Determining fastest mirrors
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
base                                                                                                          | 3.7 kB     00:00     
extras                                                                                                        | 3.4 kB     00:00
-------------------- 卖萌的字符们    -----------------------------------------------------------------------

Installed:
  httpd.x86_64 0:2.2.15-47.el6.centos                                                                                                

Dependency Installed:
  apr.x86_64 0:1.3.9-5.el6_2                     apr-util.x86_64 0:1.3.9-3.el6_0.1      apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1     
  httpd-tools.x86_64 0:2.2.15-47.el6.centos     

Complete!

#
这就安装完了!


下来我们启动它;
#service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 220.250.64.225 for ServerName
                                                           [  OK  ]


启动好了    我们在浏览器 输入  这台机器的  IP地址!
因为新号 不能传图片 所以 给你看字符别揍我:
这里是url:http://192.168.2.118/

Apache 2 Test Page
powered by CentOS
This page is used to test the proper operation of the Apache HTTP server after it has been installed. If you can read this page it means that the Apache HTTP server installed at this site is working properly.

If you are a member of the general public:

The fact that you are seeing this page indicates that the website you just visited is either experiencing problems or is undergoing routine maintenance.

If you would like to let the administrators of this website know that you've seen this page instead of the page you expected, you should send them e-mail. In general, mail sent to the name "webmaster" and directed to the website's domain should reach the appropriate person.

For example, if you experienced problems while visiting www.example.com, you should send e-mail to "webmaster@example.com".

If you are the website administrator:

You may now add content to the directory /var/www/html/. Note that until you do so, people visiting your website will see this page and not your content. To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.

You are free to use the images below on Apache and CentOS Linux powered HTTP servers. Thanks for using Apache and CentOS!

[ Powered by Apache ] [ Powered by CentOS Linux ]

About CentOS:

The Community ENTerprise Operating System (CentOS) Linux is a community-supported enterprise distribution derived from sources freely provided to the public by Red Hat. As such, CentOS Linux aims to be functionally compatible with Red Hat Enterprise Linux. The CentOS Project is the organization that builds CentOS. We mainly change packages to remove upstream vendor branding and artwork.
For information on CentOS please visit the CentOS website.

Note:

CentOS is an Operating System and it is used to power this website; however, the webserver is owned by the domain owner and not the CentOS Project. If you have issues with the content of this site, contact the owner of the domain, not the CentOS Project.

Unless this server is on the centos.org domain, the CentOS Project doesn't have anything to do with the content on this webserver or any e-mails that directed you to this site.

For example, if this website is www.example.com, you would find the owner of the example.com domain at the following WHOIS server:
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-12-7 11:51:53 | 显示全部楼层
我们来构建自己的第一个主页:

命令输入:echo fishc.com > /var/www/html/index.html


刷新 我们的 浏览器!  


看到我们主页成了:
萌萌的url:http://192.168.2.118/
内容:fishc.com  
嗯我们就完成了我们的第一个静态页面!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-12-12 15:50:54 | 显示全部楼层
路过  看看   。。。。谢谢分享
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-12-21 16:18:44 | 显示全部楼层
如何收藏楼主的帖子呢?我挺想做这一行的,先来顶一下!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2015-12-21 16:19:40 | 显示全部楼层
留名mark一下,挺有用的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2016-1-7 22:04:54 | 显示全部楼层
echo fishc.com > /var/www/html/index.html这个意思是不是复制鱼C的首页作为自己的首页啊?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2016-1-14 20:43:11 | 显示全部楼层
黎明晨曦 发表于 2016-1-7 22:04
echo fishc.com > /var/www/html/index.html这个意思是不是复制鱼C的首页作为自己的首页啊?

把 fishc.com  输出重定向到 index.html  里
网页只显示 fishc.com  这一串字
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2016-1-15 11:12:24 | 显示全部楼层
懒人在思考丶 发表于 2016-1-14 20:43
把 fishc.com  输出重定向到 index.html  里
网页只显示 fishc.com  这一串字

嗯,谢谢啦!明白了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2016-7-6 22:16:34 | 显示全部楼层
谢谢分享
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2016-7-7 15:13:37 | 显示全部楼层
其实楼主粘贴一些命令就行了,过程那些信息没必要放进来
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-24 21:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表