Wednesday, May 29, 2013

Percona MySQL installation tutorial


How to install

  • Install the Percona repository
 rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-1.$(uname -i).rpm
  • If the above RPM repo is not found you can check for up-to-date documentation here
 http://www.percona.com/docs/wiki/repositories:yum
  • Check the current MySQL version installed on the server
 root@grumpy [~]# mysql -V
 mysql  Ver 14.12 Distrib 5.0.92, for unknown-linux-gnu (x86_64) using readline 5.1
 root@grumpy [~]# 
  • Stop mysql server on the machine. Make sure that guardian will not restart it after stop!
 root@grumpy [~]# if [ -d /svcstop ]; then touch /svcstop/mysql; fi
 root@grumpy [~]# /etc/init.d/mysql stop
 Shutting down MySQL.                                       [  OK  ]
 root@grumpy [~]# 
  • Backup the raw files of mysql
 root@grumpy [~]# cp -a /var/lib/mysql /var/lib/mysql.backup
 root@grumpy [~]# 
  • Generate a list of your current databases
 root@grumpy [~]# mysql -A -sN -e "show databases" > active.db.list.log
  • Remove MySQL-server installed on this machine. While removing it with yum make sure that it will not remove OTHER critical system packages. If it does so use rpm -e --nodeps instead!
 root@grumpy [~]# rpm -qa | grep -i "mysql.*server"
 MySQL-server-5.0.92-0.glibc23
 root@grumpy [~]# yum remove MySQL-server-5.0.92-0.glibc23
  • Make sure to install Percona with the same ${major}.${minor} version as the old MySQL version. Use the following command to install PerconaSQL server. Disable excludes are added because of cPanel /etc/yum.conf config.
 yum --disableexcludes=main install Percona-SQL-server-SET-CORRECT-VERSION-HERE
  • Monitor closely the response of the installation process for any errors
  • Usually MySQL will be automatically started after the above yum install command. If not make sure to start it.
  • Try to connect to the MySQL server
 root@grumpy [~]# mysql -A
  • Check the mysql error log for any errors very carefully!
 root@sgded-bizserver [~]# tail -f /var/lib/mysql/$(hostname).err
  • Make sure that all clients databases are present:
 mysql -A -sN -e "show databases" > new.db.list.log
 for dbname in $(> /dev/null ); then
               echo "Database $dbname is missing from show databases"
       fi
 done
  • Enable User Statistics in /etc/my.cnf
 sed -i '/userstat_running/D' /etc/my.cnf && echo "userstat_running=1" >> /etc/my.cnf && /etc/init.d/mysql restart
Keep in mind that the userstat_running variable should be after [mysqld] definition and before any other [] definitions.
  • Make sure that the user statistics are enabled for the MySQL server
 root@grumpy [~]# mysql -e 'show variables like "userstat_running"'
 +------------------+-------+
 | Variable_name    | Value |
 +------------------+-------+
 | userstat_running | ON    | 
 +------------------+-------+
If in the above output you see OFF, this means that the userstat_running variable is in the wrong place in /etc/my.cnf.
  • You can verify that the statistics are working by executing the following command:
 root@grumpy [~]# mysql -A -sN information_schema -e "select * from user_statistics;"
  • Enable CPUstats for percona by executing:
 /usr/local/1h/bin/detect_mysql.sh
  • If you are using cPanel - In order to prevent cPanel upgrades from automatically restarting MySQL create the following files:
touch /etc/mysqldisable
touch /etc/mysqlupdisable
  • Remove guardian lock file
 root@grumpy [~]# if [ -f /svcstop/mysql ]; then rm -f /svcstop/mysql; fi

How to revert

  • Stop MySQL-Percona
  • Remove userstat_running from /etc/my.cnf
  • Install the same version of MySQL as percona was
  • Start MySQL

Ubuntu Networking Configuration Using Command Line

The basics for any network based on *nix hosts is the Transport Control Protocol/ Internet Protocol (TCP/IP) combination of three protocols. This combination consists of the Internet Protocol (IP),Transport Control Protocol (TCP), and Universal Datagram Protocol (UDP).
By Default most of the users configure their network card during the installation of Ubuntu. You can however, use the ifconfig command at the shell prompt or Ubuntu's graphical network configuration tools, such as network-admin, to edit your system's network device information or to add or remove network devices on your system
Configure Network Interface Using Command-Line
You can configure a network interface from the command line using the networking utilities. You configure your network client hosts with the command line by using commands to change your current settings or by editing a number of system files.
Configuring DHCP address for your network card
If you want to configure DHCP address you need to edit the /etc/network/interfaces and you need to enter the following lines replace eth0 with your network interface card
sudo vi /etc/network/interfaces
Note :- Use vi editor if you don't have GUI installed
If you have GUI use the following command
gksudo gedit /etc/network/interfaces
# The primary network interface -- use DHCP to find our address
auto eth0
iface eth0 inet dhcp
Configuring Static IP address for your network card
If you want to configure Static IP address you need to edit the /etc/network/interfaces and you need to enter the following lines replace eth0 with your network interface card
sudo vi /etc/network/interfaces
Note :- Use vi editor if you don't have GUI installed
If you have GUI use the following command
gksudo gedit /etc/network/interfaces
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255
After entering all the details you need to restart networking services using the following command
sudo /etc/init.d/networking restart
Setting up Second IP address or Virtual IP address in Ubuntu
If you are a server system administrator or normal user some time you need to assign a second ipaddress to your Ubuntu machine.For this you need to edit the /etc/network/interfaces file and you need to add the following syntax.Below one is the only example you need to chnage according to your ip address settings
sudo vi /etc/network/interfaces
Note :- Use vi editor if you don't have GUI installed
If you have GUI use the following command
gksudo gedit /etc/network/interfaces
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x
You need to enter all the details like address,netmask,network,broadcast and gateways values after entering all the values save this file and you need to restart networking services in debian using the following command to take effect of our new ipaddress.
After entering all the details you need to restart networking services using the following command
sudo /etc/init.d/networking restart
Setting your ubuntu stytem hostname
Setting up your hostname upon a ubuntu installation is very straightforward. You can directly query, or set, the hostname with the hostname command.
As an user you can see your current hostname with
sudo /bin/hostname
Example
To set the hostname directly you can become root and run
sudo /bin/hostname newname
When your system boots it will automatically read the hostname from the file /etc/hostname
If you want to know more about how to setup host name check here
Setting up DNS
When it comes to DNS setup Ubuntu doesn't differ from other distributions. You can add hostname and IP addresses to the file /etc/hosts for static lookups.
To cause your machine to consult with a particular server for name lookups you simply add their addresses to /etc/resolv.conf.
For example a machine which should perform lookups from the DNS server at IP address 192.168.3.2 would have a resolv.conf file looking like this
sudo vi /etc/resolv.conf
Note :- Use vi editor if you don't have GUI installed
If you have GUI use the following command
gksudo gedit /etc/resolv.conf
enter the following details
search test.com
nameserver 192.168.3.2

Restart Network Service

RedHat Linux command to reload or restart network (login as root user):
# service network restart
OR
# /etc/init.d/network restart
To start Linux network service:
# service network start
To stop Linux network service:
# service network stop
Debian Linux command to reload or restart network:
# /etc/init.d/networking restart
To start Linux network service:
# /etc/init.d/networking start
To stop Linux network service:
# /etc/init.d/networking stop
Ubuntu Linux user use sudo command with above Debian Linux command:
# sudo /etc/init.d/networking restart
To start Linux network service:
# sudo /etc/init.d/networking start
To stop Linux network service:
# sudo /etc/init.d/networking stop

Cài đặt lại DB Mysql trên CentOs

1, Stop MySQL server
 /etc/init.d/mysqld stop
2, Backup your databases.
cp /database_dir/database_files /backup_dir/.
3,  Remove Old MySQL files
yum remove mysql
4, Reinstall database
yum install mysql-server mysql
5, start database
/etc/init.d/mysqld start
6, create new users
mysql –user=root mysql -p
Enter password:
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘admin_user’@'%my_IP_address’ IDENTIFIED BY ‘only_FBI_knows’ WITH GRANT OPTION;
mysql> quit;
/etc/init.d/mysqld stop
7, edit my.cnf file
    datadir=/disk2/mysql_data
copy files to data directory
 cp -R /var/lib/mysql/* /disk2/mysql_data/.
 cp -R /backup_dir/* /disk2/mysql_data/.
 chown -R mysql:mysql  /disk2/mysql_data
8, restart mysql
/etc/init.d/mysqld start
or
/sbin/service mysqld start
9, Import backup data
mysql -p -h localhost labsupply < labsupply.sql
data  backup command:
/usr/bin/mysqldump -u root –password=topsecret –databases labsupply > labsupply.sql
10, Make sure MySQL will be started on reboot:
chkconfig mysqld on

http://www.my-whiteboard.com/how-to-reinstall-mysql-database-on-centos-redhat/ 

Monday, April 8, 2013

How To Configure Cisco's Syslog Logging


In this blog entry I will outline the steps you need to take on your Cisco Router or Catalyst device to configure syslog logging.

If you are configuring a Cisco Router for syslog logging then please follow the steps below:

1. In order to ensure that logging is enabled, issue the logging on command.

Router(config)# logging on

2. In order to specify the Essentials server that is to receive the router syslog messages, issue the logging ip_address command. ip_address is the address of the server that collects the syslog messages.

Router(config)# logging 1.1.1.1

3. In order to limit the types of messages that can be logged to the Essentials server, set the appropriate logging trap level with the logging trap informational command. The informational portion of the command signifies severity level 6. This means all messages from level 0-5 (from emergencies to notifications) are logged to the Essentials server.

Router(config)# logging trap informational

Valid logging facilities are local0 through local7.

Valid levels are:

emergency
alert
critical
error
warning
notification
informational
debug
4. In order to verify if the device sends syslog messages, run the sh logging command. You see all the syslog messages that are sent. If you do not see syslog messages, ensure that this is configured:

logging on logging console debug logging monitor debug logging trap debug

If you are configuring a Cisco Catalyst device for syslog logging please follow the steps below:

1. Ensure sure logging is enabled with the set logging server enable command.

Catalyst> (enable) set logging server enable

2. Specify the Essentials server that is to receive the router syslog messages, with the logging server_ip command. server ip is the IP address of the Essentials server.

Catalyst> (enable) set logging server 1.1.1.1

3. Limit the types of messages logged to the Essentials server. Enter set logging level informational, where informational signifies severity level 6. This means that all messages from level 0-5 (from emergencies to notifications) are logged to the Essentials server.

Catalyst> (enable) set logging server severity 6

4. In order to see if syslog messages are sent, use the sh logging buffer command. You see syslog messages that are sent. If you experience problems with switches, try this configuration:

set logging level all 7 default

set logging server enable

set logging server 1.1.1.1 (your unix syslog server ip address)

set logging server facility LOCAL7

set logging server severity 7 #syslog

set logging console enable

set logging server enable

set logging server 1.1.1.1

set logging level cdp 7 default

set logging level mcast 7 default

set logging level dtp 7 default

set logging level dvlan 7 default

set logging level earl 7 default

set logging level fddi 7 default

set logging level ip 7 default

set logging level pruning 7 default

set logging level snmp 7 default

set logging level spantree 7 default

set logging level sys 7 default

set logging level tac 7 default

set logging level tcp 7 default

set logging level telnet 7 default

set logging level tftp 7 default

set logging level vtp 7 default

set logging level vmps 7 default

set logging level kernel 7 default

set logging level filesys 7 default

set logging level drip 7 default

set logging level pagp 7 default

set logging level mgmt 7 default

set logging level mls 7 default

set logging level protfilt 7 default

set logging level security 7 default

set logging level radius 7 default

set logging level udld 7 default

set logging level gvrp 7 default

set logging server facility LOCAL7

!

Enter: sh logging

You see this output:

Logging buffer size: 500

timestamp option: enabled

Logging history size: 1

Logging console: enabled

Logging server: enabled {1.1.1.1}

server facility: LOCAL7

server severity: debugging(7)

Current Logging Session: enabled

Your Cisco device will now be configured for syslog logging.


Software 4 win: http://www.geardownload.com/internet/syslog-watcher-personal-edition-download.html

http://www.joshd.ca/content/how-configure-ciscos-syslog-logging