在linux命令行安装oracle11g centos系统

http://space.itpub.net/21582653/viewspace-716034

 

在linux命令行安装oracle11g

 

一:环境设置

1.1  检查服务器硬件资源

Linux系统(x86-32)下的硬件要求

物理内存:最少1GB

交互空间:物理内存为1GB至2GB之间时,交互空间为物理内存的1.5倍;物理内存为2GB至8GB之间时,交互空间为物理内存的1倍;物理内存为8GB以上时,交互空间为物理内存的0.75倍。

磁盘空间:企业版4.35GB;标准版3.22GB;自定义(最大值):3.45GB

1.2  操作系统环境设置

X86(32位)Red Hat Enterise 5.0、CentOS5.0需要的安装包:

binutils-2.17.50.0.6-14.el5

elfutils-libelf-0.137-3.el5

elfutils-libelf-devel-0.137-3.el5

gcc-4.1.2-50.el5

gcc-c++-4.1.2-50.el5

glibc-2.5-58.el5_6.4

glibc-common-2.5-58.el5_6.4

glibc-devel-2.5-58.el5_6.4

glibc-headers-2.5-58.el5_6.4

libaio-devel-0.3.106-5

libaio-0.3.106-5

libgcc-4.1.2-50.el5

libstdc++-4.1.2-50.el5

libstdc++-devel-4.1.2-50.el5

make-3.81-3.el5

sysstat-7.0.2-3.el5

unixODBC-2.2.11-7.1

unixODBC-devel-2.2.11-7.1

1.3  内核参数设置

将以下参数设置加入/etc/sysctl.conf中,这样每次操作系统启动时,便会自动设置这些内核参数,而不需要每次都人工设置。

# vi /etc/sysctl.conf

fs.file-max = 6553600

kernel.shmall = 2097152

kernel.shmmax = 2147483648

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 1024 65000

net.core.rmem_default = 4194304

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 262144

 

使用sysctl –p命令使/etc/sysctl.conf设置值生效。

1.4  设置系统资源限制

假设未来由oracle这个系统用户安装Orace Database 11g,则系统管理员需要将以下参数添加到/etc/security/limits.conf中

# vi /etc/security/limits.conf

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft  nofile 1024

oracle hard  nofile 65536

 

接着,设置/etc/pam.d/login,启动系统资源限制。

# vi /etc/pam.d/login

session required  /lib/security/pam_limits.so

session required  pam_limits.so

 

最后,为了能让每个用户在每次登陆系统之后,都能自动设置其最大可启动进程数与最多可开启文件数,设置/etc/profile。

# vi /etc/profile

if [ $USER = “oracle” ] ; then

if [ $SHELL = “/bin/ksh” ]; then

ulimit –p 16384

ulimit -n 65536

else

ulimit –u 16384 -n 65536

fi

fi

 

 

1.5  网络设置

安装oracle database 11g的服务器必须有固定的IP地址。

 

1.6  创建用户组与用户账户

# groupadd oinstall

#groupadd  dba

#groupadd  oper

#useradd -g oinstall -G  dba,oper oracle

#passwd oracle

 

设置用户环境变量

将下列设置添加到/home/oracle/.bash_profile文件中

# vi  /home/oracle/.bash_profile

umask 022

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1

ORACLE_SID=orcl

PATH=$ORACLE_HOME/bin:$PATH

export PATH

export ORACLE_BASE ORACLE_HOME ORACLE_SID

export NLS_LANG=”SIMPLIFIED CHINESE_CHINA.ZHS16GBK”

 

设置安装路径

# mkdir -p /home/u01/app/oracle/product/11.1.0

# mkdir -p /home/u01/oradata

#chmod -R 775 /home/u01

#chown  -R oracle.oinstall /home/u01

 

二、安装Oracle Database  11g R1

把orace database 11g r1 的安装包下载到oracle用户的家目录解压,解压后的文件夹为database

# unzip  linux_11gR1_database_1013.zip

 

修改静默安装的应答文件

# vi database/install/response/ee.rsp

ORACLE_BASE=”/home/u01/app”

ORACLE_HOME=”/home/u01/app/oracle/product/11.1.0/db_1″

ORACLE_HOME_NAME=”orarch”

 

切换为oracle用户,以静默方式执行安装脚本,在安装过程中如果没有错误不会有信息输出,最后会输出请运行root.sh脚本的信息。

# su – oracle

$cd  database

$ ./runInstaller -responseFile /home/oracle/linux_11gR1/database/install/response/ee.rsp –silent

 

输出请运行root.sh脚本的信息时,打开另一个终端以root身份运行/home/u01/app/oracle/product/11.1.0/db_1脚本。

运行完root.sh脚本后在安装的终端中回车既完成安装。

ssh登陆缓慢的解决方法

原因之一是因为LINUX系统的一个文件/etc/nsswitch.conf ,在这里面有如下一行
hosts: files dns
这行的含义是对于访问的主机进行域名解析的顺序,是先访问file,也就是/etc/hosts文件,如果hosts中没有记录域名,则访问dns,进行域名解析,如果dns也无法访问,就会等待访问超时后返回,因此等待时间比较长。
解决这个问题有以下几个方法:
1、在server上/etc/hosts文件中把你本机的ip和hostname加入,改后便可生效;
2、在server上/etc/ssh/sshd_config文件中修改或加入UseDNS=no ,然后重启sshd服务(service sshd restart)即可;
3、注释掉server上/etc/resolv.conf中所有行,改后便可生效;
4、修改server上/etc/nsswitch.conf中hosts为hosts: files ,改后便可生效(即去掉dns参数);
#我访问慢的原因就是因为上边这个原因,通过上边几个方法都能解决掉。
另外一个原因可能是
authentication gssapi-with-mic出现问题,在server上/etc/ssh/sshd_config文件中修改GSSAPIAuthentication no.
/etc/init.d/sshd restart重启sshd进程使配置生效。

如果以上两招还不能解决问题,善于使用DEBUG MODE ssh -v来查看log,找到停滞时间最长的步骤,然后针对性的修改配置解决。

使用jsvc启动tomcat

使用jsvc启动tomcat,可以使用独立用户启动tomcat,限制权限

下面是官方教程,在docs项目里也有

http://tomcat.apache.org/tomcat-7.0-doc/setup.html

但这里只讲到了daemon.sh的使用就完了

下面总结下设置开机启动的步骤

#su –
新增运行tomcat的独立用户
#useradd -s /sbin/nologin tomcat
#passwd tomcat
复制启动脚本
#cp daemon.sh /etc/init.d/tomcat
#chmod 755 /etc/init.d/tomcat
修改启动脚本
#vi /etc/init.d/tomcat

在最上面添加环境变量

#JAVA_HOME=/webapps/jdk1.7.0_40/
#TOMCAT_HOME=/webapps/apache-tomcat-7.0.42
#CATALINA_HOME=$TOMCAT_HOME
#CATALINA_BASE=$TOMCAT_HOME
#设置启动tomcat的独立用户
#TOMCAT_USER=tomcat
#:wq
当然这些环境变量也可以在/etc/profile里配置成全局变量
#source /etc/profile使其立即生效

设置$TOMCAT_HOME目录的所有者为tomcat用户
#chown -R tomcat:tomcat $TOMCAT_HOME

启动tomcat
#service tomcat start

daemon.sh脚本不支持chkconfig –add tomcat 添加服务,
所以只能手动创建了
#cd /etc/rc3.d/
#ln -s ../init.d/tomcat S99tomcat
这样系统以runlevel3启动以后就会自动启动tomcat了

 

使MySQL对表名不区分大小写

LINUX下的MYSQL默认是要区分表名大小写的,所以很可能在windows运行好好的系统,放到Linux上就会报找不到表的错误

让MYSQL不区分表名大小写的方法其实很简单:

1.用ROOT登录,修改/etc/my.cnf

2.在[mysqld]下加入一行:lower_case_table_names=1

3.重新启动数据库即可

MySql实现远程连接

前提:

1、进入mysql,创建一个新用户root,密码为root:

格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by “用户密码”;
grant select,update,insert,delete on *.* to root@192.168.1.12 identified by “root”;

原先数据表结构

mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+———–+——+——————————————-+
| host      | user | password                                  |
+———–+——+——————————————-+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+———–+——+——————————————-+

执行上述语句后结果

mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+————–+——+——————————————-+
| host         | user | password                                  |
+————–+——+——————————————-+
| localhost    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+————–+——+——————————————-+
2 rows in set (0.00 sec)

 

可以看到在user表中已有刚才创建的root用户。host字段表示登录的主机,其值可以用IP,也可用主机名,

(1)有时想用本地IP登录,那么可以将以上的Host值改为自己的Ip即可。

2、实现远程连接(授权法)

将host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql服务器,建议在开发时设为%。
update user set host = ’%’ where user = ’root’;

将权限改为ALL PRIVILEGES

mysql> use mysql;
Database changed
mysql> grant all privileges  on *.* to root@’%’ identified by “root”;
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,password from user;
+————–+——+——————————————-+
| host         | user | password                                  |
+————–+——+——————————————-+
| localhost    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| %            | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+————–+——+——————————————-+
3 rows in set (0.00 sec)

这样机器就可以以用户名root密码root远程访问该机器上的MySql.

3、实现远程连接(改表法)

use mysql;

update user set host = ‘%’ where user = ‘root’;

这样在远端就可以通过root用户访问Mysql.

 

总结:第一种方法就是修改表的数据

centos6.4 MySQL 5.5 安装过程

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. This is guide, howto install or upgrade MySQL Community Server latest and greatest version 5.5.33 on Fedora 18/17/16/15/14/13/12, CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9.

Note: If you are upgrading MySQL (from earlier version), then make sure that you backup (dump and copy) your database and configs. And remember run mysql_upgrade command.

Install MySQL Database 5.5.33 on Fedora 18/17/16/15/14/13/12, CentOS 6.4/5.9, Red Hat (RHEL) 6.4/5.9

1. Change root user

su -
## OR ##
sudo -i

2. Install Remi repository

Fedora

## Remi Dependency on Fedora 18, 17, 16
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm 
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

## Fedora 18 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm

## Fedora 17 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm

## Fedora 16 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-16.rpm

## Fedora 15 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-15.rpm

## Fedora 14 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-14.rpm

## Fedora 13 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-13.rpm

## Fedora 12 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-12.rpm

CentOS and Red Hat (RHEL)

## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

## CentOS 6 and Red Hat (RHEL) 6 ##
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

## Remi Dependency on CentOS 5 and Red Hat (RHEL) 5 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

## CentOS 5 and Red Hat (RHEL) 5 ## 
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

3. Check Available MySQL versions

Fedora 18, 17, 16, 15, 14, 13, 12

yum --enablerepo=remi list mysql mysql-server

CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

yum --enablerepo=remi,remi-test list mysql mysql-server

Output:

Loaded plugins: changelog, fastestmirror, presto, refresh-packagekit
...
remi                                                            | 3.0 kB     00:00     
remi/primary_db                                                 | 106 kB     00:00     
Available Packages
mysql.i686                               5.5.33-1.fc18.remi                        @remi
mysql-server.i686                        5.5.33-1.fc18.remi                        @remi

4. Update or Install MySQL 5.5.33

Fedora 18, 17, 16, 15, 14, 13, 12

yum --enablerepo=remi install mysql mysql-server

CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

yum --enablerepo=remi,remi-test install mysql mysql-server

5. Start MySQL server and autostart MySQL on boot

Fedora 18/17/16

systemctl start mysqld.service ## use restart after update

systemctl enable mysqld.service

Fedora 15/14/13/12/11, CentOS 6.4/6.3/6.2/6.1/6/5.9 and Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

/etc/init.d/mysqld start ## use restart after update
## OR ##
service mysqld start ## use restart after update

chkconfig --levels 235 mysqld on

6. MySQL Secure Installation

  • Set (Change) root password
  • Remove anonymous users
  • Disallow root login remotely
  • Remove test database and access to it
  • Reload privilege tables

Start MySQL Secure Installation with following command

/usr/bin/mysql_secure_installation

Output:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we\'ll need the current
password for the root user.  If you\'ve just installed MySQL, and
you haven\'t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you\'ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Note: If you don’t want some reason, do a “MySQL Secure Installation” then at least it’s very important to change the root user’s password

mysqladmin -u root password [your_password_here]

## Example ##
mysqladmin -u root password myownsecrectpass

7. Connect to MySQL database (localhost) with password

mysql -u root -p

## OR ##
mysql -h localhost -u root -p

8. Create Database, Create MySQL User and Enable Remote Connections to MySQL Database

This example uses following parameters:

  • DB_NAME = webdb
  • USER_NAME = webdb_user
  • REMOTE_IP = 10.0.15.25
  • PASSWORD = password123
  • PERMISSIONS = ALL
## CREATE DATABASE ##
# CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> CREATE DATABASE webdb;

## CREATE USER ##
mysql> CREATE USER 'webdb_user'@'10.0.15.25' IDENTIFIED BY 'password123';

## GRANT PERMISSIONS ##
mysql> GRANT ALL ON webdb.* TO 'webdb_user'@'10.0.15.25';

##  FLUSH PRIVILEGES, Tell the server TO reload the GRANT TABLES  ##
mysql> FLUSH PRIVILEGES;

Enable Remote Connection to MySQL Server –> Open MySQL Port (3306) on Iptables Firewall (as root user again)

1. Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

2. Add following INPUT rule:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

3. Restart Iptables Firewall:

service iptables restart
## OR ##
/etc/init.d/iptables restart

4. Test remote connection:

mysql -h dbserver_name_or_ip_address -u webdb_user -p webdb

centos 6.4更新163源

centos 6.4更新163源

1. 备份现在的源文件
#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2.   下载163源
cd /etc/yum.repos.d/
#wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
3. 把下载文件改成源文件
#mv CentOS6-Base-163.repo CentOS-Base.repo
4. 更新列表
#yum clean all
#yum makecache
5. 更新系统
#yum update
P:
如果有报错:
file:///media/CentOS/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/CentOS/repodata/repomd.xml
这样的错误是因为/etc/yum.repos.d目录下的CentOS-Media.repo所致,删除即可。