分类目录归档:CentOS

CentOS7 Lsyncd 文件实时同步(替代Rsync和Inotify)

Lsyncd结合了inotify + rsync,Lsyncd监视本地目录树事件监视器接口(inotify或fsevents)。它聚合和组合事件几秒钟,然后生成一个(或多个)进程(es)来同步更改。

部署环境

# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 

# uname -a                
Linux filesync-20.203.localdomain 3.10.0-693.11.1.el7.x86_64 #1 SMP Mon Dec 4 23:52:40 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    
# rsync --version   
rsync  version 3.0.9  protocol version 30
Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
    append, ACLs, xattrs, iconv, symtimes

rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
    
# lsyncd --version         
Version: 2.2.2

  安装部署 lsyncd

部署机器

Server-A  192.168.20.203   [主文件服务器,  读写]
Server-B  192.168.20.204   [备份文件服务器,只读]

密钥登录

Server-A服务器上操作

#生成密钥文件
ssh-keygen -t rsa
#将公钥拷贝到B
ssh-copy-id username@192.168.20.204
#测试
ssh username@192.168.20.204

安装 lsyncd

yum -y install lsyncd

配置文件

settings {
    logfile    = "/tmp/lsyncd.log",
    statusFile = "/tmp/lsyncd.status",
    insist = true,
    statusInterval = 10
}
sync {
    default.rsyncssh,
    source="/data",
    host="username@192.168.20.204",
    targetdir="/data",
    rsync = {
        archive = true,
        compress = false,
        whole_file = false,
        _extra = {"--bwlimit=40960"}
    },
    ssh = {
        port = 22
    }
}

测试

lsyncd -nodaemon /etc/lsyncd.conf

后台启动 lsyncd

systemctl start lsyncd
systemctl enable lsyncd

系统优化

echo -e "\nfs.inotify.max_user_watches = 8192000" >> /etc/sysctl.conf 
sysctl -p

参考文档

CentOS6 安装Webmin

官网:http://www.webmin.cn/download.html
参考:http://spikedighole.blog.163.com/blog/static/176998045201562805435418/

01# uname -a               
02Linux localhost.localdomain 2.6.32-573.18.1.el6.x86_64 #1 SMP Tue Feb 9 22:46:17 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
03# cat /etc/redhat-release
04CentOS release 6.7 (Final)
05# rpm -qa|grep webmin
06webmin-1.780-1.noarch
07 
08 
09# webadmin安装升级会用到perl-Net-SSLeay
10yum -y install perl-Net-SSLeay
12wget http://jaist.dl.sourceforge.net/project/webadmin/webmin/1.780/webmin-1.780-1.noarch.rpm
13rpm -ivh webmin-1.780-1.noarch.rpm
14netstat -ntlp|grep 10000

 

CentOS 使用lynx更新3322.org DDNS

参考文档:
http://www.pubyun.com/products/dyndns/download/

01# 安装lynx
02# yum install lynx
03 
05HTTP/1.1 200 OK
06Server: nginx
07Date: Tue, 23 Feb 2016 09:12:23 GMT
08Content-Type: text/plain; charset=utf-8
09Connection: close
10Vary: Cookie
11 
12good 16.26.19.26
13#
14#
16HTTP/1.1 200 OK
17Server: nginx
18Date: Tue, 23 Feb 2016 09:14:00 GMT
19Content-Type: text/plain; charset=utf-8
20Connection: close
21Vary: Cookie
22 
23nochg 16.26.19.26

 

CentOS6 安装phpMyAdmin

01# cat /etc/redhat-release
02CentOS release 6.7 (Final)
03# rpm -qa|grep phpMyAdmin
04phpMyAdmin-4.0.10.14-1.el6.noarch
05# rpm -qa|grep mysql-server
06mysql-server-5.1.73-5.el6_6.x86_64
07 
08# 添加epel源
10 
11# 安装相关软件包
12# yum -y install httpd mysql php php-mysql phpmyadmin
13 
14# 修改index文件
15# vi /etc/httpd/conf/httpd.conf
16DirectoryIndex index.php index.html index.html.var
17 
18# 允许远程登录phpMyAdmin
19# vi /etc/httpd/conf.d/phpMyAdmin.conf
20   <IfModule !mod_authz_core.c>
21     # Apache 2.2
22     Order Deny,Allow
23     Deny from All
24     Allow from 1.1.1.2
25     Allow from 127.0.0.1
26     Allow from ::1
27   </IfModule>
28    
29# 重启httpd
30service httpd restart
31 
32# 登录
33http://server_ip/phpmyadmin/

 

kickstart_示例

kickstart 示例

 

001#platform=x86, AMD64, or Intel EM64T
002# System authorization information
003auth  --useshadow  --enablemd5
004# System bootloader configuration
005bootloader --location=mbr
006# Partition clearing information
007clearpart --all --initlabel
008# Use text mode install
009text
010# Firewall configuration
011firewall --enabled --http --ssh --port=123:udp
012# Run the Setup Agent on first boot
013firstboot --disable
014# System keyboard
015keyboard us
016# System language
017lang en_US.UTF-8 --addsupport=zh_CN.UTF-8
018# Use network installation
019url --url=http://192.168.211.50/cblr/links/centos7mini-x86_64
020# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
021repo --name=source-1 --baseurl=http://192.168.211.50/cobbler/ks_mirror/centos7mini-x86_64
022 
023# Network information
024# # Using "new" style networking config, by matching networking information to the physical interface's
025# MAC-address
026# %include /tmp/pre_install_network_config
027 
028network  --bootproto=dhcp --device=eth0 --onboot=on --ipv6=auto
029# --device=eth0 由于网卡的名字可能是eth0、em1、eno16777736等,--device制定的与目标机器网卡不一致时,会报错无法启动,顾不指定--device
030# network --bootproto=static --ip=192.168.100.52 --netmask=255.255.255.0 --gateway=192.168.100.1 --nameserver=223.5.5.5,223.6.6.6 --onboot=on --ipv6=auto
031# network --bootproto=dhcp --onboot=on --noipv6
032# network --device team0 --activate --bootproto=static --ip=10.34.102.222 --netmask=255.255.255.0 --gateway=10.34.102.254 --nameserver=10.34.39.2 -teamslaves="p3p1'{\"prio\": -10, \"sticky\": true}',p3p2'{\"prio\": 100}'" --teamconfig="{\"runner\": {\"name\": \"activebackup\"}}"
033 
034# Reboot after installation
035reboot
036 
037#Root password
038rootpw --iscrypted $1$allgo$sjkKoGvJXV2AuBNFeHyxP.
039 
040# 加密密码生成
041# 格式 openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
042# 其中 random-phrase-here 为干扰码
043 
044#add user
045# user --name=<username> [--groups=<list>] [--homedir=<homedir>] [--password=<password>] [--iscrypted] [--shell=<shell>] [--uid=<uid>]
046user --name="centos" --password="$1$allgo$sjkKoGvJXV2AuBNFeHyxP." --iscrypted --uid=1000
047 
048# SELinux configuration
049selinux --disabled
050# Do not configure the X Window System
051skipx
052# System timezone
053# timezone  Asia/Shanghai
054timezone --ntpservers=110.75.186.247,cn.ntp.org.cn Asia/Shanghai
055# --nontp Disable automatic starting of NTP service
056 
057# Install OS instead of upgrade
058install
059# Clear the Master Boot Record
060zerombr
061# Allow anaconda to partition the system as needed
062# autopart
063 
064# CentOS6 不支持xfs
065# part / --asprimary --fstype="ext4" --size=20480
066# part /boot --asprimary --fstype="ext4" --size=512
067# part swap --asprimary --fstype="swap" --size=2048
068# part /data --asprimary --fstype="ext4" --grow --size=1
069 
070 
071# CentOS7 支持xfs
072# part / --asprimary --fstype="xfs" --size=20480
073# part /boot --asprimary --fstype="xfs" --size=512
074# part swap --asprimary --fstype="swap" --size=2048
075# part /data --asprimary --fstype="xfs" --grow --size=1
076 
077# CentOS7 使用LVM分区
078part /boot --fstype="xfs" --size=1024
079part swap --fstype="swap" --size=2048
080part pv.01 --size=1 --grow
081volgroup centos pv.01
082logvol  / --fstype="xfs" --vgname=centos  --size=10240  --name=root
083logvol  /data  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=data
084 
085 
086# %pre部分脚本(系统安装前执行)系统在解析 ks.cfg 文件之后立即运行,而且必须以 %pre 命令开头。注意,你在 %pre 部分可以访问网络;然而,名称服务(name service)在此时还没有被配置,因此只有 IP 地址才能奏效。
087%pre
088set -x -v
089exec 1>/tmp/ks-pre.log 2>&1
090 
091# Once root's homedir is there, copy over the log.
092while : ; do
093    sleep 10
094    if [ -d /mnt/sysimage/root ]; then
095        cp /tmp/ks-pre.log /mnt/sysimage/root/
096        logger "Copied %pre section log to system"
097        break
098    fi
099done &
100 
101 
103# Start pre_install_network_config generated code
104# generic functions to be used later for discovering NICs
105mac_exists() {
106  [ -z "$1" ] && return 1
107 
108  if which ip 2>/dev/null >/dev/null; then
109    ip -o link | grep -i "$1" 2>/dev/null >/dev/null
110    return $?
111  elif which esxcfg-nics 2>/dev/null >/dev/null; then
112    esxcfg-nics -l | grep -i "$1" 2>/dev/null >/dev/null
113    return $?
114  else
115    ifconfig -a | grep -i "$1" 2>/dev/null >/dev/null
116    return $?
117  fi
118}
119get_ifname() {
120  if which ip 2>/dev/null >/dev/null; then
121    IFNAME=$(ip -o link | grep -i "$1" | sed -e 's/^[0-9]*: //' -e 's/:.*//')
122  elif which esxcfg-nics 2>/dev/null >/dev/null; then
123    IFNAME=$(esxcfg-nics -l | grep -i "$1" | cut -d " " -f 1)
124  else
125    IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)
126    if [ -z $IFNAME ]; then
127      IFNAME=$(ifconfig -a | grep -i -B 2 "$1" | sed -n '/flags/s/:.*$//p')
128    fi
129  fi
130}
131 
132# Start of code to match cobbler system interfaces to physical interfaces by their mac addresses
133#  Start eno16777736
134# Configuring eno16777736 (00:0C:29:48:30:63)
135if mac_exists 00:0C:29:48:30:63
136then
137  get_ifname 00:0C:29:48:30:63
138  echo "network --device=$IFNAME --bootproto=static --ip=192.168.211.11 --netmask=255.255.255.0 --gateway=192.168.211.1 --hostname=test.mydomain.com" >> /tmp/pre_install_network_config
139fi
140# End pre_install_network_config generated code
141 
142# Enable installation monitoring
143 
144%end
145 
146# %packages 指令也支持下面的选项:
147# --nobase,不要安装@Base 组.如果想创建一个很小的系统,可以使用这个选项.
148# --resolvedeps,选项已经被取消了.目前依赖关系可以自动地被解析.
149# --ignoredeps,选项已经被取消了.目前依赖关系可以自动地被解析.
150# --ignoremissing,忽略缺少的软件包或软件包组,而不是暂停安装来向用户询问是中止还是继续安装.
151# 例如:%packages --ignoremissing
152%packages --ignoremissing --nobase
153@Core
154vim
155wget
156%end
157 
158# %post部分脚本系统安装后执行, DHCP配置网络没有配置dns服务器
159%post --nochroot
160set -x -v
161exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1
162 
163%end
164 
165%post
166set -x -v
167exec 1>/root/ks-post.log 2>&1
168 
169# Start yum configuration
170# curl "http://192.168.211.50/cblr/svc/op/yum/system/test" --output /etc/yum.repos.d/cobbler-config.repo
171 
172# End yum configuration
173 
174 
175 
176# Start post_install_network_config generated code
177 
178# create a working directory for interface scripts
179mkdir /etc/sysconfig/network-scripts/cobbler
180cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/cobbler/
181 
182# set the gateway in the network configuration file
183grep -v GATEWAY /etc/sysconfig/network > /etc/sysconfig/network.cobbler
184echo "GATEWAY=192.168.211.1" >> /etc/sysconfig/network.cobbler
185rm -f /etc/sysconfig/network
186mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
187 
188# set the hostname in the network configuration file
189grep -v HOSTNAME /etc/sysconfig/network > /etc/sysconfig/network.cobbler
190echo "HOSTNAME=test.mydomain.com" >> /etc/sysconfig/network.cobbler
191rm -f /etc/sysconfig/network
192mv /etc/sysconfig/network.cobbler /etc/sysconfig/network
193 
194# Also set the hostname now, some applications require it
195# (e.g.: if we're connecting to Puppet before a reboot).
196/bin/hostname test.mydomain.com
197 
198# Start configuration for eno16777736
199echo "DEVICE=eno16777736" > /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
200echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
201echo "HWADDR=00:0C:29:48:30:63" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
202IFNAME=$(ip -o link | grep -i '00:0C:29:48:30:63' | sed -e 's/^[0-9]*: //' -e 's/:.*//')
203if [ -f "/etc/modprobe.conf" ] && [ $IFNAME ]; then
204    grep $IFNAME /etc/modprobe.conf | sed "s/$IFNAME/eno16777736/" >> /etc/modprobe.conf.cobbler
205    grep -v $IFNAME /etc/modprobe.conf >> /etc/modprobe.conf.new
206    rm -f /etc/modprobe.conf
207    mv /etc/modprobe.conf.new /etc/modprobe.conf
208fi
209echo "TYPE=Ethernet" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
210echo "BOOTPROTO=none" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
211echo "IPADDR=192.168.211.11" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
212echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
213# End configuration for eno16777736
214 
215sed -i 's/ONBOOT=yes/ONBOOT=no/g' /etc/sysconfig/network-scripts/ifcfg-eth*
216 
217rm -f /etc/sysconfig/network-scripts/ifcfg-eno16777736
218mv /etc/sysconfig/network-scripts/cobbler/* /etc/sysconfig/network-scripts/
219rm -r /etc/sysconfig/network-scripts/cobbler
220if [ -f "/etc/modprobe.conf" ]; then
221cat /etc/modprobe.conf.cobbler >> /etc/modprobe.conf
222rm -f /etc/modprobe.conf.cobbler
223fi
224# End post_install_network_config generated code
225 
226 
227 
228 
229# Start download cobbler managed config files (if applicable)
230# End download cobbler managed config files (if applicable)
231 
232# Start koan environment setup
233echo "export COBBLER_SERVER=192.168.211.50" > /etc/profile.d/cobbler.sh
234echo "setenv COBBLER_SERVER 192.168.211.50" > /etc/profile.d/cobbler.csh
235# End koan environment setup
236 
237# begin Red Hat management server registration
238# not configured to register to any Red Hat management server (ok)
239# end Red Hat management server registration
240 
241# Begin cobbler registration
242# skipping for system-based installation
243# End cobbler registration
244 
245# Enable post-install boot notification
246 
247# Start final steps
248 
251# End final steps
252%end

 

 

 

CentOS7x64下安装Cobbler

测试中发现,无法导入32位系统镜像,使用32位的CentOS安装Cobbler也不行,目前未解决。

 

001# 安装环境
002# cat /etc/redhat-release
003CentOS Linux release 7.1.1503 (Core)
004 
005# uname -a
006Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
007 
008 
009# cat /etc/redhat-release
010CentOS Linux release 7.1.1503 (Core)
011[root@localhost ~]# uname -a
012Linux localhost.localdomain 3.10.0-229.20.1.el7.x86_64 #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
013 
014# rpm -qa cobbler
015cobbler-2.6.10-1.el7.noarch
016 
017####################################################################################
018#
019#安装过程
020#
021####################################################################################
022# 增加repo源
023rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
024# 或
025wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
026 
027# 安装Cobbler及相关软件
028yum -y install httpd xinetd tftp-server dnsmasq rsync syslinux
029yum -y install cobbler fence-agents pykickstart
030 
031# 关闭selinux
032# vi /etc/selinux/config
033SELINUX=disabled
034 
035# 获取selinux状态
036# getenforce
037 
038# 关闭iptables
039systemctl stop firewalld
040systemctl disable firewalld
041 
042# 生成系统安装后,root的密码 (默认密码为 cobbler)
043# 格式 openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
044# 其中 random-phrase-here 为干扰码
045 
046# openssl passwd -1 -salt 'allgo' 'allgo.cc'                                
047$1$allgo$sjkKoGvJXV2AuBNFeHyxP.
048 
049# 修改Cobbler配置/etc/cobbler/settings
050manage_dhcp:1
051manage_dns:1
052manage_tftpd:1
053restart_dhcp:1
054restart_dns:1
055next_server:<服务器的 IP 地址>
056server:<服务器的 IP 地址>
057default_password_crypted: "$1$allgo$sjkKoGvJXV2AuBNFeHyxP."
058 
059# 修改 modules,使用dnsmasq作为DHCP、DNS服务器
060# vi /etc/cobbler/modules.conf
061[dns]
062module = manage_dnsmasq
063 
064[dhcp]
065module = manage_dnsmasq
066 
067[tftpd]
068module = manage_in_tftpd
069 
070# 修改dnsmasq配置文件 /etc/dnsmasq.conf
071# vi /etc/dnsmasq.conf
072 
073# Cobbler generated configuration file for dnsmasq
074# $date
075#
076 
077# resolve.conf .. ?
078#no-poll
079#enable-dbus
080read-ethers
081addn-hosts = /var/lib/cobbler/cobbler_hosts
082 
083dhcp-range=192.168.211.10,192.168.211.29,255.255.255.0
084dhcp-ignore=tag:!known
085dhcp-option=3,$next_server
086dhcp-lease-max=1000
087dhcp-authoritative
088dhcp-boot=pxelinux.0
089dhcp-boot=net:normalarch,pxelinux.0
090dhcp-boot=net:ia64,$elilo
091 
092$insert_cobbler_system_definitions
093 
094# TFTP配置
095# cat /etc/xinetd.d/tftp
096# default: off
097# description: The tftp server serves files using the trivial file transfer \
098#       protocol.  The tftp protocol is often used to boot diskless \
099#       workstations, download configuration files to network-aware printers, \
100#       and to start the installation process for some operating systems.
101service tftp
102{
103        socket_type             = dgram
104        protocol                = udp
105        wait                    = yes
106        user                    = root
107        server                  = /usr/sbin/in.tftpd
108        server_args             = -s /var/lib/tftpboot
109        disable                 = no
110        per_source              = 11
111        cps                     = 100 2
112        flags                   = IPv4
113}
114 
115systemctl start xinetd.service
116systemctl status xinetd.service
117systemctl enable xinetd.service
118 
119systemctl start tftp.socket
120systemctl status tftp.socket
121systemctl enable tftp.socket
122 
123systemctl start tftp.service
124systemctl status tftp.service
125systemctl enable tftp.service
126 
127# 配置httpd
128cd /etc/httpd/conf.d/
129#移除并备份conf文件,目的不显示测试页面
130mv autoindex.conf autoindex.conf.bak
131mv userdir.conf userdir.conf.bak
132mv welcome.conf welcome.conf.bak
133 
134 
135# 启动httpd、Cobbler
136systemctl start httpd.service
137systemctl enable httpd.service
138systemctl status httpd.service
139 
140systemctl start cobblerd.service
141systemctl enable cobblerd.service
142systemctl status cobblerd.service
143 
144# Cobbler检查,会检测到一些错误,根据提示解决
145cobbler check
146 
147# Cobbler配置应用
148cobbler sync
149 
150# 查看相关应用是否启动
151ss -naltu
152 
153 
154# 准备安装文件
155# 导入iso文件
156mount -t iso9660 -o loop,ro /os/CentOS-7-x86_64-Minimal-1503-01.iso /mnt
157cobbler import --name=centos7mini --path=/mnt --arch=x86_64
158# cobbler import --arch=x86_64 --path=/mnt --name=centos7mini2
159 
160# 查看导入结果
161cobbler distro list
162cobbler distro report
163cobbler profile report
164 
165# 添加kickstart配置文件
166# 从现有sample_end 修改得到
167# cp /var/lib/cobbler/kickstarts/sample_end.ks /var/lib/cobbler/kickstarts/jxl_data.ks
168# vi /var/lib/cobbler/kickstarts/jxl_data.ks
169timezone Asia/Shanghai --isUtc
170lang en_US.UTF-8 --addsupport=zh_CN.UTF-8
171 
172# 添加账号
173# user --name=<username> [--groups=<list>] [--homedir=<homedir>] [--password=<password>] [--iscrypted] [--shell=<shell>] [--uid=<uid>]
174user --name="centos" --iscrypted="$1$juxinli$PEn5Sl/DCkrLOGeSmVrFP1" --uid=1000
175 
176 
177# Allow anaconda to partition the system as needed
178# autopart
179 
180# Partition clearing information
181clearpart --all --initlabel
182# Disk partitioning information
183part / --asprimary --fstype="xfs" --size=204800
184part /boot --asprimary --fstype="xfs" --size=1024
185part swap --asprimary --fstype="swap" --size=4096
186# kvm
187part /vm --asprimary --fstype="xfs" --grow --size=1
188# data
189part /data --asprimary --fstype="xfs" --grow --size=1
190 
191#LVM-data
192part /boot --fstype="xfs" --size=1024
193part swap --fstype="swap" --size=4096
194part pv.01 --size=1 --grow
195volgroup centos pv.01
196logvol  / --fstype="xfs" --vgname=centos  --size=2048  --name=root
197logvol  /data  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=data
198 
199 
200#LVM-kvm
201part /boot --fstype="xfs" --size=1024
202part swap --fstype="swap" --size=4096
203part pv.01 --size=1 --grow
204volgroup centos pv.01
205logvol  / --fstype="xfs" --vgname=centos  --size=2048  --name=root
206logvol  /vm  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=vm
207 
208 
209 
210 
211 
212 
213 
214# cobbler profile add --name=Fedora17-xfce --ksmeta='desktop_pkg_group=@xfce-desktop' --kickstart=/var/lib/cobbler/kickstarts/example.ks --parent=centos7mini2-x86_64
215# cobbler profile add --name=centos-data --kickstart=/var/lib/cobbler/kickstarts/jxl_data.ks --parent=centos7mini2-x86_64
216 
217# 修改kickstart文件
218cobbler profile edit --name=centos7mini-x86_64 --kickstart=/var/lib/cobbler/kickstarts/jxl_data.ks
219 
220# 验证kickstart文件内容
221cobbler profile getks --name=centos7mini-x86_64
222 
223# 配置需要安装的机器
224# 针对MAC为00:0C:29:48:30:63的机器安装
225cobbler system add --name=test --profile=centos7mini-x86_64 --interface=eno16777736 --mac=00:0C:29:48:30:63 --ip-address=192.168.211.11 --netmask=255.255.255.0 --static=1 --dns-name=test.mydomain.com --gateway=192.168.211.1 --hostname=test.mydomain.com
226 
227cobbler system report
228 
229 
230#######
231# 让配置生效
232cobbler sync
233 
234#######注意################
235# 检查 dnsmasq dhcp-range是否正确,因为cobbler sync 会修改
236grep "range" /etc/dnsmasq.conf
237dhcp-range=192.168.211.10,192.168.211.20
238 
239# 修改/etc/dnsmasq.conf 后需要重启dnsmasq
240systemctl restart dnsmasq.service
241 
242 
243 
244##############################
245# 安装Cobbler Web 界面
246 
247yum -y install cobbler-web
248# 修改授权
249# /etc/cobbler/modules.conf
250[authentication]
251module = authn_pam
252 
253[authorization]
254module = authz_ownership
255 
256# 添加Cobbler_web 账号
257# useradd web && passwd web
258 
259# 将 账号 添加到Cobbler_web admins组
260# cat /etc/cobbler/users.conf
261[admins]
262admin = ""
263cobbler = ""
264web = ""
265 
266# 重启服务
267service cobblerd restart
268service httpd restart
269 
270# 登录WEB(注意使用https)
271https://192.168.211.131/cobbler_web/
272 
273 
274# Cobbler 子命令介绍
275cobbler check         #检查cobbler配置
276cobbler sync          #步配置到dhcp pxe和数据目录
277cobbler list          #列出所有的cobbler元素
278cobbler import        #导入安装的系统光盘镜像
279cobbler report        #列出各元素的详细信息
280cobbler distro        #查看导入的发行版系统信息
281cobbler profile       #查看配置信息
282cobbler system        #查看添加的系统信息
283cobbler reposync      #同步yum仓库到本地
284 
285cobbler repo add --name=CentOS-7-x86_64 --mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/
286cobbler reposync
287 
288 
289# 参考文档
290# Cobbler官网
291http://cobbler.github.io/manuals/quickstart/
292http://cobbler.github.io/manuals/2.6.0/
293# dnsmasq设置
294http://debugo.com/dnsmasq/
295# 使用 Cobbler 自动化和管理系统安装
296http://www.ibm.com/developerworks/cn/linux/l-cobbler/
297# Cobbler自动化工具同时批量部署CentOS7及CentOS6.5
298http://www.tuicool.com/articles/YZN3qi
299#kickstart配置文件详解
300http://blog.chinaunix.net/uid-17240700-id-2813881.html

 

wget 下载 java或jdk

Oracle官网上下载jdk,需要点击accept licence的才能下载,使用下面的命令,直接可以下载。

1wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm

下载完毕后最好验证一下md5

1# md5sum jdk-7u79-linux-x64.rpm jdk-7u79-linux-x64.rpm
28486da4cdc4123f5c4f080d279f07712  jdk-7u79-linux-x64.rpm

下载页面:
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

https://www.oracle.com/webfolder/s/digest/7u79checksum.html

 

参考:http://www.oschina.net/code/snippet_875267_44726

CentOS下安装Jira

  安装环境:

01# cat /etc/redhat-release
02CentOS release 6.6 (Final)
03 
04# uname -a
05Linux Jira-it 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
06 
07# java -version
08java version "1.6.0_36"
09OpenJDK Runtime Environment (IcedTea6 1.13.8) (rhel-1.13.8.1.el6_7-x86_64)
10OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
11  
12# javac -version
13javac 1.6.0_36
14 
15# mysql -V
16mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

Jira检查安装环境:

01# /usr/share/jira/atlassian-jira-6.3.6-standalone/bin/version.sh
02                .....
03          .... .NMMMD.  ...
04        .8MMM.  $MMN,..~MMMO.
05        .?MMM.         .MMM?.
06 
07     OMMMMZ.           .,NMMMN~
08     .IMMMMMM. .NMMMN. .MMMMMN,
09       ,MMMMMM$..3MD..ZMMMMMM.
10        =NMMMMMM,. .,MMMMMMD.
11         .MMMMMMMM8MMMMMMM,
12           .ONMMMMMMMMMMZ.
13             ,NMMMMMMM8.
14            .:,.$MMMMMMM
15          .IMMMM..NMMMMMD.
16         .8MMMMM:  :NMMMMN.
17         .MMMMMM.   .MMMMM~.
18         .MMMMMN    .MMMMM?.
19 
20      Atlassian JIRA
21      Version : 6.3.6
22                   
23Detecting JVM PermGen support...
24PermGen switch is supported. Setting to 384m
25 
26If you encounter issues starting or stopping JIRA, please see the Troubleshooting guide at http://confluence.atlassian.com/display/JIRA/Installation+Troubleshooting+Guide
27 
28 
29Server startup logs are located in /usr/share/jira/atlassian-jira-6.3.6-standalone/logs/catalina.out
30Using CATALINA_BASE:   /usr/share/jira/atlassian-jira-6.3.6-standalone
31Using CATALINA_HOME:   /usr/share/jira/atlassian-jira-6.3.6-standalone
32Using CATALINA_TMPDIR: /usr/share/jira/atlassian-jira-6.3.6-standalone/temp
33Using JRE_HOME:        /usr
34Using CLASSPATH:       /usr/share/jira/atlassian-jira-6.3.6-standalone/bin/bootstrap.jar:/usr/share/jira/atlassian-jira-6.3.6-standalone/bin/tomcat-juli.jar
35Using CATALINA_PID:    /usr/share/jira/atlassian-jira-6.3.6-standalone/work/catalina.pid
36Server version: Apache Tomcat/7.0.55
37Server built:   Jul 18 2014 05:34:04
38Server number:  7.0.55.0
39OS Name:        Linux
40OS Version:     2.6.32-504.el6.x86_64
41Architecture:   amd64
42JVM Version:    1.6.0_36-b36
43JVM Vendor:     Sun Microsystems Inc.

安装过程: 继续阅读

PXE网络安装CentOS7.1

PXE网络安装CentOS 7.1,安装环境:
先安装一台桌面版CentOS(使用CentOS-7-x86_64-DVD-1503-01.iso安装),作为启动服务器,ip为192.168.72.32。

1#安装http、tftp、dhcp服务
2yum install httpd tftp-server dhcp
3 
4#安装syslinux,安装后才有文件 /usr/share/syslinux/pxelinux.0
5yum install syslinux
6 
7#安装system-config-kickstart配置启动文件,
8yum install system-config-kickstart
1#DHCP配置
2cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

DHCP配置文件修改

01# cat /etc/dhcp/dhcpd.conf
02# dhcpd.conf
03#
04# Sample configuration file for ISC dhcpd
05#
06 
07# option definitions common to all supported networks...
08#domain-name 修改为对应名称
09option domain-name "localhost";
10option domain-name-servers 223.5.5.5, 223.6.6.6;
11 
12default-lease-time 600;
13max-lease-time 7200;
14 
15# Use this to enble / disable dynamic dns updates globally.
16#ddns-update-style none;
17 
18# If this DHCP server is the official DHCP server for the local
19# network, the authoritative directive should be uncommented.
20#authoritative;
21 
22# Use this to send dhcp log messages to a different log file (you also
23# have to hack syslog.conf to complete the redirection).
24log-facility local7;
25 
26# No service will be given on this subnet, but declaring it helps the
27# DHCP server to understand the network topology.
28 
29 
30subnet 192.168.72.0 netmask 255.255.255.0 {
31        range 192.168.72.243 192.168.72.250;
32        option routers 192.168.72.1;
33        next-server 192.168.72.32; #TFTP服务器IP
34        filename "pxelinux.0";
35 
36}

#tftp配置,disable = no

01# cat /etc/xinetd.d/tftp
02# default: off
03# description: The tftp server serves files using the trivial file transfer \
04#       protocol.  The tftp protocol is often used to boot diskless \
05#       workstations, download configuration files to network-aware printers, \
06#       and to start the installation process for some operating systems.
07service tftp
08{
09        socket_type             = dgram
10        protocol                = udp
11        wait                    = yes
12        user                    = root
13        server                  = /usr/sbin/in.tftpd
14        server_args             = -s /var/lib/tftpboot
15        disable                 = no  #修改
16        per_source              = 11
17        cps                     = 100 2
18        flags                   = IPv4
19}

httpd配置

1cd /etc/httpd/conf.d/
2#移除并备份conf文件,目的不显示测试页面
3mv autoindex.conf autoindex.conf.bak
4mv userdir.conf userdir.conf.bak
5mv welcome.conf welcome.conf.bak
6 
7#http目录文件准备
8mkdir /var/www/html/centos
9mount ~/CentOS-7-x86_64-DVD-1503-01.iso /var/www/html/centos

/var/www/html/ks.cfg 文件配置

01# cat /var/www/html/ks.cfg
02#platform=x86, AMD64, or Intel EM64T
03#version=DEVEL
04# Install OS instead of upgrade
05install
06# Keyboard layouts
07keyboard 'us'# Reboot after installation
08reboot
09# Root password
10rootpw --iscrypted $1$BhbE2ZLC$D/XPM6Jscst055R3X0nLp.
11# System timezone
12timezone Asia/Shanghai --isUtc
13# Use network installation
14url --url="http://192.168.72.32/centos"  #最后面不需要加 /
15# System language
16lang en_US
17# Firewall configuration
18firewall --disabled
19# Network information
20network  --bootproto=dhcp --device=ens0 --onboot=yes --noipv6 --hostname=pxe_one
21# System authorization information
22auth  --useshadow  --passalgo=sha512
23# Use graphical install
24graphical
25firstboot --disable
26# SELinux configuration
27selinux --disabled
28 
29# System bootloader configuration
30# 新硬盘需要创建mbr
31bootloader --location=mbr
32# Clear the Master Boot Record
33zerombr
34# Partition clearing information
35clearpart --all --initlabel
36# Disk partitioning information
37part / --asprimary --fstype="xfs" --size=20480
38part /boot --asprimary --fstype="xfs" --size=512
39part swap --asprimary --fstype="swap" --size=2048
40part /data --asprimary --fstype="xfs" --grow --size=1
41 
42%packages
43@core
44#@chinese-support
45#iptraf
46#vim
47#openssh-server
48#ntp
49#wget
50 
51%end

http根目录结构

01# tree -aL 2 /var/www/html/
02/var/www/html/
03├── centos
04│   ├── CentOS_BuildTag
05│   ├── .discinfo
06│   ├── EFI
07│   ├── EULA
08│   ├── GPL
09│   ├── images
10│   ├── isolinux
11│   ├── LiveOS
12│   ├── Packages
13│   ├── repodata
14│   ├── RPM-GPG-KEY-CentOS-7
15│   ├── RPM-GPG-KEY-CentOS-Testing-7
16│   ├── TRANS.TBL
17│   └── .treeinfo
18└── ks.cfg
19 
207 directories, 9 files

tftp目录文件准备

01#tftp目录文件准备
02cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
03mkdir /var/lib/tftpboot/pxelinux.cfg
04cp /var/www/html/centos/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
05cp /var/www/html/centos/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
06cp /var/www/html/centos/isolinux/{vesamenu.c32,boot.msg,splash.png} /var/lib/tftpboot/
07 
08# tree /var/lib/tftpboot/
09/var/lib/tftpboot/
10├── boot.msg
11├── initrd.img
12├── pxelinux.0
13├── pxelinux.cfg
14│   └── default
15├── splash.png
16├── vesamenu.c32
17└── vmlinuz
18 
191 directory, 7 files

/var/lib/tftpboot/pxelinux.cfg/default 文件

001# cat /var/lib/tftpboot/pxelinux.cfg/default
002default vesamenu.c32
003timeout 60
004 
005display boot.msg
006 
007# Clear the screen when exiting the menu, instead of leaving the menu displayed.
008# For vesamenu, this means the graphical background is still displayed without
009# the menu itself for as long as the screen remains in graphics mode.
010menu clear
011menu background splash.png
012menu title CentOS 7
013menu vshift 8
014menu rows 18
015menu margin 8
016#menu hidden
017menu helpmsgrow 15
018menu tabmsgrow 13
019 
020# Border Area
021menu color border * #00000000 #00000000 none
022 
023# Selected item
024menu color sel 0 #ffffffff #00000000 none
025 
026# Title bar
027menu color title 0 #ff7ba3d0 #00000000 none
028 
029# Press [Tab] message
030menu color tabmsg 0 #ff3a6496 #00000000 none
031 
032# Unselected menu item
033menu color unsel 0 #84b8ffff #00000000 none
034 
035# Selected hotkey
036menu color hotsel 0 #84b8ffff #00000000 none
037 
038# Unselected hotkey
039menu color hotkey 0 #ffffffff #00000000 none
040 
041# Help text
042menu color help 0 #ffffffff #00000000 none
043 
044# A scrollbar of some type? Not sure.
045menu color scrollbar 0 #ffffffff #ff355594 none
046 
047# Timeout msg
048menu color timeout 0 #ffffffff #00000000 none
049menu color timeout_msg 0 #ffffffff #00000000 none
050 
051# Command prompt text
052menu color cmdmark 0 #84b8ffff #00000000 none
053menu color cmdline 0 #ffffffff #00000000 none
054 
055# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
056 
057menu tabmsg Press Tab for full configuration options on menu items.
058 
059menu separator # insert an empty line
060menu separator # insert an empty line
061 
062label linux
063  menu label ^Install CentOS 7
064  menu default
065  kernel vmlinuz
066# append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet
067  append initrd=initrd.img inst.ks=http://192.168.72.32/ks.cfg quiet
068 
069label check
070  menu label Test this ^media & install CentOS 7
071  kernel vmlinuz
072  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet
073 
074menu separator # insert an empty line
075 
076# utilities submenu
077menu begin ^Troubleshooting
078  menu title Troubleshooting
079 
080label vesa
081  menu indent count 5
082  menu label Install CentOS 7 in ^basic graphics mode
083  text help
084        Try this option out if you're having trouble installing
085        CentOS 7.
086  endtext
087  kernel vmlinuz
088  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet
089 
090label rescue
091  menu indent count 5
092  menu label ^Rescue a CentOS system
093  text help
094        If the system will not boot, this lets you access files
095        and edit config files to try to get it booting again.
096  endtext
097  kernel vmlinuz
098  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet
099 
100label memtest
101  menu label Run a ^memory test
102  text help
103        If your system is having issues, a problem with your
104        system's memory may be the cause. Use this utility to
105        see if the memory is working correctly.
106  endtext
107  kernel memtest
108 
109menu separator # insert an empty line
110 
111label local
112  menu label Boot from ^local drive
113  localboot 0xffff
114 
115menu separator # insert an empty line
116menu separator # insert an empty line
117 
118label returntomain
119  menu label Return to ^main menu
120  menu exit
121 
122menu end

启动服务器

01#启动服务器
02iptables -F
03systemctl start httpd.service
04systemctl status httpd.service
05systemctl enable httpd.service
06 
07systemctl start dhcpd.service
08systemctl status dhcpd.service
09systemctl enable dhcpd.service
10 
11systemctl start xinetd.service
12systemctl status xinetd.service
13systemctl enable xinetd.service
14 
15systemctl start tftp.socket
16systemctl status tftp.socket
17systemctl enable tftp.socket
18 
19systemctl start tftp.service
20systemctl status tftp.service
21systemctl enable tftp.service

查看服务端口是否正常

1#查看服务端口是否正常 tcp-80、udp-67、udp-69
2ss -tilnp
3ss -uilnp
4#或
5netstat -nat
6netstat -nau
7 
8#查看dhcp地址分配情况
9/var/lib/dhcpd/dhcpd.leases

继续阅读

SquidTL安装–待续

安装系统:CentOS 7.1

1wget http://www.zerozone.it/Software/Linux/SquidTL/squidtl-0.0.2.tar.gz
2 
3tar -vxzf squidtl-0.0.2.tar.gz
4 
5cd squidtl/

1yum install automake
2cp -rf /usr/share/automake-1.13 /usr/share/automake-1.10

01# ./configure
02checking for a BSD-compatible install... /usr/bin/install -c
03checking whether build environment is sane... yes
04checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
05checking for gawk... gawk
06checking whether make sets $(MAKE)... yes
07checking for gcc... gcc
08checking for C compiler default output file name... a.out
09checking whether the C compiler works... yes
10checking whether we are cross compiling... no
11checking for suffix of executables...
12checking for suffix of object files... o
13checking whether we are using the GNU C compiler... yes
14checking whether gcc accepts -g... yes
15checking for gcc option to accept ISO C89... none needed
16checking for style of include used by make... GNU
17checking dependency style of gcc... gcc3
18checking how to run the C preprocessor... gcc -E
19checking for grep that handles long lines and -e... /usr/bin/grep
20checking for egrep... /usr/bin/grep -E
21checking for ANSI C header files... yes
22checking for mysql_config... no
23configure: error: Couldn't find mysql_config. Please verify that it is installed.

configure: error: Couldn’t find mysql_config. Please verify that it is installed.

01# yum provides */mysql_config
02Loaded plugins: fastestmirror, langpacks
03Loading mirror speeds from cached hostfile
04 * base: mirrors.aliyun.com
05 * epel: epel.mirror.srv.co.ge
06 * extras: mirrors.aliyun.com
07 * updates: mirrors.aliyun.com
08epel/x86_64/filelists_db                                                                                                                              | 6.3 MB  00:00:06    
091:mariadb-devel-5.5.41-2.el7_0.i686 : Files for development of MariaDB/MySQL applications
10Repo        : base
11Matched from:
12Filename    : /usr/lib/mysql/mysql_config
13Filename    : /usr/bin/mysql_config
14 
15 
16 
171:mariadb-devel-5.5.41-2.el7_0.x86_64 : Files for development of MariaDB/MySQL applications
18Repo        : base
19Matched from:
20Filename    : /usr/bin/mysql_config
21Filename    : /usr/lib64/mysql/mysql_config
1yum install mariadb-devel

 

01./configure
02checking for a BSD-compatible install... /usr/bin/install -c
03checking whether build environment is sane... yes
04checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
05checking for gawk... gawk
06checking whether make sets $(MAKE)... yes
07checking for gcc... gcc
08checking for C compiler default output file name... a.out
09checking whether the C compiler works... yes
10checking whether we are cross compiling... no
11checking for suffix of executables...
12checking for suffix of object files... o
13checking whether we are using the GNU C compiler... yes
14checking whether gcc accepts -g... yes
15checking for gcc option to accept ISO C89... none needed
16checking for style of include used by make... GNU
17checking dependency style of gcc... gcc3
18checking how to run the C preprocessor... gcc -E
19checking for grep that handles long lines and -e... /usr/bin/grep
20checking for egrep... /usr/bin/grep -E
21checking for ANSI C header files... yes
22checking for mysql_config... /usr/bin/mysql_config
23checking for pkg-config... /usr/bin/pkg-config
24checking pkg-config is at least version 0.9.0... yes
25checking for XML... no
26configure: error: libxml2 is required.

configure: error: libxml2 is required.

1yum install libxml2-devel
01# ./configure       
02checking for a BSD-compatible install... /usr/bin/install -c
03checking whether build environment is sane... yes
04checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
05checking for gawk... gawk
06checking whether make sets $(MAKE)... yes
07checking for gcc... gcc
08checking for C compiler default output file name... a.out
09checking whether the C compiler works... yes
10checking whether we are cross compiling... no
11checking for suffix of executables...
12checking for suffix of object files... o
13checking whether we are using the GNU C compiler... yes
14checking whether gcc accepts -g... yes
15checking for gcc option to accept ISO C89... none needed
16checking for style of include used by make... GNU
17checking dependency style of gcc... gcc3
18checking how to run the C preprocessor... gcc -E
19checking for grep that handles long lines and -e... /usr/bin/grep
20checking for egrep... /usr/bin/grep -E
21checking for ANSI C header files... yes
22checking for mysql_config... /usr/bin/mysql_config
23checking for pkg-config... /usr/bin/pkg-config
24checking pkg-config is at least version 0.9.0... yes
25checking for XML... yes
26checking for strdup... yes
27checking for strerror... yes
28checking for vsprintf... yes
29checking for sigaction... yes
30checking for signal... yes
31configure: creating ./config.status
32config.status: creating Makefile
33config.status: creating src/Makefile
34config.status: creating src/config.h
35config.status: executing depfiles commands