System General Deployment Manual

1. centos7 version

#01挂载本地ISO镜像
mkdir -p /etc/yum.repos.d/bak
mv /etc/yum.repos.d/CentOS* /etc/yum.repos.d/bak

cat > /etc/yum.repos.d/dvd.repo <<EOF
[OEL7]
name=OEL7
baseurl=file:///media/
gpgcheck=0
enabled=1
EOF


mount /dev/cdrom /media/


yum install vim telnet net-tools ntpdate lrzsz unzip gcc -y


#将 SELINUX=enforcing 替换为SELINUX=disabled
sed -i "s|SELINUX=enforcing|SELINUX=disabled|" /etc/selinux/config

#替换zabbix  配置文件ip 192.168.1.2
sed -i "s|Server=127.0.0.1|Server=192.168.1.2|" /etc/zabbix/zabbix_agentd.conf
sed -i "s|ServerActive=127.0.0.1|ServerActive=192.168.1.2|" /etc/zabbix/zabbix_agentd.conf


#启动zabbix
systemctl enable zabbix-agent
systemctl start zabbix-agent.service
systemctl status zabbix-agent.service


# CentOS 7	开机不自动启动防火墙
systemctl disable firewalld.service
systemctl status firewalld.service

# 关闭防火墙
systemctl stop firewalld.service
setenforce 0

#CentOS7使用/etc/rc.d/rc.local设置开机自动启动
chmod +x /etc/rc.d/rc.local

#修改主机名-CentOS 7
hostnamectl set-hostname 'jspweb1'

echo -e "NETWORKING=yes\nHOSTNAME=jspweb1" >> /etc/sysconfig/network


#$tmp  追加空格
echo "182.11.100.2$tmp jspweb1" >> /etc/hosts

2. centos6 version

1. System firewall configuration

A. It takes effect after restarting
. Turn on: chkconfig iptables on.
Turn off: chkconfig iptables off
. B. It takes effect immediately and becomes invalid after restarting
. Turn on: service iptables start
. Turn off: service iptables stop.

2. Machine name setting

Linux machine name setting
View the machine name
hostname
list: Set the machine name rw_01
hostname rw_01

vi /etc/sysconfig/network
HOSTNAME=rw_01

#Solution to the inability to find the host name
vi /etc/hosts

127.0.0.1 rw_01 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

3. Linux machine time setting

A. Set the date
date –s 2017-05-03
B. Set the time
date –s 14:23:13
View the time
date

4. Synchronization time

a.ntpd服务的设置

[root@linux ~]# vi /etc/ntp.conf 
#添加下面2行
server 127.127.1.0
fudge 127.127.1.0 stratum 10

b.启动ntpd服务
#关闭ntp
#service ntpd stop
#启动ntp
service ntpd start

c.添加时间同步定时任务
vi /etc/crontab
#加上下面一句:
#每天早上6点同步时间,时间同步服务器进行同步并写入BIOS
0 6 * * * root /usr/sbin/ntpdate 10.28.19.81; /sbin/hwclock -w

5. System encoding settings

查看系统编码方式
locale

设置系统编码方式
vi /etc/sysconfig/i18n
#在打开的文件中填写内容(粘贴上去)
LANG="zh_CN.GB18030"
SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"

更新刚设置的系统编码
source /etc/sysconfig/i18n

6. JDK installation and environment settings:

1. Install jdk on the linux platform and log in to linux as the root user.

aUpload the linux version of the jdk installation package jdk-7u79-linux-x64.rpm to /opt
and enter the installation directory

[root@localhost ~]#cd /opt
[root@localhost opt]#rpm -ivh jdk-7u79-linux-x64.rpm

b. Set environment variables.

[root@localhost ~]#vi /etc/profile

#在最后面加入 
#java环境变量
export JAVA_HOME=/usr/java/jdk1.7.0_79
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#保存退出。

c. Check whether the JDK is installed successfully.

[root@localhost ~]#java -version

If you see the JVM version and related information, the installation is successful.

2. JDK environment variables (Windows)

System Variables → Create a new JAVA_HOME variable.
.Fill
in the jdk installation directory with variable value (my name is E:\Java\jdk1.7.0)

System variables → Find Path variables → Edit
.
Enter the variable value at the end (note whether there is a ; sign at the end of the original Path variable value. If not, enter the ; sign first and then enter the above code)

%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;

.System
variables→Create a new CLASSPATH variable
.
Fill in the variable value (note the dot at the front)

.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar

System variables are configured

Check whether the configuration is successful. Run cmd and enter java -version (there is a space between java and -version)
.
If the version information is displayed as shown in the figure, the installation and configuration are successful.

7. Tomcat installation

上传linux版本的tomcat安装包apache-tomcat-7.0.62.tar.gz到 /opt
进入安装目录
A.解压文件
tar  –xzvf  apache-tomcat-7.0.62.tar.gz

B.启动 tomcat
cd /opt/apache-tomcat-7.0.62
#./bin/startup.sh


C.关闭 tomcat
cd /opt/apache-tomcat-7.0.62
./bin/shutdown.sh 
 

D.查看tomcat进程如果发现JAVA进程可用kill -9 xx杀死进程
 ps –ef |grep tomcat 

8. Database redis installation

1.将程序redis-2.8.20-3.el6.art.x86_64.rpm
依赖包jemalloc-3.6.0-1.el6.art.x86_64.rpm上传到/opt目录下
(1)安装jemalloc依赖包
[root@localhost ~]# cd /opt
[root@localhost opt]# rpm –ivh jemalloc-3.6.0-1.el6.art.x86_64.rpm

(2)安装redis
[root@localhost ~]#cd /opt
[root@localhost ~]# rpm –ivh redis-2.8.20-3.el6.art.x86_64.rpm

(3) Configure redis file
[root@localhost ~]#vi /etc/redis.conf

#daemonize no修改为daemonize yes
daemonize yes

#database 16修改为
database 32
#修改为bind 127.0.0.1和本机ip地址
bind 127.0.0.1 192.168.01.01

#requirepass foobared去掉注释,foobared改为自己的密码,我在这里改为
requirepass dafasf@131.

(4) Start the redis service
[root@localhost ~]# service redis start

(5) Close the redis service
[root@localhost ~]# service redis stop

(6) Log in to redis
#01 without password and log in to
redis-cli -h 10.28.19.85

@02 Log in to
redis-cli with password -p 6379 -a 123456

  1. Compressed package installation

tar -zxvf redis-6.2.7.tar.gz
cd redis-6.2.7

#Install
make && make install

#Copy the configuration file
cp redis.conf /etc/

#Modify configuration parameters
vim /etc/redis.conf

#daemonize no修改为daemonize yes
daemonize yes

#database 16修改为
database 32
#修改为bind 127.0.0.1和本机ip地址
bind 127.0.0.1 192.168.01.01

#requirepass foobared去掉注释,foobared改为自己的密码,我在这里改为
requirepass dafasf@131.

#Start
/usr/local/bin/redis-server /etc/redis.conf

9. Install nginx

1、安装nginx
#将程序nginx-1.8.0-1.el6.ngx.x86_64.rpm上传到/opt目录下
[root@localhost opt]# cd /opt
[root@localhost opt]# rpm –ivh nginx-1.8.0-1.el6.ngx.x86_64.rpm

2、启动nginx服务
[root@localhost ~]# service nginx start

3、关闭nginx服务
[root@localhost ~]# service nginx stop

10. Clean logs regularly

1、Linux删除文件命令:
find 对应目录 -mtime +天数 -name "文件名" -exec rm -rf {
    
    } \;

1.1案例
#删除10天前的日志
find /root/kinginx/nginx_app/logs/ -mtime +30 -name "*.log.*" -exec rm -rf {
    
    } \;

2、编辑shell脚本
touch /opt/soft/bin/delect.sh
#!/bin/sh
find /root/kinginx/nginx_app/logs/ -mtime +30 -name "*.log.*" -exec rm -rf {
    
    } \;


3、脚本授权
chmod  775 delect.sh



4、将脚本添加到定时任务中
vim /var/spool/cron/root
#每天凌晨12点05分执行
5 0 * * *  /usr/local/scriptTask/cleanlog.sh


5、查看定时任务
crontab -l  
#每天凌晨过5分执行
5 0 * * *  /opt/soft/bin/delect.sh

11. Mount the file server

1.在linux系统执行下面语句
(挂在windows的ip:192.168.58.1的D:\yum共享目录至此目录下)

mount -t cifs  -o username=Administrator,password=renwei1  //192.168.58.1/yum  /rhel_yum



2.通过修改fstab文件,支持开机自动挂载
修改/etc/fstab文件,文件最后加入:
//192.168.58.1/yum  /rhel_yum cifs default,username=Administrator,password=renwei1 0 2

12. Mysql uninstallation and installation

1.1. Install the mysql database
1.1.1. Uninstall the system mysql related package
rpm -qa | grep -i mysql
Uninstall the installed mysql related package through the command
rpm -e *
#Force to delete the mysql installation package

rpm -e mysql-libs-5.1.73-8.el6_8.x86_64 --nodeps

1.1.2. Install mysql
in the following order

rpm -ivh mysql-community-common-*.rpm

rpm -ivh mysql-community-libs-*.rpm

rpm -ivh mysql-community-client*.rpm

rpm -ivh mysql-community-server-5.7*.rpm

Start the mysql service
service mysql start
Set the mysql service to start automatically at boot
chkconfig mysql on
1.1.3. Modify the root user password
View the root user default password
cat /root/.mysql_secret
Use the default password to log in to
mysql -u root -p password
Change password
mysql > set password=password('bhzq8858');
1.1.4. Configure mysql
to copy the my.cnf configuration file
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
modify the configuration file, ignoring the case
vi /etc/my.cnf Add lower_case_table_names=1
under [mysqld] to restart the mysql service service mysql restart 1.1.5. Create a new koacif user and authorize mysql> create user koacif; mysql> GRANT ALL PRIVILEGES ON . TO 'koacif'@' %' IDENTIFIED BY 'koacif' WITH GRANT OPTION;






mysql> FLUSH PRIVILEGES;
1.1.6. Import database backup
Create koacif database
mysql -u root -p
mysql> CREATE DATABASE / !32312 IF NOT EXISTS / koacif/*!40100 DEFAULT CHARACTER SET utf8 */;
Execute the command
mysql -u root - p koacif<khv1dump.sql --default-character-set=utf8

1.1.7 Force password change and remote login authorization
vi /etc/my.cnf
#Enter the last line in this file:
skip-grant-tables

#Restart the MySQL service

service mysqld restart

#Log in to msyql
mysql -u root -p

mysql
mysql> use mysql;
mysql> UPDATE user SET password=password(“root”) WHERE user=‘root’;

mysql>GRANT ALL PRIVILEGES ON . TO ‘root’@‘192.168.199.99’ IDENTIFIED BY ‘密码’ WITH GRANT OPTION;

#Remote login authorization
mysql>GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

mysql> flush privileges;
mysql> exit;

1.1.8mysql master-slave configuration

1. Basic configuration of the main database (182.16.19.2 main)

(1) Open the master data configuration file my.cnf and add these items (it is best to type by hand, there are problems with copying)

server_id = 1 #Unique identification, the master database and slave database cannot be repeated
log_bin = mysql-bin #Open the log
binlog_do_db = test #Log those databases

[root@sx01 ~]# /etc/init.d/mysql restart

– Log in to mysql
[root@ ~]# mysql -u root -p
mysql>use mysql;
//Create a synchronization account in the master database to authorize the use of the slave database
mysql> create user 'slave'@'182.16.19.2' identified by 'slave123';
//Authorize replication in the master database to the slave database
mysql> grant replication slave on . to 'slave'@'182.16.19.1' identified by 'slave123';
//Refresh permissions
mysql> flush privileges;

//After adding the read lock, you can only read but not write
mysql> flush tables with read lock;

#Master library execution: show master status; Note down the values ​​of Position and File, which will be used later when configuring the slave library.
mysql> show master status;

mysql> quit;
//Backup the main database and transfer the backup file to the slave database
[root@ ~]# mysqldump -uroot -p test>test.sql;

[root@ ~]# scp test.sql [email protected]:/root/

[root@Execute from the library server~]# mysql -uroot -p test<test.sql;

2. Slave library (182.16.19.1) configuration information

(1) Modify the configuration file my.cnf

server_id = 2
log_bin = mysql-bin #Open log
binlog_do_db = test

/etc/init.d/mysql restart
–登入mysql
[root@ ~]# mysql -u root -p
mysql>stop slave;

mysql>change master to master_host=‘182.16.19.2’,master_user=‘slave’,master_password=‘slave123’,master_log_file=‘mysql-bin.000015’,Master_Log_Pos=885;

mysql>start slave;

mysql> show slave status \G

3. If you modify the new log

#Stop slave from machine
mysql> stop slave;

Flush logs: mysql>flush logs;
mysql> show master status;

mysql>CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin.000017’,MASTER_LOG_POS=120;

mysql> start slave;
mysql> show slave status \G

4. Synchronization failed: Slave_IO_Running: no
Use the following command to check the server_id. The code is as follows:

    mysql> show variables like 'server_id'; 
    +---------------+-------+ 
    | Variable_name | Value | 
    +---------------+-------+ 
    | server_id | 1 | 
    +---------------+-------+ 
    1 row in set (0.00 sec) 

It was found that mysql did not update the server_id from the my.cnf file. In this case, it can only be modified manually. The code is as follows:

mysql> set global server_id=2; #The value here is the same as the one set in my.cnf.

mysql> slave start;

13. Modify the Oracle monitoring host name

1. Configure the listener.ora and tnsnames.ora files under $ORACLE_HOME/network/admin/

2.Oracle data start and stop

A. Switch to the oracle user:
#su - oracle
B. Use the database administrator to connect to the oracle database:
sqlplus / as sysdba
C. Start the database:
sql>startup
D. Exit the database connection:
sql>exit
E. Start database monitoring:
lsnrctl start
F. Check the service startup status and see the following echo information. The service is started successfully:
lsnrctl status

Note: Close the database:
Close the listening service:
$lsnrctl stop
Use the database administrator to connect to the oracle database:
$sqlplus / as sysdba
Close the database:

shutdown immediate
exits the database connection:
exit

alter user sys identified by sys;

14. Linux Memcached installation

1.源代码安装
从其官方网站(http://memcached.org)下载memcached最新版本。
wget http://memcached.org/latest                    下载最新版本


yum install libevent libevent-devel -y

tar -zxvf memcached-1.x.x.tar.gz                    解压源码

cd memcached-1.x.x                                  进入目录
./configure --prefix=/usr/local/memcached           配置

make && make test                                   编译

sudo make install                                   安装

Guess you like

Origin blog.csdn.net/qq_35583325/article/details/88847172